d810c7d0c0
This commit was generated by the following steps: - Manually change the SDK constraint in `pkg/front_end/pubspec.yaml` - Run `gclient sync` - Run `find pkg/front_end/benchmarks pkg/front_end/lib pkg/front_end/presubmit_helper.dart pkg/front_end/presubmit_helper_spawn.dart pkg/front_end/test pkg/front_end/tool -iname '*.dart' | xargs tools/sdks/dart-sdk/bin/dart format` - Manually fix remaining long lines and add dead code ignore comments. - Fix coverage by running `dart --enable-asserts pkg/front_end/test/coverage_suite.dart --tasks=5 --add-and-remove-comments` - Fix `pkg/front_end/test/coverage_merger/assert_message_auto_ignored` by running `dart pkg/front_end/test/unit_test_suites.dart -p pkg/front_end/test/coverage_merger/assert_message_auto_ignored -DupdateExpectations=true` The diff is large because the version bump causes the formatter to switch into "tall mode". Change-Id: I6a6a696410da8b168060acfe0e4d6e91e294c4f0 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/447628 Auto-Submit: Paul Berry <paulberry@google.com> Reviewed-by: Johnni Winther <johnniwinther@google.com> Commit-Queue: Johnni Winther <johnniwinther@google.com>
105 lines
3.0 KiB
Dart
105 lines
3.0 KiB
Dart
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
|
|
// for details. 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 'coverage_helper.dart';
|
|
import 'vm_service_helper.dart' as vmService;
|
|
|
|
Future<void> main(List<String> args) async {
|
|
CoverageHelper coverageHelper = new CoverageHelper();
|
|
|
|
List<String> allArgs = <String>[];
|
|
allArgs.addAll([
|
|
"--disable-dart-dev",
|
|
"--enable-asserts",
|
|
"--pause_isolates_on_exit",
|
|
]);
|
|
allArgs.addAll(args);
|
|
|
|
await coverageHelper.start(allArgs);
|
|
}
|
|
|
|
class CoverageHelper extends vmService.LaunchingVMServiceHelper {
|
|
final bool forceCompilation;
|
|
final bool printHits;
|
|
final bool doPrint;
|
|
|
|
CoverageHelper({
|
|
this.forceCompilation = false,
|
|
this.printHits = true,
|
|
this.doPrint = true,
|
|
});
|
|
|
|
@override
|
|
Future<void> run() async {
|
|
vmService.VM vm = await serviceClient.getVM();
|
|
if (vm.isolates!.length != 1) {
|
|
throw "Expected 1 isolate, got ${vm.isolates!.length}";
|
|
}
|
|
vmService.IsolateRef isolateRef = vm.isolates!.single;
|
|
await waitUntilIsolateIsRunnable(isolateRef.id!);
|
|
await serviceClient.resume(isolateRef.id!);
|
|
Completer<String> cTimeout = new Completer();
|
|
Timer timer = new Timer(new Duration(minutes: 20), () {
|
|
cTimeout.complete("Timeout");
|
|
killProcess();
|
|
});
|
|
|
|
Completer<String> cRunDone = new Completer();
|
|
// ignore: unawaited_futures
|
|
waitUntilPaused(isolateRef.id!).then((value) => cRunDone.complete("Done"));
|
|
|
|
await Future.any([cRunDone.future, cTimeout.future, cProcessExited.future]);
|
|
|
|
timer.cancel();
|
|
|
|
if (!await isPausedAtExit(isolateRef.id!)) {
|
|
killProcess();
|
|
throw "Expected to be paused at exit, but is just paused!";
|
|
}
|
|
|
|
// Get and process coverage information.
|
|
Stopwatch stopwatch = new Stopwatch()..start();
|
|
vmService.SourceReport sourceReport = await serviceClient.getSourceReport(
|
|
isolateRef.id!,
|
|
[vmService.SourceReportKind.kCoverage],
|
|
forceCompile: forceCompilation,
|
|
);
|
|
print("Got source report from VM in ${stopwatch.elapsedMilliseconds} ms");
|
|
stopwatch.reset();
|
|
Coverage coverage = getCoverageFromSourceReport([
|
|
sourceReport,
|
|
], includeCoverageFor);
|
|
|
|
// It's paused at exit, so resuming should allow us to exit.
|
|
await serviceClient.resume(isolateRef.id!);
|
|
|
|
if (doPrint) {
|
|
coverage.printCoverage(printHits);
|
|
}
|
|
gotCoverage(coverage);
|
|
}
|
|
|
|
void gotCoverage(Coverage coverage) {}
|
|
|
|
bool includeCoverageFor(Uri uri) {
|
|
if (uri.isScheme("dart")) {
|
|
return false;
|
|
}
|
|
if (uri.isScheme("package")) {
|
|
return uri.pathSegments.first == "front_end" ||
|
|
uri.pathSegments.first == "_fe_analyzer_shared" ||
|
|
uri.pathSegments.first == "kernel";
|
|
}
|
|
return true;
|
|
}
|
|
|
|
Completer<String> cProcessExited = new Completer();
|
|
@override
|
|
void processExited(int exitCode) {
|
|
cProcessExited.complete("Exit");
|
|
}
|
|
}
|