@@ -30,12 +30,8 @@ String usingTargetOSMessageForPlatform(String targetOS) =>
3030 'Specializing Platform getters for target OS $targetOS .' ;
3131final String usingTargetOSMessage =
3232 usingTargetOSMessageForPlatform (Platform .operatingSystem);
33- const crossOSExperimentalError =
34- 'Native cross-compilation support is experimental' ;
35-
36- final Target host = Target .current;
37- Target targetForOS (OS targetOS) =>
38- Target .fromArchitectureAndOS (host.architecture, targetOS);
33+ String unsupportedTargetError (Target target) =>
34+ 'Unsupported target platform $target ' ;
3935
4036void defineCompileTests () {
4137 final isRunningOnIA32 = Platform .version.contains ('ia32' );
@@ -420,25 +416,28 @@ void defineCompileTests() {
420416 mainSrc: 'void main() {print(const String.fromEnvironment("cross"));}' );
421417 final inFile = path.canonicalize (path.join (p.dirPath, p.relativeFilePath));
422418 final outFile = path.canonicalize (path.join (p.dirPath, 'myexe' ));
423- final targetOS = Platform .isLinux ? OS .macOS : OS .linux;
424-
419+ // Make sure targetOS is always unsupported (not Linux and not matches host
420+ // OS) to trigger an error.
421+ final targetOS = Platform .isWindows ? OS .macOS : OS .windows;
422+ final targetArch = Architecture .arm64;
423+ final target = Target .fromArchitectureAndOS (targetArch, targetOS);
425424 final result = await p.run (
426425 [
427426 'compile' ,
428427 'exe' ,
429428 '-v' ,
430429 '--target-os' ,
431430 targetOS.name,
431+ '--target-arch' ,
432+ targetArch.name,
432433 '-o' ,
433434 outFile,
434435 inFile,
435436 ],
436437 );
437438
438439 expect (result.stdout, isNot (contains (usingTargetOSMessage)));
439- expect (result.stderr, contains (crossOSExperimentalError));
440- expect (result.stderr, contains (host.toString ()));
441- expect (result.stderr, contains (targetForOS (targetOS).toString ()));
440+ expect (result.stderr, contains (unsupportedTargetError (target)));
442441 expect (result.exitCode, 128 );
443442 }, skip: isRunningOnIA32);
444443
@@ -513,7 +512,11 @@ void defineCompileTests() {
513512 }, skip: isRunningOnIA32);
514513
515514 test ('Compile aot snapshot cannot compile cross platform' , () async {
516- final targetOS = Platform .isLinux ? 'windows' : 'linux' ;
515+ // Make sure targetOS is always unsupported (not Linux and not matches host
516+ // OS) to trigger an error.
517+ final targetOS = Platform .isWindows ? OS .macOS : OS .windows;
518+ final targetArch = Architecture .arm64;
519+ final target = Target .fromArchitectureAndOS (targetArch, targetOS);
517520 final p = project (mainSrc: 'void main() { print("I love $targetOS "); }' );
518521 final inFile = path.canonicalize (path.join (p.dirPath, p.relativeFilePath));
519522
@@ -523,16 +526,18 @@ void defineCompileTests() {
523526 'aot-snapshot' ,
524527 '-v' ,
525528 '--target-os' ,
526- targetOS,
529+ targetOS.name,
530+ '--target-arch' ,
531+ targetArch.name,
527532 '-o' ,
528533 'main.aot' ,
529534 inFile,
530535 ],
531536 );
532537
533538 expect (result.stdout,
534- isNot (contains (usingTargetOSMessageForPlatform (targetOS))));
535- expect (result.stderr, contains (crossOSExperimentalError ));
539+ isNot (contains (usingTargetOSMessageForPlatform (targetOS.name ))));
540+ expect (result.stderr, contains (unsupportedTargetError (target) ));
536541
537542 expect (result.exitCode, isNot (0 ));
538543 }, skip: isRunningOnIA32);
0 commit comments