Generate test metrics consistently. (#145943)
Starts creating metric files consistently for web, dart and flutter runners. It also starts creating the files in the temp folder instead of the checkout one. Bug: https://github.com/flutter/flutter/issues/145793
This commit is contained in:
@@ -1665,11 +1665,15 @@ Future<void> runFlutterWebTest(
|
||||
List<String> tests,
|
||||
bool useWasm,
|
||||
) async {
|
||||
const LocalFileSystem fileSystem = LocalFileSystem();
|
||||
final String suffix = DateTime.now().microsecondsSinceEpoch.toString();
|
||||
final File metricFile = fileSystem.systemTempDirectory.childFile('metrics_$suffix.json');
|
||||
await runCommand(
|
||||
flutter,
|
||||
<String>[
|
||||
'test',
|
||||
'--reporter=expanded',
|
||||
'--file-reporter=json:${metricFile.path}',
|
||||
'-v',
|
||||
'--platform=chrome',
|
||||
if (useWasm) '--wasm',
|
||||
@@ -1683,6 +1687,10 @@ Future<void> runFlutterWebTest(
|
||||
'FLUTTER_WEB': 'true',
|
||||
},
|
||||
);
|
||||
// metriciFile is a transitional file that needs to be deleted once it is parsed.
|
||||
// TODO(godofredoc): Ensure metricFile is parsed and aggregated before deleting.
|
||||
// https://github.com/flutter/flutter/issues/146003
|
||||
metricFile.deleteSync();
|
||||
}
|
||||
|
||||
|
||||
@@ -1724,7 +1732,8 @@ Future<void> _runDartTest(String workingDirectory, {
|
||||
}
|
||||
|
||||
const LocalFileSystem fileSystem = LocalFileSystem();
|
||||
final File metricFile = fileSystem.file(path.join(flutterRoot, 'metrics.json'));
|
||||
final String suffix = DateTime.now().microsecondsSinceEpoch.toString();
|
||||
final File metricFile = fileSystem.systemTempDirectory.childFile('metrics_$suffix.json');
|
||||
final List<String> args = <String>[
|
||||
'run',
|
||||
'test',
|
||||
@@ -1787,6 +1796,11 @@ Future<void> _runDartTest(String workingDirectory, {
|
||||
print('Failed to generate metrics: $e');
|
||||
}
|
||||
}
|
||||
|
||||
// metriciFile is a transitional file that needs to be deleted once it is parsed.
|
||||
// TODO(godofredoc): Ensure metricFile is parsed and aggregated before deleting.
|
||||
// https://github.com/flutter/flutter/issues/146003
|
||||
metricFile.deleteSync();
|
||||
}
|
||||
|
||||
Future<void> _runFlutterTest(String workingDirectory, {
|
||||
@@ -1809,9 +1823,13 @@ Future<void> _runFlutterTest(String workingDirectory, {
|
||||
tags.addAll(<String>['-t', 'reduced-test-set']);
|
||||
}
|
||||
|
||||
const LocalFileSystem fileSystem = LocalFileSystem();
|
||||
final String suffix = DateTime.now().microsecondsSinceEpoch.toString();
|
||||
final File metricFile = fileSystem.systemTempDirectory.childFile('metrics_$suffix.json');
|
||||
final List<String> args = <String>[
|
||||
'test',
|
||||
'--reporter=expanded',
|
||||
'--file-reporter=json:${metricFile.path}',
|
||||
if (shuffleTests && !_isRandomizationOff) '--test-randomize-ordering-seed=$shuffleSeed',
|
||||
if (fatalWarnings) '--fatal-warnings',
|
||||
...options,
|
||||
@@ -1849,6 +1867,11 @@ Future<void> _runFlutterTest(String workingDirectory, {
|
||||
environment: environment,
|
||||
);
|
||||
|
||||
// metriciFile is a transitional file that needs to be deleted once it is parsed.
|
||||
// TODO(godofredoc): Ensure metricFile is parsed and aggregated before deleting.
|
||||
// https://github.com/flutter/flutter/issues/146003
|
||||
metricFile.deleteSync();
|
||||
|
||||
if (outputChecker != null) {
|
||||
final String? message = outputChecker(result);
|
||||
if (message != null) {
|
||||
|
||||
Reference in New Issue
Block a user