Unverified Commit 542fbd4c authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

Some minor fixes to the tool_coverage tool. (#36570)

Extracted from https://github.com/flutter/flutter/pull/36205
parent 45ae4f6d
......@@ -10,7 +10,7 @@ import 'dart:isolate';
import 'package:async/async.dart';
import 'package:coverage/coverage.dart';
import 'package:flutter_tools/src/context_runner.dart';
import 'package:path/path.dart' as p;
import 'package:path/path.dart' as path;
import 'package:pedantic/pedantic.dart';
import 'package:stream_channel/isolate_channel.dart';
import 'package:stream_channel/stream_channel.dart';
......@@ -31,7 +31,7 @@ import 'package:flutter_tools/src/test/coverage_collector.dart';
///
/// Example invocation:
///
/// dart tool/tool_coverage.dart.
/// dart tool/tool_coverage.dart
Future<void> main(List<String> arguments) async {
return runInContext(() async {
final VMPlatform vmPlatform = VMPlatform();
......@@ -50,19 +50,19 @@ class VMPlatform extends PlatformPlugin {
flutterProject: FlutterProject.current(),
);
final Map<String, Future<void>> _pending = <String, Future<void>>{};
final String precompiledPath = p.join('.dart_tool', 'build', 'generated', 'flutter_tools');
final String precompiledPath = path.join('.dart_tool', 'build', 'generated', 'flutter_tools');
@override
StreamChannel<void> loadChannel(String path, SuitePlatform platform) =>
StreamChannel<void> loadChannel(String codePath, SuitePlatform platform) =>
throw UnimplementedError();
@override
Future<RunnerSuite> load(String path, SuitePlatform platform,
Future<RunnerSuite> load(String codePath, SuitePlatform platform,
SuiteConfiguration suiteConfig, Object message) async {
final ReceivePort receivePort = ReceivePort();
Isolate isolate;
try {
isolate = await _spawnIsolate(path, receivePort.sendPort);
isolate = await _spawnIsolate(codePath, receivePort.sendPort);
} catch (error) {
receivePort.close();
rethrow;
......@@ -71,7 +71,7 @@ class VMPlatform extends PlatformPlugin {
// When this is completed we remove it from the map of pending so we can
// log the futures that get "stuck".
unawaited(completer.future.whenComplete(() {
_pending.remove(path);
_pending.remove(codePath);
}));
final ServiceProtocolInfo info = await Service.controlWebServer(enable: true);
final dynamic channel = IsolateChannel<Object>.connectReceive(receivePort)
......@@ -94,14 +94,14 @@ class VMPlatform extends PlatformPlugin {
VMEnvironment environment;
final RunnerSuiteController controller = deserializeSuite(
path,
codePath,
platform,
suiteConfig,
environment,
channel,
message,
);
_pending[path] = completer.future;
_pending[codePath] = completer.future;
return await controller.suite;
}
......@@ -109,11 +109,11 @@ class VMPlatform extends PlatformPlugin {
///
/// This isolate connects an [IsolateChannel] to [message] and sends the
/// serialized tests over that channel.
Future<Isolate> _spawnIsolate(String path, SendPort message) async {
String testPath = p.absolute(p.join(precompiledPath, path) + '.vm_test.dart');
Future<Isolate> _spawnIsolate(String codePath, SendPort message) async {
String testPath = path.absolute(path.join(precompiledPath, codePath) + '.vm_test.dart');
testPath = testPath.substring(0, testPath.length - '.dart'.length) + '.vm.app.dill';
return await Isolate.spawnUri(p.toUri(testPath), <String>[], message,
packageConfig: p.toUri('.packages'),
return await Isolate.spawnUri(path.toUri(testPath), <String>[], message,
packageConfig: path.toUri('.packages'),
checked: true,
);
}
......@@ -126,8 +126,8 @@ class VMPlatform extends PlatformPlugin {
// TODO(jonahwilliams): resolve whether there are any specific tests that
// get stuck or if it is a general infra issue with how we are collecting
// coverage.
// Log tests that are "Stuck" waiuting for coverage.
print('The folllowing tests timed out waiting for coverage:');
// Log tests that are "Stuck" waiting for coverage.
print('The following tests timed out waiting for coverage:');
print(_pending.keys.join(', '));
}
final String packagePath = Directory.current.path;
......@@ -139,7 +139,7 @@ class VMPlatform extends PlatformPlugin {
formatter: formatter,
);
final String prefix = Platform.environment['SUBSHARD'] ?? '';
final String outputLcovPath = p.join('coverage', '$prefix.lcov.info');
final String outputLcovPath = path.join('coverage', '$prefix.lcov.info');
File(outputLcovPath)
..createSync(recursive: true)
..writeAsStringSync(result);
......
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