Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

[et] Fix concurrent modification exception #52247

Merged
merged 2 commits into from
Apr 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions tools/engine_tool/lib/src/commands/test_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,18 @@ et test //flutter/fml:fml_benchmarks # Run a single test target in `//flutter/f
);
}

final List<BuildTarget> testTargets = <BuildTarget>[];
for (final BuildTarget target in selectedTargets) {
if (!target.testOnly || target.type != BuildTargetType.executable) {
// Remove any targets that aren't testOnly and aren't executable.
selectedTargets.remove(target);
if (_isTestExecutable(target)) {
testTargets.add(target);
}
if (target.executable == null) {
environment.logger.fatal(
'$target is an executable but is missing the executable path');
}
}
// Chop off the '//' prefix.
final List<String> buildTargets = selectedTargets
final List<String> buildTargets = testTargets
.map<String>(
(BuildTarget target) => target.label.substring('//'.length))
.toList();
Expand All @@ -95,11 +95,16 @@ et test //flutter/fml:fml_benchmarks # Run a single test target in `//flutter/f
final WorkerPool workerPool =
WorkerPool(environment, ProcessTaskProgressReporter(environment));
final Set<ProcessTask> tasks = <ProcessTask>{};
for (final BuildTarget target in selectedTargets) {
for (final BuildTarget target in testTargets) {
final List<String> commandLine = <String>[target.executable!.path];
tasks.add(ProcessTask(
target.label, environment, environment.engine.srcDir, commandLine));
}
return await workerPool.run(tasks) ? 0 : 1;
}

/// Returns true if `target` is a testonly executable.
static bool _isTestExecutable(BuildTarget target) {
return target.testOnly && target.type == BuildTargetType.executable;
}
}
24 changes: 24 additions & 0 deletions tools/engine_tool/test/test_command_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,28 @@ void main() {
testEnvironment.cleanup();
}
});

test('test command skips non-testonly executables', () async {
final TestEnvironment testEnvironment = TestEnvironment.withTestEngine(
cannedProcesses: cannedProcesses,
);
try {
final Environment env = testEnvironment.environment;
final ToolCommandRunner runner = ToolCommandRunner(
environment: env,
configs: configs,
);
final int result = await runner.run(<String>[
'test',
'//third_party/protobuf:protoc',
]);
expect(result, equals(1));
expect(testEnvironment.processHistory.length, lessThan(3));
expect(testEnvironment.processHistory.where((ExecutedProcess process) {
return process.command[0].contains('protoc');
}), isEmpty);
} finally {
testEnvironment.cleanup();
}
});
}