diff --git a/packages/pigeon/tool/shared/test_runner.dart b/packages/pigeon/tool/shared/test_runner.dart index ba663946b83..38935cf6913 100644 --- a/packages/pigeon/tool/shared/test_runner.dart +++ b/packages/pigeon/tool/shared/test_runner.dart @@ -13,17 +13,22 @@ import 'test_suites.dart'; /// Runs the given tests, printing status and exiting with failure if any of /// them fails. -Future runTests(List testsToRun) async { - // Pre-generate the necessary common output files. - // TODO(stuartmorgan): Consider making this conditional on the specific - // tests being run, as not all of them need these files. - final String baseDir = p.dirname(p.dirname(Platform.script.toFilePath())); - print('# Generating platform_test/ output...'); - final int generateExitCode = await generateTestPigeons(baseDir: baseDir); - if (generateExitCode == 0) { - print('Generation complete!'); - } else { - print('Generation failed; see above for errors.'); +Future runTests( + List testsToRun, { + bool runGeneration = true, +}) async { + if (runGeneration) { + // Pre-generate the necessary common output files. + // TODO(stuartmorgan): Consider making this conditional on the specific + // tests being run, as not all of them need these files. + final String baseDir = p.dirname(p.dirname(Platform.script.toFilePath())); + print('# Generating platform_test/ output...'); + final int generateExitCode = await generateTestPigeons(baseDir: baseDir); + if (generateExitCode == 0) { + print('Generation complete!'); + } else { + print('Generation failed; see above for errors.'); + } } for (final String test in testsToRun) { diff --git a/packages/pigeon/tool/test.dart b/packages/pigeon/tool/test.dart index 3667f44e78e..8d7e71b1c5d 100644 --- a/packages/pigeon/tool/test.dart +++ b/packages/pigeon/tool/test.dart @@ -18,11 +18,14 @@ import 'shared/test_runner.dart'; import 'shared/test_suites.dart'; const String _testFlag = 'test'; +const String _noGen = 'no-generation'; const String _listFlag = 'list'; Future main(List args) async { final ArgParser parser = ArgParser() ..addMultiOption(_testFlag, abbr: 't', help: 'Only run specified tests.') + ..addFlag(_noGen, + abbr: 'g', help: 'Skips the generation step.', negatable: false) ..addFlag(_listFlag, negatable: false, abbr: 'l', help: 'List available tests.') ..addFlag('help', @@ -105,5 +108,5 @@ ${parser.usage}'''); } } - await runTests(testsToRun); + await runTests(testsToRun, runGeneration: !argResults.wasParsed(_noGen)); }