2727import java .io .File ;
2828import java .util .ArrayList ;
2929import java .util .List ;
30+ import java .util .Properties ;
3031import java .util .regex .Matcher ;
3132import 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