Unverified Commit 953a9471 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

add coverage benchmark (#30222)

parent 22584305
...@@ -36,11 +36,18 @@ enum TestStep { ...@@ -36,11 +36,18 @@ enum TestStep {
testPassed, testPassed,
} }
Future<int> runTest() async { Future<int> runTest({bool coverage = false}) async {
final Stopwatch clock = Stopwatch()..start(); final Stopwatch clock = Stopwatch()..start();
final List<String> arguments = <String>[
'test',
];
if (coverage) {
arguments.add('--coverage');
}
arguments.add(path.join('flutter_test', 'trivial_widget_test.dart'));
final Process analysis = await startProcess( final Process analysis = await startProcess(
path.join(flutterDirectory.path, 'bin', 'flutter'), path.join(flutterDirectory.path, 'bin', 'flutter'),
<String>['test', path.join('flutter_test', 'trivial_widget_test.dart')], arguments,
workingDirectory: path.join(flutterDirectory.path, 'dev', 'automated_tests'), workingDirectory: path.join(flutterDirectory.path, 'dev', 'automated_tests'),
); );
int badLines = 0; int badLines = 0;
...@@ -50,6 +57,8 @@ Future<int> runTest() async { ...@@ -50,6 +57,8 @@ Future<int> runTest() async {
if (step == TestStep.starting && entry == 'Building flutter tool...') { if (step == TestStep.starting && entry == 'Building flutter tool...') {
// ignore this line // ignore this line
step = TestStep.buildingFlutterTool; step = TestStep.buildingFlutterTool;
} else if (step == TestStep.testPassed && entry.contains('Collecting coverage information...')) {
// ignore this line
} else if (step.index < TestStep.runningPubGet.index && entry == 'Running "flutter packages get" in automated_tests...') { } else if (step.index < TestStep.runningPubGet.index && entry == 'Running "flutter packages get" in automated_tests...') {
// ignore this line // ignore this line
step = TestStep.runningPubGet; step = TestStep.runningPubGet;
...@@ -113,10 +122,13 @@ void main() { ...@@ -113,10 +122,13 @@ void main() {
.replaceAll('_xyzzy', 'owner') .replaceAll('_xyzzy', 'owner')
); );
final int interfaceChange = await runTest(); // run test again with interface changed final int interfaceChange = await runTest(); // run test again with interface changed
// run test with coverage enabled.
final int withCoverage = await runTest(coverage: true);
final Map<String, dynamic> data = <String, dynamic>{ final Map<String, dynamic> data = <String, dynamic>{
'without_change_elapsed_time_ms': withoutChange, 'without_change_elapsed_time_ms': withoutChange,
'implementation_change_elapsed_time_ms': implementationChange, 'implementation_change_elapsed_time_ms': implementationChange,
'interface_change_elapsed_time_ms': interfaceChange, 'interface_change_elapsed_time_ms': interfaceChange,
'with_coverage_time_ms': withCoverage,
}; };
return TaskResult.success(data, benchmarkScoreKeys: data.keys.toList()); return TaskResult.success(data, benchmarkScoreKeys: data.keys.toList());
} finally { } finally {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment