@@ -273,6 +273,13 @@ void main() {
273273 .childDirectory ('ios-arm64_armv7' )
274274 .childDirectory ('Flutter.framework' )
275275 .createSync (recursive: true );
276+ fileSystem
277+ .directory ('out' )
278+ .childDirectory ('host_debug_unopt' )
279+ .childDirectory ('dart-sdk' )
280+ .childDirectory ('bin' )
281+ .createSync (recursive: true );
282+
276283 expect (
277284 artifacts.getArtifactPath (
278285 Artifact .flutterFramework,
@@ -325,6 +332,75 @@ void main() {
325332 );
326333 });
327334
335+ testWithoutContext ('falls back to prebuilt dart sdk' , () {
336+ final String failureMessage = 'Unable to find a built dart sdk at:'
337+ ' "${fileSystem .path .join ('/out' , 'host_debug_unopt' , 'dart-sdk' )}"'
338+ ' or a prebuilt dart sdk at:'
339+ ' "${fileSystem .path .join ('/flutter' , 'prebuilts' , 'linux-x64' , 'dart-sdk' )}"' ;
340+
341+ expect (
342+ () => artifacts.getArtifactPath (Artifact .frontendServerSnapshotForEngineDartSdk),
343+ throwsToolExit (message: failureMessage),
344+ );
345+ expect (
346+ () => artifacts.getHostArtifact (HostArtifact .engineDartSdkPath),
347+ throwsToolExit (message: failureMessage),
348+ );
349+ expect (
350+ () => artifacts.getHostArtifact (HostArtifact .engineDartBinary),
351+ throwsToolExit (message: failureMessage),
352+ );
353+ expect (
354+ () => artifacts.getHostArtifact (HostArtifact .dart2jsSnapshot),
355+ throwsToolExit (message: failureMessage),
356+ );
357+ expect (
358+ () => artifacts.getHostArtifact (HostArtifact .dartdevcSnapshot),
359+ throwsToolExit (message: failureMessage),
360+ );
361+ expect (
362+ () => artifacts.getHostArtifact (HostArtifact .kernelWorkerSnapshot),
363+ throwsToolExit (message: failureMessage),
364+ );
365+
366+ fileSystem
367+ .directory ('flutter' )
368+ .childDirectory ('prebuilts' )
369+ .childDirectory ('linux-x64' )
370+ .childDirectory ('dart-sdk' )
371+ .childDirectory ('bin' )
372+ .createSync (recursive: true );
373+
374+ expect (
375+ artifacts.getArtifactPath (Artifact .frontendServerSnapshotForEngineDartSdk),
376+ fileSystem.path.join ('/flutter' , 'prebuilts' , 'linux-x64' , 'dart-sdk' , 'bin' ,
377+ 'snapshots' , 'frontend_server.dart.snapshot' ),
378+ );
379+ expect (
380+ artifacts.getHostArtifact (HostArtifact .engineDartSdkPath).path,
381+ fileSystem.path.join ('/flutter' , 'prebuilts' , 'linux-x64' , 'dart-sdk' ),
382+ );
383+ expect (
384+ artifacts.getHostArtifact (HostArtifact .engineDartBinary).path,
385+ fileSystem.path.join ('/flutter' , 'prebuilts' , 'linux-x64' , 'dart-sdk' , 'bin' , 'dart' ),
386+ );
387+ expect (
388+ artifacts.getHostArtifact (HostArtifact .dart2jsSnapshot).path,
389+ fileSystem.path.join ('/flutter' , 'prebuilts' , 'linux-x64' , 'dart-sdk' ,
390+ 'bin' , 'snapshots' , 'dart2js.dart.snapshot' ),
391+ );
392+ expect (
393+ artifacts.getHostArtifact (HostArtifact .dartdevcSnapshot).path,
394+ fileSystem.path.join ('/flutter' , 'prebuilts' , 'linux-x64' , 'dart-sdk' ,
395+ 'bin' , 'snapshots' , 'dartdevc.dart.snapshot' ),
396+ );
397+ expect (
398+ artifacts.getHostArtifact (HostArtifact .kernelWorkerSnapshot).path,
399+ fileSystem.path.join ('/flutter' , 'prebuilts' , 'linux-x64' , 'dart-sdk' ,
400+ 'bin' , 'snapshots' , 'kernel_worker.dart.snapshot' ),
401+ );
402+ });
403+
328404 testWithoutContext ('getEngineType' , () {
329405 expect (
330406 artifacts.getEngineType (TargetPlatform .android_arm, BuildMode .debug),
@@ -351,11 +427,81 @@ void main() {
351427 operatingSystemUtils: FakeOperatingSystemUtils (),
352428 );
353429
354- expect (artifacts.getHostArtifact (HostArtifact .engineDartBinary).path, contains ('.exe' ));
430+ fileSystem
431+ .directory ('out' )
432+ .childDirectory ('host_debug_unopt' )
433+ .childDirectory ('dart-sdk' )
434+ .childDirectory ('bin' )
435+ .createSync (recursive: true );
436+
437+ expect (
438+ artifacts.getHostArtifact (HostArtifact .engineDartBinary).path,
439+ fileSystem.path.join ('/out' , 'host_debug_unopt' , 'dart-sdk' , 'bin' , 'dart.exe' ),
440+ );
355441 });
356442
357443 testWithoutContext ('Looks up dart on linux platforms' , () async {
358- expect (artifacts.getHostArtifact (HostArtifact .engineDartBinary).path, isNot (contains ('.exe' )));
444+ fileSystem
445+ .directory ('/out' )
446+ .childDirectory ('host_debug_unopt' )
447+ .childDirectory ('dart-sdk' )
448+ .childDirectory ('bin' )
449+ .createSync (recursive: true );
450+
451+ expect (
452+ artifacts.getHostArtifact (HostArtifact .engineDartBinary).path,
453+ fileSystem.path.join ('/out' , 'host_debug_unopt' , 'dart-sdk' , 'bin' , 'dart' ),
454+ );
455+ });
456+
457+ testWithoutContext ('Finds dart-sdk in windows prebuilts' , () async {
458+ artifacts = LocalEngineArtifacts (
459+ fileSystem.path.join (fileSystem.currentDirectory.path, 'out' , 'android_debug_unopt' ),
460+ fileSystem.path.join (fileSystem.currentDirectory.path, 'out' , 'host_debug_unopt' ),
461+ cache: cache,
462+ fileSystem: fileSystem,
463+ platform: FakePlatform (operatingSystem: 'windows' ),
464+ processManager: FakeProcessManager .any (),
465+ operatingSystemUtils: FakeOperatingSystemUtils (),
466+ );
467+
468+ fileSystem
469+ .directory ('/flutter' )
470+ .childDirectory ('prebuilts' )
471+ .childDirectory ('windows-x64' )
472+ .childDirectory ('dart-sdk' )
473+ .childDirectory ('bin' )
474+ .createSync (recursive: true );
475+
476+ expect (
477+ artifacts.getHostArtifact (HostArtifact .engineDartBinary).path,
478+ fileSystem.path.join ('/flutter' , 'prebuilts' , 'windows-x64' , 'dart-sdk' , 'bin' , 'dart.exe' ),
479+ );
480+ });
481+
482+ testWithoutContext ('Finds dart-sdk in macos prebuilts' , () async {
483+ artifacts = LocalEngineArtifacts (
484+ fileSystem.path.join (fileSystem.currentDirectory.path, 'out' , 'android_debug_unopt' ),
485+ fileSystem.path.join (fileSystem.currentDirectory.path, 'out' , 'host_debug_unopt' ),
486+ cache: cache,
487+ fileSystem: fileSystem,
488+ platform: FakePlatform (operatingSystem: 'macos' ),
489+ processManager: FakeProcessManager .any (),
490+ operatingSystemUtils: FakeOperatingSystemUtils (),
491+ );
492+
493+ fileSystem
494+ .directory ('/flutter' )
495+ .childDirectory ('prebuilts' )
496+ .childDirectory ('macos-x64' )
497+ .childDirectory ('dart-sdk' )
498+ .childDirectory ('bin' )
499+ .createSync (recursive: true );
500+
501+ expect (
502+ artifacts.getHostArtifact (HostArtifact .engineDartBinary).path,
503+ fileSystem.path.join ('/flutter' , 'prebuilts' , 'macos-x64' , 'dart-sdk' , 'bin' , 'dart' ),
504+ );
359505 });
360506 });
361507}
0 commit comments