[flutter_tools] add build system test for concurrent failures (#75251)
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:file_testing/file_testing.dart';
|
||||
import 'package:flutter_tools/src/artifacts.dart';
|
||||
@@ -645,13 +647,49 @@ void main() {
|
||||
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(
|
||||
fileSystem: fileSystem,
|
||||
logger: BufferLogger.test(),
|
||||
platform: FakePlatform(operatingSystem: 'linux'),
|
||||
platform: platform ?? FakePlatform(operatingSystem: 'linux'),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user