From 953a9471308ec523fcbb4037da6e7d89a49fe88d Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Fri, 29 Mar 2019 17:00:19 -0700 Subject: [PATCH] add coverage benchmark (#30222) --- .../bin/tasks/flutter_test_performance.dart | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/dev/devicelab/bin/tasks/flutter_test_performance.dart b/dev/devicelab/bin/tasks/flutter_test_performance.dart index 0e5ef8d979..3843f1c53f 100644 --- a/dev/devicelab/bin/tasks/flutter_test_performance.dart +++ b/dev/devicelab/bin/tasks/flutter_test_performance.dart @@ -36,11 +36,18 @@ enum TestStep { testPassed, } -Future runTest() async { +Future runTest({bool coverage = false}) async { final Stopwatch clock = Stopwatch()..start(); + final List arguments = [ + 'test', + ]; + if (coverage) { + arguments.add('--coverage'); + } + arguments.add(path.join('flutter_test', 'trivial_widget_test.dart')); final Process analysis = await startProcess( path.join(flutterDirectory.path, 'bin', 'flutter'), - ['test', path.join('flutter_test', 'trivial_widget_test.dart')], + arguments, workingDirectory: path.join(flutterDirectory.path, 'dev', 'automated_tests'), ); int badLines = 0; @@ -50,6 +57,8 @@ Future runTest() async { if (step == TestStep.starting && entry == 'Building flutter tool...') { // ignore this line 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...') { // ignore this line step = TestStep.runningPubGet; @@ -113,10 +122,13 @@ void main() { .replaceAll('_xyzzy', 'owner') ); 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 data = { 'without_change_elapsed_time_ms': withoutChange, 'implementation_change_elapsed_time_ms': implementationChange, 'interface_change_elapsed_time_ms': interfaceChange, + 'with_coverage_time_ms': withCoverage, }; return TaskResult.success(data, benchmarkScoreKeys: data.keys.toList()); } finally {