Add --dry-run to dev/bots/test.dart. (#158956)
Closes https://github.com/flutter/flutter/issues/158884. /cc @reidbaker. Example output: ```sh % SHARD=tool_integration_tests SUBSHARD=6_6 dart dev/bots/test.dart --dry-run ▌13:59:18▐ STARTING ANALYSIS ▌13:59:18▐ --dry-run enabled. Tests will not actually be executed. ▌13:59:18▐ SHARD=tool_integration_tests ▌13:59:18▐ SUBSHARD=6_6 ▌13:59:18▐ |> bin/flutter: --version ▌13:59:18▐ |> bin/cache/dart-sdk/bin/dart (packages/flutter_tools): run test --reporter=expanded --file-reporter=json:/var/folders/qw/qw_3qd1x4kz5w975jhdq4k58007b7h/T/metrics_1731621558619861.json --test-randomize-ordering-seed=20241114 -j1 test/integration.shard/shader_compiler_test.dart test/integration.shard/overall_experience_test.dart test/integration.shard/expression_evaluation_test.dart test/integration.shard/isolated/native_assets_without_cbuild_assemble_test.dart test/integration.shard/isolated/native_assets_test.dart test/integration.shard/isolated/native_assets_agp_version_test.dart test/integration.shard/coverage_collection_test.dart test/integration.shard/devtools_uri_test.dart test/integration.shard/deprecated_gradle_settings_test.dart test/integration.shard/batch_entrypoint_test.dart test/integration.shard/bash_entrypoint_test.dart test/integration.shard/background_isolate_test.dart ```
This commit is contained in:
@@ -162,6 +162,15 @@ Future<CommandResult> runCommand(String executable, List<String> arguments, {
|
||||
}) async {
|
||||
final String commandDescription = '${path.relative(executable, from: workingDirectory)} ${arguments.join(' ')}';
|
||||
final String relativeWorkingDir = workingDirectory ?? path.relative(io.Directory.current.path);
|
||||
if (dryRun) {
|
||||
printProgress(_prettyPrintRunCommand(executable, arguments, workingDirectory));
|
||||
return CommandResult._(
|
||||
0,
|
||||
Duration.zero,
|
||||
'$executable ${arguments.join(' ')}',
|
||||
'Simulated execution due to --dry-run',
|
||||
);
|
||||
}
|
||||
|
||||
final Command command = await startCommand(executable, arguments,
|
||||
workingDirectory: workingDirectory,
|
||||
@@ -205,6 +214,23 @@ Future<CommandResult> runCommand(String executable, List<String> arguments, {
|
||||
return result;
|
||||
}
|
||||
|
||||
final String _flutterRoot = path.dirname(path.dirname(path.dirname(path.fromUri(io.Platform.script))));
|
||||
|
||||
String _prettyPrintRunCommand(String executable, List<String> arguments, String? workingDirectory) {
|
||||
final StringBuffer output = StringBuffer();
|
||||
|
||||
// Print CWD relative to the root.
|
||||
output.write('|> ');
|
||||
output.write(path.relative(executable, from: _flutterRoot));
|
||||
if (workingDirectory != null) {
|
||||
output.write(' (${path.relative(workingDirectory, from: _flutterRoot)})');
|
||||
}
|
||||
output.writeln(': ');
|
||||
output.writeAll(arguments.map((String a) => ' $a'), '\n');
|
||||
|
||||
return output.toString();
|
||||
}
|
||||
|
||||
/// Specifies what to do with the command output from [runCommand] and [startCommand].
|
||||
enum OutputMode {
|
||||
/// Forwards standard output and standard error streams to the test process'
|
||||
|
||||
Reference in New Issue
Block a user