@@ -238,28 +238,6 @@ void main() {
238
238
' C:\\ .tmp_rand0\\ dir2_rand0\n ' ))));
239
239
});
240
240
241
- test ('when path has spaces' , () {
242
- expect (
243
- sanitizeExecutablePath (r'Program Files\bla.exe' ,
244
- platform: platform),
245
- r'"Program Files\bla.exe"' );
246
- expect (
247
- sanitizeExecutablePath (r'ProgramFiles\bla.exe' , platform: platform),
248
- r'ProgramFiles\bla.exe' );
249
- expect (
250
- sanitizeExecutablePath (r'"Program Files\bla.exe"' ,
251
- platform: platform),
252
- r'"Program Files\bla.exe"' );
253
- expect (
254
- sanitizeExecutablePath (r'"Program Files\bla.exe"' ,
255
- platform: platform),
256
- r'"Program Files\bla.exe"' );
257
- expect (
258
- sanitizeExecutablePath (r'C:\"Program Files"\bla.exe' ,
259
- platform: platform),
260
- r'C:\"Program Files"\bla.exe' );
261
- });
262
-
263
241
test ('with absolute path when currentDirectory getter throws' , () {
264
242
final FileSystem fsNoCwd = MemoryFileSystemNoCwd (fs);
265
243
final String command = fs.path.join (dir3.path, 'bla.exe' );
@@ -378,13 +356,6 @@ void main() {
378
356
' /.tmp_rand0/dir1_rand0\n '
379
357
' /.tmp_rand0/dir2_rand0\n ' ))));
380
358
});
381
-
382
- test ('when path has spaces' , () {
383
- expect (
384
- sanitizeExecutablePath ('/usr/local/bin/foo bar' ,
385
- platform: platform),
386
- '/usr/local/bin/foo bar' );
387
- });
388
359
});
389
360
});
390
361
group ('Real Filesystem' , () {
@@ -571,6 +542,80 @@ void main() {
571
542
' ${tmpDir .path }/path4\n '
572
543
' ${tmpDir .path }/path5\n ' ))));
573
544
});
545
+
546
+ group ('can actually execute files' , () {
547
+ void testCompileAndExecute (File mainFile) {
548
+ final localProcessManager = LocalProcessManager ();
549
+ final exePath = '${mainFile .path }.exe' ;
550
+ // Create an executable we can actually run.
551
+ expect (
552
+ localProcessManager.runSync ([
553
+ io.Platform .resolvedExecutable,
554
+ 'compile' ,
555
+ 'exe' ,
556
+ mainFile.path,
557
+ '-o' ,
558
+ exePath
559
+ ]).exitCode,
560
+ 0 );
561
+
562
+ for (final runInShell in const [true , false ]) {
563
+ final result =
564
+ localProcessManager.runSync ([exePath], runInShell: runInShell);
565
+ expect (result.exitCode, 0 ,
566
+ reason: 'runInShell: $runInShell \n stdout: ${result .stdout }\n '
567
+ 'stderr: ${result .stderr }' );
568
+ expect (result.stdout, contains ('hello' ));
569
+ }
570
+ }
571
+
572
+ test ('with spaces in the command name' , () {
573
+ final dir = tmpDir.childDirectory ('the path' );
574
+ final main = dir.childFile ('main.dart' )
575
+ ..createSync (recursive: true )
576
+ ..writeAsStringSync ('''
577
+ void main() {
578
+ print('hello');
579
+ }''' );
580
+ testCompileAndExecute (main);
581
+ });
582
+
583
+ test ('with parenthesis in the command name' , () async {
584
+ final dir = tmpDir.childDirectory ('theP()ath' );
585
+ final main = dir.childFile ('main.dart' )
586
+ ..createSync (recursive: true )
587
+ ..writeAsStringSync ('''
588
+ void main() {
589
+ print('hello');
590
+ }''' );
591
+ testCompileAndExecute (main);
592
+ },
593
+ skip: io.Platform .isWindows
594
+ ? 'https://github.com/dart-lang/tools/issues/2139'
595
+ : null );
596
+
597
+ test ('with spaces and parenthesis in the command name' , () async {
598
+ final dir = tmpDir.childDirectory ('the P()ath' );
599
+ final main = dir.childFile ('main.dart' )
600
+ ..createSync (recursive: true )
601
+ ..writeAsStringSync ('''
602
+ void main() {
603
+ print('hello');
604
+ }''' );
605
+ testCompileAndExecute (main);
606
+ });
607
+
608
+ test ('with spaces inside parenthesis in the command name' , () async {
609
+ final dir = tmpDir.childDirectory ('the P( )ath' );
610
+ final main = dir.childFile ('main.dart' )
611
+ ..createSync (recursive: true )
612
+ ..writeAsStringSync ('''
613
+ void main() {
614
+ print('hello');
615
+ }''' );
616
+ testCompileAndExecute (main);
617
+ });
618
+ });
574
619
});
575
620
}
576
621
0 commit comments