Unverified Commit 7a066564 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] add build system test for concurrent failures (#75251)

parent 4c545583
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
// @dart = 2.8 // @dart = 2.8
import 'dart:async';
import 'package:file/memory.dart'; import 'package:file/memory.dart';
import 'package:file_testing/file_testing.dart'; import 'package:file_testing/file_testing.dart';
import 'package:flutter_tools/src/artifacts.dart'; import 'package:flutter_tools/src/artifacts.dart';
...@@ -645,13 +647,49 @@ void main() { ...@@ -645,13 +647,49 @@ void main() {
expect(thirdResult.outputFiles, isEmpty); expect(thirdResult.outputFiles, isEmpty);
}); });
testWithoutContext('Build completes all dependencies before failing', () async {
final MemoryFileSystem fileSystem = MemoryFileSystem.test();
final BuildSystem buildSystem = setUpBuildSystem(fileSystem, FakePlatform(
operatingSystem: 'linux',
numberOfProcessors: 10, // Ensure the tool will process tasks concurrently.
));
final Completer<void> startB = Completer<void>();
final Completer<void> startC = Completer<void>();
final Completer<void> finishB = Completer<void>();
final TestTarget a = TestTarget((Environment environment) {
throw StateError('Should not run');
})..name = 'A';
final TestTarget b = TestTarget((Environment environment) async {
startB.complete();
await finishB.future;
throw Exception('1');
})..name = 'B';
final TestTarget c = TestTarget((Environment environment) {
startC.complete();
throw Exception('2');
})..name = 'C';
a.dependencies.addAll(<Target>[b, c]);
final Future<BuildResult> pendingResult = buildSystem.build(a, environment);
await startB.future;
await startC.future;
finishB.complete();
final BuildResult result = await pendingResult;
expect(result.success, false);
expect(result.exceptions.keys, containsAll(<String>['B', 'C']));
});
} }
BuildSystem setUpBuildSystem(FileSystem fileSystem) { BuildSystem setUpBuildSystem(FileSystem fileSystem, [FakePlatform platform]) {
return FlutterBuildSystem( return FlutterBuildSystem(
fileSystem: fileSystem, fileSystem: fileSystem,
logger: BufferLogger.test(), logger: BufferLogger.test(),
platform: FakePlatform(operatingSystem: 'linux'), platform: platform ?? FakePlatform(operatingSystem: 'linux'),
); );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment