33// found in the LICENSE file.
44
55import 'dart:convert' as convert;
6+ import 'dart:ffi' as ffi;
67import 'dart:io' as io;
78
89import 'package:engine_build_configs/src/build_config.dart' ;
@@ -39,6 +40,7 @@ void main() {
3940 // dryRun should not try to spawn any processes.
4041 processManager: _fakeProcessManager (),
4142 ),
43+ abi: ffi.Abi .linuxX64,
4244 engineSrcDir: engine.srcDir,
4345 task: generator,
4446 dryRun: true ,
@@ -65,6 +67,7 @@ void main() {
6567 // dryRun should not try to spawn any processes.
6668 processManager: _fakeProcessManager (),
6769 ),
70+ abi: ffi.Abi .linuxX64,
6871 engineSrcDir: engine.srcDir,
6972 test: test,
7073 dryRun: true ,
@@ -93,6 +96,7 @@ void main() {
9396 // dryRun should not try to spawn any processes.
9497 processManager: _fakeProcessManager (),
9598 ),
99+ abi: ffi.Abi .linuxX64,
96100 engineSrcDir: engine.srcDir,
97101 build: targetBuild,
98102 dryRun: true ,
@@ -154,6 +158,7 @@ void main() {
154158 // dryRun should not try to spawn any processes.
155159 processManager: _fakeProcessManager (),
156160 ),
161+ abi: ffi.Abi .linuxX64,
157162 engineSrcDir: engine.srcDir,
158163 build: targetBuild,
159164 extraGnArgs: < String > ['--extra-gn-arg' ],
@@ -193,6 +198,7 @@ void main() {
193198 // dryRun should not try to spawn any processes.
194199 processManager: _fakeProcessManager (),
195200 ),
201+ abi: ffi.Abi .linuxX64,
196202 engineSrcDir: engine.srcDir,
197203 build: targetBuild,
198204 extraGnArgs: < String > ['--goma' ],
@@ -218,10 +224,9 @@ void main() {
218224 final GlobalBuildRunner buildRunner = GlobalBuildRunner (
219225 platform: FakePlatform (operatingSystem: Platform .linux),
220226 processRunner: ProcessRunner (
221- processManager: _fakeProcessManager (
222- unameResult: io.ProcessResult (1 , 0 , 'arm64' , '' ),
223- ),
227+ processManager: _fakeProcessManager (),
224228 ),
229+ abi: ffi.Abi .linuxX64,
225230 engineSrcDir: engine.srcDir,
226231 build: targetBuild,
227232 extraGnArgs: < String > ['--rbe' ],
@@ -263,6 +268,7 @@ void main() {
263268 // dryRun should not try to spawn any processes.
264269 processManager: _fakeProcessManager (),
265270 ),
271+ abi: ffi.Abi .linuxX64,
266272 engineSrcDir: engine.srcDir,
267273 build: targetBuild,
268274 runGn: false ,
@@ -297,6 +303,7 @@ void main() {
297303 // dryRun should not try to spawn any processes.
298304 processManager: _fakeProcessManager (),
299305 ),
306+ abi: ffi.Abi .linuxX64,
300307 engineSrcDir: engine.srcDir,
301308 build: targetBuild,
302309 runNinja: false ,
@@ -338,6 +345,7 @@ void main() {
338345 // dryRun should not try to spawn any processes.
339346 processManager: _fakeProcessManager (),
340347 ),
348+ abi: ffi.Abi .linuxX64,
341349 engineSrcDir: engine.srcDir,
342350 build: targetBuild,
343351 runGenerators: false ,
@@ -381,6 +389,7 @@ void main() {
381389 // dryRun should not try to spawn any processes.
382390 processManager: _fakeProcessManager (),
383391 ),
392+ abi: ffi.Abi .linuxX64,
384393 engineSrcDir: engine.srcDir,
385394 build: targetBuild,
386395 runTests: false ,
@@ -409,10 +418,9 @@ void main() {
409418 final GlobalBuildRunner buildRunner = GlobalBuildRunner (
410419 platform: FakePlatform (operatingSystem: Platform .linux),
411420 processRunner: ProcessRunner (
412- processManager: _fakeProcessManager (
413- unameResult: io.ProcessResult (1 , 0 , 'arm64' , '' ),
414- ),
421+ processManager: _fakeProcessManager (),
415422 ),
423+ abi: ffi.Abi .linuxX64,
416424 engineSrcDir: engine.srcDir,
417425 build: targetBuild,
418426 extraGnArgs: < String > ['--no-lto' , '--no-goma' , '--rbe' ],
@@ -448,6 +456,7 @@ void main() {
448456 // dryRun should not try to spawn any processes.
449457 processManager: _fakeProcessManager (),
450458 ),
459+ abi: ffi.Abi .linuxX64,
451460 engineSrcDir: engine.srcDir,
452461 build: targetBuild,
453462 dryRun: true ,
@@ -469,6 +478,7 @@ void main() {
469478 gnResult: io.ProcessResult (1 , 1 , '' , '' ),
470479 ),
471480 ),
481+ abi: ffi.Abi .linuxX64,
472482 engineSrcDir: engine.srcDir,
473483 build: targetBuild,
474484 );
@@ -495,6 +505,7 @@ void main() {
495505 ninjaResult: io.ProcessResult (1 , 1 , '' , '' ),
496506 ),
497507 ),
508+ abi: ffi.Abi .linuxX64,
498509 engineSrcDir: engine.srcDir,
499510 build: targetBuild,
500511 );
@@ -518,10 +529,10 @@ void main() {
518529 platform: FakePlatform (operatingSystem: Platform .linux),
519530 processRunner: ProcessRunner (
520531 processManager: _fakeProcessManager (
521- unameResult: io.ProcessResult (1 , 0 , 'arm64' , '' ),
522532 bootstrapResult: io.ProcessResult (1 , 1 , '' , '' ),
523533 ),
524534 ),
535+ abi: ffi.Abi .linuxX64,
525536 engineSrcDir: engine.srcDir,
526537 build: targetBuild,
527538 extraGnArgs: < String > ['--rbe' ],
@@ -547,7 +558,6 @@ void main() {
547558 platform: FakePlatform (operatingSystem: Platform .linux),
548559 processRunner: ProcessRunner (
549560 processManager: _fakeProcessManager (
550- unameResult: io.ProcessResult (1 , 0 , 'arm64' , '' ),
551561 canRun: (Object ? exe, {String ? workingDirectory}) {
552562 if (exe is String ? && exe != null && exe.endsWith ('bootstrap' )) {
553563 return false ;
@@ -556,6 +566,7 @@ void main() {
556566 },
557567 ),
558568 ),
569+ abi: ffi.Abi .linuxX64,
559570 engineSrcDir: engine.srcDir,
560571 build: targetBuild,
561572 extraGnArgs: < String > ['--rbe' ],
@@ -568,10 +579,31 @@ void main() {
568579
569580 expect (events[2 ] is RunnerError , isTrue);
570581 });
582+
583+ test ('GlobalBuildRunner throws a StateError on an unsupported host cpu' , () async {
584+ final GlobalBuild targetBuild = buildConfig.builds[0 ];
585+ final GlobalBuildRunner buildRunner = GlobalBuildRunner (
586+ platform: FakePlatform (operatingSystem: Platform .linux),
587+ processRunner: ProcessRunner (
588+ processManager: _fakeProcessManager (),
589+ ),
590+ abi: ffi.Abi .linuxRiscv32,
591+ engineSrcDir: engine.srcDir,
592+ build: targetBuild,
593+ extraGnArgs: < String > ['--rbe' ],
594+ );
595+
596+ bool caughtError = false ;
597+ try {
598+ await buildRunner.run ((RunnerEvent event) {});
599+ } on StateError catch (_) {
600+ caughtError = true ;
601+ }
602+ expect (caughtError, isTrue);
603+ });
571604}
572605
573606FakeProcessManager _fakeProcessManager ({
574- io.ProcessResult ? unameResult,
575607 io.ProcessResult ? bootstrapResult,
576608 io.ProcessResult ? gnResult,
577609 io.ProcessResult ? ninjaResult,
@@ -587,7 +619,6 @@ FakeProcessManager _fakeProcessManager({
587619 return FakeProcessManager (
588620 canRun: canRun ?? (Object ? exe, {String ? workingDirectory}) => true ,
589621 onRun: (List <String > cmd) => switch (cmd) {
590- ['uname' , ...] => unameResult ?? success,
591622 _ => failUnknown ? io.ProcessResult (1 , 1 , '' , '' ) : success,
592623 },
593624 onStart: (List <String > cmd) => switch (cmd) {
0 commit comments