Skip to content
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
27 changes: 16 additions & 11 deletions packages/pigeon/tool/shared/test_runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,22 @@ import 'test_suites.dart';

/// Runs the given tests, printing status and exiting with failure if any of
/// them fails.
Future<void> runTests(List<String> 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<void> runTests(
List<String> 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) {
Expand Down
5 changes: 4 additions & 1 deletion packages/pigeon/tool/test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> main(List<String> 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',
Expand Down Expand Up @@ -105,5 +108,5 @@ ${parser.usage}''');
}
}

await runTests(testsToRun);
await runTests(testsToRun, runGeneration: !argResults.wasParsed(_noGen));
}