Skip to content

Commit d539693

Browse files
committed
Updated to read dart.sdk from getenv if getProperty doesn't work (getenv might be correct).
Updated to allow access to necessary test files
1 parent 7a0fbb7 commit d539693

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

third_party/src/test/java/com/jetbrains/lang/dart/util/DartTestUtils.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.io.File;
2828
import java.util.ArrayList;
2929
import java.util.List;
30+
import java.util.Properties;
3031
import java.util.regex.Matcher;
3132
import java.util.regex.Pattern;
3233

@@ -65,8 +66,22 @@ private static String findTestDataPath() {
6566
@TestOnly
6667
public static void configureDartSdk(@NotNull final Module module, @NotNull final Disposable disposable, final boolean realSdk) {
6768
final String sdkHome;
69+
String tempSdk;
70+
6871
if (realSdk) {
69-
sdkHome = System.getProperty("dart.sdk");
72+
tempSdk = System.getProperty("dart.sdk");
73+
74+
// getting the dart.sdk from System.getProperty() was failing in many cases on Windows,
75+
// inexplicably? However, since the dart.sdk is an environment variable it makes sense that
76+
// getenv works here
77+
//
78+
if (tempSdk == null) {
79+
// try to get from System.getEnv
80+
tempSdk = System.getenv("dart.sdk");
81+
}
82+
83+
sdkHome = tempSdk;
84+
7085
if (sdkHome == null) {
7186
Assert.fail("To run tests that use Dart Analysis Server you need to add '-Ddart.sdk=[real SDK home]' to the VM Options field of " +
7287
"the corresponding JUnit run configuration (Run | Edit Configurations)");
@@ -82,6 +97,11 @@ public static void configureDartSdk(@NotNull final Module module, @NotNull final
8297

8398
VfsRootAccess.allowRootAccess(disposable, sdkHome);
8499

100+
// The above root access doesn't always work properly, the line below
101+
// sets access to anything from src/test/testData and below
102+
//
103+
VfsRootAccess.allowRootAccess(disposable, BASE_TEST_DATA_PATH);
104+
85105
ApplicationManager.getApplication().runWriteAction(() -> {
86106
Disposer.register(disposable, DartSdkLibUtil.configureDartSdkAndReturnUndoingDisposable(module.getProject(), sdkHome));
87107
Disposer.register(disposable, DartSdkLibUtil.enableDartSdkAndReturnUndoingDisposable(module));

0 commit comments

Comments
 (0)