diff --git a/dev/devicelab/bin/tasks/dartdocs.dart b/dev/devicelab/bin/tasks/dartdocs.dart new file mode 100644 index 0000000000..de99aa813d --- /dev/null +++ b/dev/devicelab/bin/tasks/dartdocs.dart @@ -0,0 +1,60 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:async'; +import 'dart:convert'; +import 'dart:io'; + +import 'package:flutter_devicelab/framework/framework.dart'; +import 'package:flutter_devicelab/framework/utils.dart'; + +Future main() async { + await task(() async { + final Stopwatch clock = new Stopwatch()..start(); + final Process analysis = await startProcess( + 'flutter', + ['analyze', '--flutter-repo', '--dartdocs'], + workingDirectory: flutterDirectory.path, + ); + int publicMembers = 0; + int otherErrors = 0; + int otherLines = 0; + await for (String entry in analysis.stderr.transform(UTF8.decoder).transform(const LineSplitter())) { + print('analyzer stderr: $entry'); + if (entry.startsWith('[lint] Document all public members')) { + publicMembers += 1; + } else if (entry.startsWith('[')) { + otherErrors += 1; + } else if (entry.startsWith('(Ran in ')) { + // ignore this line + } else { + otherLines += 1; + } + } + await for (String entry in analysis.stdout.transform(UTF8.decoder).transform(const LineSplitter())) { + print('analyzer stdout: $entry'); + if (entry == 'Building flutter tool...') { + // ignore this line + } else if (entry.startsWith('Analyzing ')) { + // ignore this line + } else { + otherLines += 1; + } + } + final int result = await analysis.exitCode; + clock.stop(); + if (publicMembers == 0 && otherErrors == 0 && result != 0) + throw new Exception('flutter analyze exited with unexpected error code $result'); + if (publicMembers != 0 && otherErrors != 0 && result == 0) + throw new Exception('flutter analyze exited with successful status code despite reporting errors'); + if (otherLines != 0) + throw new Exception('flutter analyze had unexpected output (we saw $otherLines unexpected line${ otherLines == 1 ? "" : "s" })'); + final Map data = { + 'members_missing_dartdocs': publicMembers, + 'analysis_errors': otherErrors, + 'elapsed_time_ms': clock.elapsedMilliseconds, + }; + return new TaskResult.success(data, benchmarkScoreKeys: data.keys.toList()); + }); +} diff --git a/dev/devicelab/manifest.yaml b/dev/devicelab/manifest.yaml index 2f2bfdaccf..014fbaadb4 100644 --- a/dev/devicelab/manifest.yaml +++ b/dev/devicelab/manifest.yaml @@ -75,6 +75,12 @@ tasks: stage: devicelab required_agent_capabilities: ["has-android-device"] + dartdocs: + description: > + Tracks how many members are still lacking documentation. + stage: devicelab + required_agent_capabilities: ["has-android-device"] + # Android on-device tests complex_layout_scroll_perf__timeline_summary: @@ -190,14 +196,14 @@ tasks: # Measures the startup time of the Flutter Gallery app on iOS. # stage: devicelab_ios # required_agent_capabilities: ["has-ios-device"] -# flaky: true +# flaky: true # complex_layout_ios__start_up: # description: > # Measures the startup time of the Complex Layout sample app on iOS. # stage: devicelab_ios # required_agent_capabilities: ["has-ios-device"] -# flaky: true +# flaky: true flutter_gallery_ios__transition_perf: description: > @@ -225,7 +231,7 @@ tasks: # Verifies that Flutter View can be used from an iOS project. # stage: devicelab_ios # required_agent_capabilities: ["has-ios-device"] -# flaky: true +# flaky: true integration_ui_ios: description: >