From 542fbd4c7193ccf573b683ccb949f3e1720a5398 Mon Sep 17 00:00:00 2001 From: Ian Hickson Date: Mon, 22 Jul 2019 13:02:02 -0700 Subject: [PATCH] Some minor fixes to the tool_coverage tool. (#36570) Extracted from https://github.com/flutter/flutter/pull/36205 --- .../flutter_tools/tool/tool_coverage.dart | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/packages/flutter_tools/tool/tool_coverage.dart b/packages/flutter_tools/tool/tool_coverage.dart index 53a2a6ebef..bc2cf824cb 100644 --- a/packages/flutter_tools/tool/tool_coverage.dart +++ b/packages/flutter_tools/tool/tool_coverage.dart @@ -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 main(List arguments) async { return runInContext(() async { final VMPlatform vmPlatform = VMPlatform(); @@ -50,19 +50,19 @@ class VMPlatform extends PlatformPlugin { flutterProject: FlutterProject.current(), ); final Map> _pending = >{}; - final String precompiledPath = p.join('.dart_tool', 'build', 'generated', 'flutter_tools'); + final String precompiledPath = path.join('.dart_tool', 'build', 'generated', 'flutter_tools'); @override - StreamChannel loadChannel(String path, SuitePlatform platform) => + StreamChannel loadChannel(String codePath, SuitePlatform platform) => throw UnimplementedError(); @override - Future load(String path, SuitePlatform platform, + Future 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.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 _spawnIsolate(String path, SendPort message) async { - String testPath = p.absolute(p.join(precompiledPath, path) + '.vm_test.dart'); + Future _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), [], message, - packageConfig: p.toUri('.packages'), + return await Isolate.spawnUri(path.toUri(testPath), [], 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);