From 5748a7a6bd072ab66d18bbededc35c4b592ba4fa Mon Sep 17 00:00:00 2001 From: tarrinneal Date: Fri, 11 Aug 2023 15:25:29 -0700 Subject: [PATCH 1/3] skipGen --- packages/pigeon/tool/shared/test_runner.dart | 16 +++++++++------- packages/pigeon/tool/test.dart | 4 +++- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/pigeon/tool/shared/test_runner.dart b/packages/pigeon/tool/shared/test_runner.dart index ba663946b83..df7556886b1 100644 --- a/packages/pigeon/tool/shared/test_runner.dart +++ b/packages/pigeon/tool/shared/test_runner.dart @@ -13,17 +13,19 @@ import 'test_suites.dart'; /// Runs the given tests, printing status and exiting with failure if any of /// them fails. -Future runTests(List testsToRun) async { +Future runTests(List testsToRun, {bool skipGen = false}) 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.'); + if (!skipGen) { + 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..376f7dd888c 100644 --- a/packages/pigeon/tool/test.dart +++ b/packages/pigeon/tool/test.dart @@ -18,11 +18,13 @@ import 'shared/test_runner.dart'; import 'shared/test_suites.dart'; const String _testFlag = 'test'; +const String _genFlag = 'skip-generation'; const String _listFlag = 'list'; Future main(List args) async { final ArgParser parser = ArgParser() ..addMultiOption(_testFlag, abbr: 't', help: 'Only run specified tests.') + ..addFlag(_genFlag, abbr: 'g', help: 'Skips the generation step.') ..addFlag(_listFlag, negatable: false, abbr: 'l', help: 'List available tests.') ..addFlag('help', @@ -105,5 +107,5 @@ ${parser.usage}'''); } } - await runTests(testsToRun); + await runTests(testsToRun, skipGen: true); } From 9bbdab17b4e49f341ebe17614434a5574d710005 Mon Sep 17 00:00:00 2001 From: tarrinneal Date: Fri, 11 Aug 2023 15:28:48 -0700 Subject: [PATCH 2/3] more if --- packages/pigeon/tool/shared/test_runner.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/pigeon/tool/shared/test_runner.dart b/packages/pigeon/tool/shared/test_runner.dart index df7556886b1..e341848b604 100644 --- a/packages/pigeon/tool/shared/test_runner.dart +++ b/packages/pigeon/tool/shared/test_runner.dart @@ -14,11 +14,11 @@ import 'test_suites.dart'; /// Runs the given tests, printing status and exiting with failure if any of /// them fails. Future runTests(List testsToRun, {bool skipGen = false}) 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())); if (!skipGen) { + // 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) { From ea456f8700390e6296e1bc70941eeda5ea1937a8 Mon Sep 17 00:00:00 2001 From: tarrinneal Date: Fri, 11 Aug 2023 15:42:38 -0700 Subject: [PATCH 3/3] review fixes --- packages/pigeon/tool/shared/test_runner.dart | 7 +++++-- packages/pigeon/tool/test.dart | 7 ++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/pigeon/tool/shared/test_runner.dart b/packages/pigeon/tool/shared/test_runner.dart index e341848b604..38935cf6913 100644 --- a/packages/pigeon/tool/shared/test_runner.dart +++ b/packages/pigeon/tool/shared/test_runner.dart @@ -13,8 +13,11 @@ import 'test_suites.dart'; /// Runs the given tests, printing status and exiting with failure if any of /// them fails. -Future runTests(List testsToRun, {bool skipGen = false}) async { - if (!skipGen) { +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. diff --git a/packages/pigeon/tool/test.dart b/packages/pigeon/tool/test.dart index 376f7dd888c..8d7e71b1c5d 100644 --- a/packages/pigeon/tool/test.dart +++ b/packages/pigeon/tool/test.dart @@ -18,13 +18,14 @@ import 'shared/test_runner.dart'; import 'shared/test_suites.dart'; const String _testFlag = 'test'; -const String _genFlag = 'skip-generation'; +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(_genFlag, abbr: 'g', help: 'Skips the generation step.') + ..addFlag(_noGen, + abbr: 'g', help: 'Skips the generation step.', negatable: false) ..addFlag(_listFlag, negatable: false, abbr: 'l', help: 'List available tests.') ..addFlag('help', @@ -107,5 +108,5 @@ ${parser.usage}'''); } } - await runTests(testsToRun, skipGen: true); + await runTests(testsToRun, runGeneration: !argResults.wasParsed(_noGen)); }