95b1b8d756
(Part of https://github.com/dart-lang/sdk/issues/63288) This change migrates the front_end package to use the new constructor declaration syntax, described in https://github.com/dart-lang/language/blob/main/accepted/future-releases/primary-constructors/feature-specification.md#abbreviations-of-in-body-constructor-declarations. This change was performed in an automated fashion, by (a) enabling the lints `unnecessary_type_name_in_constructor` and `unnecessary_const_in_enum_constructor`, (b) fixing the resulting lint failures using `dart fix`, and then (c) reformatting the affected files. To ease code review, I've reverted unrelated formatting changes. Change-Id: I6b48c0f1c762c3fa132fbd79382496ca6a6a6964 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/508368 Reviewed-by: Konstantin Shcheglov <scheglov@google.com> SLSA-Policy-Verified: SLSA Policy Verification Service <devtools-gerritcodereview-exitgate@google.com> Commit-Queue: Paul Berry <paulberry@google.com>
89 lines
2.4 KiB
Dart
89 lines
2.4 KiB
Dart
// Copyright (c) 2024, 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 'dart:io';
|
|
|
|
import '../test/coverage_helper.dart';
|
|
import '../test/vm_service_helper.dart';
|
|
|
|
Uri? coverageUri;
|
|
|
|
Future<void> main(List<String> args) async {
|
|
String? coverage = Platform.environment["CFE_COVERAGE"];
|
|
if (coverage != null) {
|
|
coverageUri = Uri.base.resolveUri(Uri.file(coverage));
|
|
} else {
|
|
throw "Set coverage path via 'CFE_COVERAGE' environment!";
|
|
}
|
|
|
|
MyLaunchingVMServiceHelper launchingHelper = new MyLaunchingVMServiceHelper(
|
|
args,
|
|
);
|
|
await launchingHelper.start([
|
|
"--pause_isolates_on_exit",
|
|
"--disable-dart-dev",
|
|
...args,
|
|
], pauseIsolateOnStart: false);
|
|
await launchingHelper.exitCompleter.future;
|
|
}
|
|
|
|
class MyLaunchingVMServiceHelper extends LaunchingVMServiceHelper {
|
|
final List<String> args;
|
|
final Completer<int> exitCompleter = new Completer<int>();
|
|
|
|
new(this.args);
|
|
|
|
@override
|
|
void processExited(int code) {
|
|
exitCode = code;
|
|
exitCompleter.complete(code);
|
|
}
|
|
|
|
@override
|
|
Future<void> run() async {
|
|
// TODO(jensj): Get coverage for the isolate paused at exit, then resume
|
|
// that one, continue until there's no more isolates left.
|
|
// E.g. for pkg/front_end/tool/coverage_runner.dart.
|
|
await waitUntilSomeIsolatePausedAtExit();
|
|
|
|
Coverage? coverage = await collectCoverageWithHelper(
|
|
helper: this,
|
|
getKernelServiceCoverageToo: true,
|
|
displayName: args.join(" "),
|
|
);
|
|
if (coverage != null) {
|
|
File f = new File.fromUri(
|
|
coverageUri!.resolve(
|
|
"coverage_run_"
|
|
"${DateTime.now().microsecondsSinceEpoch}_"
|
|
"${process.pid}.coverage",
|
|
),
|
|
);
|
|
coverage.writeToFile(f);
|
|
}
|
|
|
|
await resumeAllIsolates();
|
|
try {
|
|
while (true) {
|
|
VM vm = await serviceClient.getVM();
|
|
List<IsolateRef> isolates = vm.isolates!;
|
|
if (isolates.isEmpty) break;
|
|
for (IsolateRef isolate in isolates) {
|
|
try {
|
|
if (await isPaused(isolate.id!) == true) {
|
|
await serviceClient.resume(isolate.id!);
|
|
}
|
|
} catch (e) {
|
|
// It might exit at some point so we can't expect to get
|
|
// a good result.
|
|
}
|
|
}
|
|
}
|
|
} catch (e) {
|
|
// Assume this is a good thing.
|
|
}
|
|
}
|
|
}
|