diff --git a/tools/engine_tool/lib/src/commands/test_command.dart b/tools/engine_tool/lib/src/commands/test_command.dart index ff0249bf1ae99..63dd438c1dabb 100644 --- a/tools/engine_tool/lib/src/commands/test_command.dart +++ b/tools/engine_tool/lib/src/commands/test_command.dart @@ -72,7 +72,7 @@ et test //flutter/fml:fml_benchmarks # Run a single test target in `//flutter/f final List testTargets = []; for (final BuildTarget target in selectedTargets) { - if (target.testOnly && target.type == BuildTargetType.executable) { + if (_isTestExecutable(target)) { testTargets.add(target); } if (target.executable == null) { @@ -102,4 +102,9 @@ et test //flutter/fml:fml_benchmarks # Run a single test target in `//flutter/f } 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; + } } diff --git a/tools/engine_tool/test/test_command_test.dart b/tools/engine_tool/test/test_command_test.dart index b8e5788b63976..ff37bf875c9d4 100644 --- a/tools/engine_tool/test/test_command_test.dart +++ b/tools/engine_tool/test/test_command_test.dart @@ -67,4 +67,29 @@ 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([ + '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(); + } + }); }