Skip to content

Commit 6cc49a4

Browse files
authored
[pigeon] skipGen (#4682)
adds ability to run pigeon tests without regenerating code (to make iterating and testing easier).
1 parent ec83969 commit 6cc49a4

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

packages/pigeon/tool/shared/test_runner.dart

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,22 @@ import 'test_suites.dart';
1313

1414
/// Runs the given tests, printing status and exiting with failure if any of
1515
/// them fails.
16-
Future<void> runTests(List<String> testsToRun) async {
17-
// Pre-generate the necessary common output files.
18-
// TODO(stuartmorgan): Consider making this conditional on the specific
19-
// tests being run, as not all of them need these files.
20-
final String baseDir = p.dirname(p.dirname(Platform.script.toFilePath()));
21-
print('# Generating platform_test/ output...');
22-
final int generateExitCode = await generateTestPigeons(baseDir: baseDir);
23-
if (generateExitCode == 0) {
24-
print('Generation complete!');
25-
} else {
26-
print('Generation failed; see above for errors.');
16+
Future<void> runTests(
17+
List<String> testsToRun, {
18+
bool runGeneration = true,
19+
}) async {
20+
if (runGeneration) {
21+
// Pre-generate the necessary common output files.
22+
// TODO(stuartmorgan): Consider making this conditional on the specific
23+
// tests being run, as not all of them need these files.
24+
final String baseDir = p.dirname(p.dirname(Platform.script.toFilePath()));
25+
print('# Generating platform_test/ output...');
26+
final int generateExitCode = await generateTestPigeons(baseDir: baseDir);
27+
if (generateExitCode == 0) {
28+
print('Generation complete!');
29+
} else {
30+
print('Generation failed; see above for errors.');
31+
}
2732
}
2833

2934
for (final String test in testsToRun) {

packages/pigeon/tool/test.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,14 @@ import 'shared/test_runner.dart';
1818
import 'shared/test_suites.dart';
1919

2020
const String _testFlag = 'test';
21+
const String _noGen = 'no-generation';
2122
const String _listFlag = 'list';
2223

2324
Future<void> main(List<String> args) async {
2425
final ArgParser parser = ArgParser()
2526
..addMultiOption(_testFlag, abbr: 't', help: 'Only run specified tests.')
27+
..addFlag(_noGen,
28+
abbr: 'g', help: 'Skips the generation step.', negatable: false)
2629
..addFlag(_listFlag,
2730
negatable: false, abbr: 'l', help: 'List available tests.')
2831
..addFlag('help',
@@ -105,5 +108,5 @@ ${parser.usage}''');
105108
}
106109
}
107110

108-
await runTests(testsToRun);
111+
await runTests(testsToRun, runGeneration: !argResults.wasParsed(_noGen));
109112
}

0 commit comments

Comments
 (0)