@@ -21,9 +21,11 @@ import '../../src/fakes.dart';
21
21
import '../../src/test_flutter_command_runner.dart' ;
22
22
23
23
const String flutterRoot = r'C:\flutter' ;
24
- const String buildFilePath = r'C:\windows\CMakeLists.txt' ;
25
- const String visualStudioPath = r'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community' ;
26
- const String _cmakePath = visualStudioPath + r'\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe' ;
24
+ const String buildFilePath = r'windows\CMakeLists.txt' ;
25
+ const String visualStudioPath =
26
+ r'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community' ;
27
+ const String _cmakePath = visualStudioPath +
28
+ r'\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe' ;
27
29
const String _defaultGenerator = 'Visual Studio 16 2019' ;
28
30
29
31
final Platform windowsPlatform = FakePlatform (
@@ -80,7 +82,7 @@ void main() {
80
82
command: < String > [
81
83
_cmakePath,
82
84
'-S' ,
83
- fileSystem.path.dirname (buildFilePath),
85
+ fileSystem.path.absolute (fileSystem.path. dirname (buildFilePath) ),
84
86
'-B' ,
85
87
r'build\windows' ,
86
88
'-G' ,
@@ -923,7 +925,7 @@ if %errorlevel% neq 0 goto :VCEnd</Command>
923
925
expect (testLogger.statusText, contains ('A summary of your Windows bundle analysis can be found at' ));
924
926
expect (testLogger.statusText, contains ('flutter pub global activate devtools; flutter pub global run devtools --appSizeBase=' ));
925
927
expect (usage.events, contains (
926
- const TestUsageEvent ('code-size-analysis' , 'windows' ),
928
+ const TestUsageEvent ('code-size-analysis' , 'windows' ),
927
929
));
928
930
}, overrides: < Type , Generator > {
929
931
FeatureFlags : () => TestFeatureFlags (isWindowsEnabled: true ),
@@ -933,6 +935,35 @@ if %errorlevel% neq 0 goto :VCEnd</Command>
933
935
FileSystemUtils : () => FileSystemUtils (fileSystem: fileSystem, platform: windowsPlatform),
934
936
Usage : () => usage,
935
937
});
938
+
939
+ // Confirms that running for Windows in a directory with a
940
+ // bad character (' in this case) throws the desired error message
941
+ // If the issue https://github.com/flutter/flutter/issues/104802 ever
942
+ // is resolved on the VS side, we can allow these paths again
943
+ testUsingContext ('Test bad path characters' , () async {
944
+ final FakeVisualStudio fakeVisualStudio = FakeVisualStudio ();
945
+ final BuildWindowsCommand command = BuildWindowsCommand ()
946
+ ..visualStudioOverride = fakeVisualStudio;
947
+ fileSystem.currentDirectory = fileSystem.directory ("test_'path" )
948
+ ..createSync ();
949
+ final String absPath = fileSystem.currentDirectory.absolute.path;
950
+ setUpMockCoreProjectFiles ();
951
+
952
+ expect (
953
+ createTestCommandRunner (command).run (const < String > ['windows' , '--no-pub' ]),
954
+ throwsToolExit (
955
+ message:
956
+ 'Path $absPath contains invalid characters in "\' #!\$ ^&*=|,;<>?". '
957
+ 'Please rename your directory so as to not include any of these characters '
958
+ 'and retry.' ,
959
+ ),
960
+ );
961
+ }, overrides: < Type , Generator > {
962
+ Platform : () => windowsPlatform,
963
+ FileSystem : () => fileSystem,
964
+ ProcessManager : () => FakeProcessManager .any (),
965
+ FeatureFlags : () => TestFeatureFlags (isWindowsEnabled: true ),
966
+ });
936
967
}
937
968
938
969
class FakeVisualStudio extends Fake implements VisualStudio {
0 commit comments