diff --git a/CHANGELOG.md b/CHANGELOG.md index b2fb3cda..cceba100 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +## 1.7.2-wip + ## 1.7.1 - Update `package:vm_service` constraints to '>=12.0.0 <14.0.0'. diff --git a/analysis_options.yaml b/analysis_options.yaml index 95df488b..1d9542ad 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,4 +1,4 @@ -include: package:lints/recommended.yaml +include: package:dart_flutter_team_lints/analysis_options.yaml analyzer: language: diff --git a/benchmark/many_isolates.dart b/benchmark/many_isolates.dart index f0b3c043..185576a3 100644 --- a/benchmark/many_isolates.dart +++ b/benchmark/many_isolates.dart @@ -10,8 +10,8 @@ Future main(List args, dynamic message) async { // If there is no message, it means this instance was created by // run_benchmarks.dart. In that case, this is the parent instance that // spawns all the others. - int sum = 0; - for (int i = 0; i < 10; ++i) { + var sum = 0; + for (var i = 0; i < 10; ++i) { final port = ReceivePort(); final isolate = Isolate.spawnUri(Uri.file('many_isolates.dart'), [], port.sendPort); diff --git a/benchmark/run_benchmarks.dart b/benchmark/run_benchmarks.dart index 4f5fd1b7..1bd2990b 100644 --- a/benchmark/run_benchmarks.dart +++ b/benchmark/run_benchmarks.dart @@ -14,12 +14,12 @@ import '../bin/format_coverage.dart' as format_coverage; class CoverageBenchmark extends AsyncBenchmarkBase { CoverageBenchmark( ScoreEmitter emitter, - String name, + super.name, this.script, { this.gatherCoverage = false, this.functionCoverage = false, this.branchCoverage = false, - }) : super(name, emitter: emitter); + }) : super(emitter: emitter); final String script; final bool gatherCoverage; @@ -102,9 +102,9 @@ class JsonEmitter implements ScoreEmitter { } Future runBenchmark(CoverageBenchmark benchmark) async { - for (int i = 0; i < 3; ++i) { + for (var i = 0; i < 3; ++i) { try { - await benchmark.report().timeout(Duration(minutes: 2)); + await benchmark.report().timeout(const Duration(minutes: 2)); return; } on TimeoutException { print('Timed out'); diff --git a/lib/src/chrome.dart b/lib/src/chrome.dart index 8d32fa93..88ec1b32 100644 --- a/lib/src/chrome.dart +++ b/lib/src/chrome.dart @@ -2,9 +2,10 @@ // 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 'package:coverage/src/hitmap.dart'; import 'package:source_maps/parser.dart'; +import 'hitmap.dart'; + /// Returns a Dart based hit-map containing coverage report for the provided /// Chrome [preciseCoverage]. /// @@ -37,6 +38,7 @@ Future> parseChromeCoverage( mapping = parse(mapResponse) as SingleMapping; } on FormatException { continue; + // ignore: avoid_catching_errors } on ArgumentError { continue; } diff --git a/lib/src/collect.dart b/lib/src/collect.dart index 03bed3ce..51b56255 100644 --- a/lib/src/collect.dart +++ b/lib/src/collect.dart @@ -80,9 +80,8 @@ Future> collect(Uri serviceUri, bool resume, controller.close(); service.dispose(); }); - service = VmService( - controller.stream, (String message) => socket.add(message), - log: StdoutLog(), disposeHandler: () => socket.close()); + service = VmService(controller.stream, socket.add, + log: StdoutLog(), disposeHandler: socket.close); await service.getVM().timeout(_retryInterval); } on TimeoutException { // The signature changed in vm_service version 6.0.0. @@ -269,11 +268,11 @@ Future _waitIsolatesPaused(VmService service, {Duration? timeout}) async { Future allPaused() async { final vm = await service.getVM(); - if (vm.isolates!.isEmpty) throw 'No isolates.'; + if (vm.isolates!.isEmpty) throw StateError('No isolates.'); for (var isolateRef in vm.isolates!) { final isolate = await service.getIsolate(isolateRef.id!); if (!pauseEvents.contains(isolate.pauseEvent!.kind)) { - throw 'Unpaused isolates remaining.'; + throw StateError('Unpaused isolates remaining.'); } } } @@ -330,8 +329,7 @@ Future>> _processSourceReport( return scripts[scriptRef]; } - HitMap getHitMap(Uri scriptUri) => - hitMaps.putIfAbsent(scriptUri, () => HitMap()); + HitMap getHitMap(Uri scriptUri) => hitMaps.putIfAbsent(scriptUri, HitMap.new); Future processFunction(FuncRef funcRef) async { final func = await service.getObject(isolateRef.id!, funcRef.id!) as Func; diff --git a/lib/src/formatter.dart b/lib/src/formatter.dart index 318bd5d2..a7a96c1d 100644 --- a/lib/src/formatter.dart +++ b/lib/src/formatter.dart @@ -4,8 +4,8 @@ import 'package:path/path.dart' as p; -import 'resolver.dart'; import 'hitmap.dart'; +import 'resolver.dart'; @Deprecated('Migrate to FileHitMapsFormatter') abstract class Formatter { @@ -144,14 +144,17 @@ extension FileHitMapsFormatter on Map { for (final entry in entries) { final v = entry.value; if (reportFuncs && v.funcHits == null) { - throw 'Function coverage formatting was requested, but the hit map is ' - 'missing function coverage information. Did you run ' - 'collect_coverage with the --function-coverage flag?'; + throw StateError( + 'Function coverage formatting was requested, but the hit map is ' + 'missing function coverage information. Did you run ' + 'collect_coverage with the --function-coverage flag?', + ); } if (reportBranches && v.branchHits == null) { - throw 'Branch coverage formatting was requested, but the hit map is ' + throw StateError( + 'Branch coverage formatting was requested, but the hit map is ' 'missing branch coverage information. Did you run ' - 'collect_coverage with the --branch-coverage flag?'; + 'collect_coverage with the --branch-coverage flag?'); } final hits = reportFuncs ? v.funcHits! diff --git a/lib/src/hitmap.dart b/lib/src/hitmap.dart index 9a8cca66..4c3b4688 100644 --- a/lib/src/hitmap.dart +++ b/lib/src/hitmap.dart @@ -5,8 +5,8 @@ import 'dart:convert' show json; import 'dart:io'; -import 'package:coverage/src/resolver.dart'; -import 'package:coverage/src/util.dart'; +import 'resolver.dart'; +import 'util.dart'; /// Contains line and function hit information for a single script. class HitMap { @@ -66,7 +66,7 @@ class HitMap { if (checkIgnoredLines) { if (ignoredLinesInFilesCache.containsKey(source)) { - final List>? cacheHit = ignoredLinesInFilesCache[source]; + final cacheHit = ignoredLinesInFilesCache[source]; if (cacheHit == null) { // Null-entry indicates that the whole file was ignored. continue; @@ -157,7 +157,7 @@ class HitMap { } } - final sourceHitMap = globalHitMap.putIfAbsent(source, () => HitMap()); + final sourceHitMap = globalHitMap.putIfAbsent(source, HitMap.new); fillHitMap(e['hits'] as List, sourceHitMap.lineHits); if (e.containsKey('funcHits')) { sourceHitMap.funcHits ??= {}; @@ -188,7 +188,7 @@ class HitMap { @Deprecated('Use packagePath') String? packagesPath, String? packagePath, }) async { - final Resolver resolver = await Resolver.create( + final resolver = await Resolver.create( packagesPath: packagesPath, packagePath: packagePath); return parseJsonSync(jsonResult, checkIgnoredLines: checkIgnoredLines, @@ -375,7 +375,7 @@ List _sortHits(List hits) { final lineOrLineRange = hits[i]; final firstLineInRange = lineOrLineRange is int ? lineOrLineRange - : int.parse(lineOrLineRange.split('-')[0] as String); + : int.parse((lineOrLineRange as String).split('-')[0]); structuredHits.add(_HitInfo(firstLineInRange, hits[i], hits[i + 1] as int)); } structuredHits.sort((a, b) => a.firstLine.compareTo(b.firstLine)); diff --git a/lib/src/resolver.dart b/lib/src/resolver.dart index d2e799ca..cb5b7288 100644 --- a/lib/src/resolver.dart +++ b/lib/src/resolver.dart @@ -205,7 +205,8 @@ class Loader { /// Returns `null` if the resource could not be loaded. List? loadSync(String path) { try { - // Ensure `readAsLinesSync` runs within the try block so errors are caught. + // Ensure `readAsLinesSync` runs within the try block so errors are + // caught. return File(path).readAsLinesSync(); } catch (_) { failed.add(path); diff --git a/lib/src/run_and_collect.dart b/lib/src/run_and_collect.dart index 1bd57908..f2a9cbc4 100644 --- a/lib/src/run_and_collect.dart +++ b/lib/src/run_and_collect.dart @@ -35,7 +35,7 @@ Future> runAndCollect(String scriptPath, timeout: timeout, ); } finally { - await process.stderr.drain(); + await process.stderr.drain(); } final exitStatus = await process.exitCode; if (exitStatus != 0) { diff --git a/lib/src/util.dart b/lib/src/util.dart index acbeeab7..7ffe7472 100644 --- a/lib/src/util.dart +++ b/lib/src/util.dart @@ -80,7 +80,8 @@ final singleLineIgnore = RegExp(r'//\s*coverage:ignore-line[\w\d\s]*$'); final ignoreFile = RegExp(r'//\s*coverage:ignore-file[\w\d\s]*$'); /// Return list containing inclusive range of lines to be ignored by coverage. -/// If there is a error in balancing the statements it will throw a FormatException, +/// If there is a error in balancing the statements it will throw a +/// [FormatException], /// unless `coverage:ignore-file` is found. /// Return [0, lines.length] if the whole file is ignored. /// @@ -162,7 +163,7 @@ List> getIgnoredLines(String filePath, List? lines) { extension StandardOutExtension on Stream> { Stream lines() => - transform(SystemEncoding().decoder).transform(const LineSplitter()); + transform(const SystemEncoding().decoder).transform(const LineSplitter()); } Future serviceUriFromProcess(Stream procStdout) { diff --git a/pubspec.yaml b/pubspec.yaml index 16e851b2..0a92b4b0 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,10 +1,10 @@ name: coverage -version: 1.7.1 +version: 1.7.2-wip description: Coverage data manipulation and formatting repository: https://github.com/dart-lang/coverage environment: - sdk: '^3.0.0' + sdk: ^3.0.0 dependencies: args: ^2.0.0 @@ -18,7 +18,7 @@ dependencies: dev_dependencies: benchmark_harness: ^2.2.0 build_runner: ^2.1.10 - lints: ^2.0.0 + dart_flutter_team_lints: ^2.0.0 mockito: ^5.3.2 test: ^1.16.0 test_descriptor: ^2.0.0 diff --git a/test/chrome_test.dart b/test/chrome_test.dart index c6fae942..165692fd 100644 --- a/test/chrome_test.dart +++ b/test/chrome_test.dart @@ -4,6 +4,7 @@ // TODO(#388): Fix and re-enable this test. @TestOn('!windows') +library; import 'dart:convert'; import 'dart:io'; @@ -42,9 +43,11 @@ void main() { sourceUriProvider, ); - final sourceReport = report['coverage'].firstWhere( - (Map report) => - report['source'].toString().contains('main_test.dart')); + final sourceReport = + (report['coverage'] as List>).firstWhere( + (Map report) => + report['source'].toString().contains('main_test.dart'), + ); final expectedHits = { 7: 1, diff --git a/test/collect_coverage_api_test.dart b/test/collect_coverage_api_test.dart index e41f5c14..fd3de439 100644 --- a/test/collect_coverage_api_test.dart +++ b/test/collect_coverage_api_test.dart @@ -94,7 +94,7 @@ void main() { everyElement(containsPair('branchHits', isNotEmpty))); expect(sources[_isolateLibFileUri], everyElement(containsPair('branchHits', isNotEmpty))); - }, skip: !platformVersionCheck(2, 17)); + }); test('collect_coverage_api with coverableLineCache', () async { final coverableLineCache = >{}; diff --git a/test/collect_coverage_test.dart b/test/collect_coverage_test.dart index e69bdf63..3c61ee5b 100644 --- a/test/collect_coverage_test.dart +++ b/test/collect_coverage_test.dart @@ -3,6 +3,8 @@ // BSD-style license that can be found in the LICENSE file. @Retry(3) +library; + import 'dart:async'; import 'dart:convert' show json; import 'dart:io'; @@ -158,19 +160,11 @@ void main() { 28: 'fooAsync', 38: 'isolateTask' }); - expect(isolateFile?.branchHits, { - 11: 1, - 12: 1, - 15: 0, - 19: 1, - 23: 1, - 28: 1, - if (platformVersionCheck(2, 18)) 29: 1, - 32: 0, - 38: 1, - 42: 1 - }); - }, skip: !platformVersionCheck(2, 17)); + expect( + isolateFile?.branchHits, + {11: 1, 12: 1, 15: 0, 19: 1, 23: 1, 28: 1, 29: 1, 32: 0, 38: 1, 42: 1}, + ); + }); test('HitMap.parseJson, old VM without branch coverage', () async { final resultString = await _collectCoverage(true, true); @@ -225,7 +219,7 @@ void main() { 28: 'fooAsync', 38: 'isolateTask' }); - }, skip: platformVersionCheck(2, 17)); + }); test('parseCoverage', () async { final tempDir = await Directory.systemTemp.createTemp('coverage.test.'); @@ -286,49 +280,49 @@ void main() { test('mergeHitmaps', () { final resultMap = >{ - "foo.dart": {10: 2, 20: 0}, - "bar.dart": {10: 3, 20: 1, 30: 0}, + 'foo.dart': {10: 2, 20: 0}, + 'bar.dart': {10: 3, 20: 1, 30: 0}, }; final newMap = >{ - "bar.dart": {10: 2, 20: 0, 40: 3}, - "baz.dart": {10: 1, 20: 0, 30: 1}, + 'bar.dart': {10: 2, 20: 0, 40: 3}, + 'baz.dart': {10: 1, 20: 0, 30: 1}, }; // ignore: deprecated_member_use_from_same_package mergeHitmaps(newMap, resultMap); expect(resultMap, >{ - "foo.dart": {10: 2, 20: 0}, - "bar.dart": {10: 5, 20: 1, 30: 0, 40: 3}, - "baz.dart": {10: 1, 20: 0, 30: 1}, + 'foo.dart': {10: 2, 20: 0}, + 'bar.dart': {10: 5, 20: 1, 30: 0, 40: 3}, + 'baz.dart': {10: 1, 20: 0, 30: 1}, }); }); test('FileHitMaps.merge', () { final resultMap = { - "foo.dart": - HitMap({10: 2, 20: 0}, {15: 0, 25: 1}, {15: "bobble", 25: "cobble"}), - "bar.dart": HitMap( - {10: 3, 20: 1, 30: 0}, {15: 5, 25: 0}, {15: "gobble", 25: "wobble"}), + 'foo.dart': + HitMap({10: 2, 20: 0}, {15: 0, 25: 1}, {15: 'bobble', 25: 'cobble'}), + 'bar.dart': HitMap( + {10: 3, 20: 1, 30: 0}, {15: 5, 25: 0}, {15: 'gobble', 25: 'wobble'}), }; final newMap = { - "bar.dart": HitMap( - {10: 2, 20: 0, 40: 3}, {15: 1, 35: 4}, {15: "gobble", 35: "dobble"}), - "baz.dart": HitMap( - {10: 1, 20: 0, 30: 1}, {15: 0, 25: 2}, {15: "lobble", 25: "zobble"}), + 'bar.dart': HitMap( + {10: 2, 20: 0, 40: 3}, {15: 1, 35: 4}, {15: 'gobble', 35: 'dobble'}), + 'baz.dart': HitMap( + {10: 1, 20: 0, 30: 1}, {15: 0, 25: 2}, {15: 'lobble', 25: 'zobble'}), }; resultMap.merge(newMap); - expect(resultMap["foo.dart"]?.lineHits, {10: 2, 20: 0}); - expect(resultMap["foo.dart"]?.funcHits, {15: 0, 25: 1}); - expect(resultMap["foo.dart"]?.funcNames, - {15: "bobble", 25: "cobble"}); - expect(resultMap["bar.dart"]?.lineHits, + expect(resultMap['foo.dart']?.lineHits, {10: 2, 20: 0}); + expect(resultMap['foo.dart']?.funcHits, {15: 0, 25: 1}); + expect(resultMap['foo.dart']?.funcNames, + {15: 'bobble', 25: 'cobble'}); + expect(resultMap['bar.dart']?.lineHits, {10: 5, 20: 1, 30: 0, 40: 3}); - expect(resultMap["bar.dart"]?.funcHits, {15: 6, 25: 0, 35: 4}); - expect(resultMap["bar.dart"]?.funcNames, - {15: "gobble", 25: "wobble", 35: "dobble"}); - expect(resultMap["baz.dart"]?.lineHits, {10: 1, 20: 0, 30: 1}); - expect(resultMap["baz.dart"]?.funcHits, {15: 0, 25: 2}); - expect(resultMap["baz.dart"]?.funcNames, - {15: "lobble", 25: "zobble"}); + expect(resultMap['bar.dart']?.funcHits, {15: 6, 25: 0, 35: 4}); + expect(resultMap['bar.dart']?.funcNames, + {15: 'gobble', 25: 'wobble', 35: 'dobble'}); + expect(resultMap['baz.dart']?.lineHits, {10: 1, 20: 0, 30: 1}); + expect(resultMap['baz.dart']?.funcHits, {15: 0, 25: 2}); + expect(resultMap['baz.dart']?.funcNames, + {15: 'lobble', 25: 'zobble'}); }); } @@ -363,7 +357,8 @@ Future _collectCoverage( await toolResult.shouldExit(0).timeout( timeout, - onTimeout: () => throw 'We timed out waiting for the tool to finish.', + onTimeout: () => + throw StateError('We timed out waiting for the tool to finish.'), ); await sampleProcess.shouldExit(); diff --git a/test/function_coverage_test.dart b/test/function_coverage_test.dart index cfae1cc8..58e84974 100644 --- a/test/function_coverage_test.dart +++ b/test/function_coverage_test.dart @@ -32,7 +32,6 @@ void main() { final isolateFile = hitMap[_sampleAppFileUri]!; expect(isolateFile.funcHits, { 7: 1, - if (!platformVersionCheck(2, 19)) 12: 0, 16: 1, 21: 1, 25: 1, @@ -43,7 +42,6 @@ void main() { }); expect(isolateFile.funcNames, { 7: 'normalFunction', - if (!platformVersionCheck(2, 19)) 12: 'BaseClass.abstractMethod', 16: 'SomeClass.SomeClass', 21: 'SomeClass.normalMethod', 25: 'SomeClass.staticMethod', @@ -99,7 +97,8 @@ Future _collectCoverage() async { await toolResult.shouldExit(0).timeout( timeout, - onTimeout: () => throw 'We timed out waiting for the tool to finish.', + onTimeout: () => + throw StateError('We timed out waiting for the tool to finish.'), ); await sampleProcess.shouldExit(); diff --git a/test/lcov_test.dart b/test/lcov_test.dart index 59ff38c4..d2af9f99 100644 --- a/test/lcov_test.dart +++ b/test/lcov_test.dart @@ -11,8 +11,6 @@ import 'package:path/path.dart' as p; import 'package:test/test.dart'; import 'package:test_process/test_process.dart'; -import 'test_util.dart'; - final _sampleAppPath = p.join('test', 'test_files', 'test_app.dart'); final _isolateLibPath = p.join('test', 'test_files', 'test_app_isolate.dart'); @@ -47,7 +45,7 @@ void main() { reason: 'be careful if you modify the test file'); expect(sampleAppBranchHits, containsPair(41, 1), reason: 'be careful if you modify the test file'); - }, skip: !platformVersionCheck(2, 17)); + }); test('validate hitMap, old VM without branch coverage', () async { final hitmap = await _getHitMap(); @@ -73,7 +71,7 @@ void main() { reason: 'be careful if you modify the test file'); expect(sampleAppFuncNames, containsPair(45, 'usedMethod'), reason: 'be careful if you modify the test file'); - }, skip: platformVersionCheck(2, 17)); + }); group('LcovFormatter', () { test('format()', () async { @@ -244,7 +242,7 @@ void main() { expect(res, contains(' 1| if (x == answer) {')); expect(res, contains(' 0| while (i < lines.length) {')); expect(res, contains(' | bar.baz();')); - }, skip: !platformVersionCheck(2, 17)); + }); }); } @@ -258,8 +256,7 @@ Future> _getHitMap() async { final sampleAppArgs = [ '--pause-isolates-on-exit', '--enable-vm-service=$port', - // Dart VM versions before 2.17 don't support branch coverage. - if (platformVersionCheck(2, 17)) '--branch-coverage', + '--branch-coverage', _sampleAppPath ]; final sampleProcess = diff --git a/test/resolver_test.dart b/test/resolver_test.dart index f34e694c..1161aee4 100644 --- a/test/resolver_test.dart +++ b/test/resolver_test.dart @@ -10,7 +10,7 @@ import 'package:test_descriptor/test_descriptor.dart' as d; void main() { group('Default Resolver', () { setUp(() async { - final String sandboxUriPath = p.toUri(d.sandbox).toString(); + final sandboxUriPath = p.toUri(d.sandbox).toString(); await d.dir('bar', [ d.dir('lib', [ d.file('bar.dart', 'final fizz = "bar";'), diff --git a/test/run_and_collect_test.dart b/test/run_and_collect_test.dart index 8a5a63eb..e21e353e 100644 --- a/test/run_and_collect_test.dart +++ b/test/run_and_collect_test.dart @@ -31,8 +31,8 @@ void main() { final hitMap = await HitMap.parseJson(coverage, checkIgnoredLines: true); checkHitmap(hitMap); - final Resolver resolver = await Resolver.create(); - final Map>?> ignoredLinesInFilesCache = {}; + final resolver = await Resolver.create(); + final ignoredLinesInFilesCache = >?>{}; final hitMap2 = HitMap.parseJsonSync(coverage, checkIgnoredLines: true, ignoredLinesInFilesCache: ignoredLinesInFilesCache, @@ -74,12 +74,12 @@ class ThrowingResolver implements Resolver { void checkIgnoredLinesInFilesCache( Map>?> ignoredLinesInFilesCache) { expect(ignoredLinesInFilesCache.length, 3); - final List keys = ignoredLinesInFilesCache.keys.toList(); - final String testAppKey = + final keys = ignoredLinesInFilesCache.keys.toList(); + final testAppKey = keys.where((element) => element.endsWith('test_app.dart')).single; - final String testAppIsolateKey = + final testAppIsolateKey = keys.where((element) => element.endsWith('test_app_isolate.dart')).single; - final String packageUtilKey = keys + final packageUtilKey = keys .where((element) => element.endsWith('package:coverage/src/util.dart')) .single; expect(ignoredLinesInFilesCache[packageUtilKey], isEmpty); diff --git a/test/test_files/function_coverage_app.dart b/test/test_files/function_coverage_app.dart index e3ffe096..c4868f9b 100644 --- a/test/test_files/function_coverage_app.dart +++ b/test/test_files/function_coverage_app.dart @@ -54,3 +54,5 @@ void main() { print(libraryFunction()); print(otherLibraryFunction()); } + +// ignore_for_file: unreachable_from_main diff --git a/test/test_files/test_app.dart b/test/test_files/test_app.dart index e0fee21d..231486a8 100644 --- a/test/test_files/test_app.dart +++ b/test/test_files/test_app.dart @@ -49,3 +49,6 @@ int usedMethod(int a, int b) { int unusedMethod(int a, int b) { return a - b; } + +// ignore_for_file: unreachable_from_main, only_throw_errors +// ignore_for_file: deprecated_member_use diff --git a/test/test_files/test_app_isolate.dart b/test/test_files/test_app_isolate.dart index 5fbf6e12..e7ade553 100644 --- a/test/test_files/test_app_isolate.dart +++ b/test/test_files/test_app_isolate.dart @@ -35,13 +35,13 @@ Future fooAsync(int x) async { /// The number of covered lines is tested and expected to be 4. /// /// If you modify this method, you may have to update the tests! -void isolateTask(dynamic threeThings) { +void isolateTask(List threeThings) { sleep(const Duration(milliseconds: 500)); fooSync(answer); fooAsync(answer).then((_) { final port = threeThings.first as SendPort; - final sum = (threeThings[1] + threeThings[2]) as int; + final sum = (threeThings[1] as int) + (threeThings[2] as int); port.send(sum); }); diff --git a/test/test_files/test_library_part.dart b/test/test_files/test_library_part.dart index d587ff25..c99876d0 100644 --- a/test/test_files/test_library_part.dart +++ b/test/test_files/test_library_part.dart @@ -2,7 +2,7 @@ // 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. -part of test_library; +part of 'test_library.dart'; int otherLibraryFunction() { return 123; diff --git a/test/test_util.dart b/test/test_util.dart index b65e3af0..209dac32 100644 --- a/test/test_util.dart +++ b/test/test_util.dart @@ -18,8 +18,7 @@ Future runTestApp(int openPort) => TestProcess.start( [ '--enable-vm-service=$openPort', '--pause_isolates_on_exit', - // Dart VM versions before 2.17 don't support branch coverage. - if (platformVersionCheck(2, 17)) '--branch-coverage', + '--branch-coverage', testAppPath ], ); @@ -32,6 +31,7 @@ List> coverageDataFromJson(Map json) { } final _versionPattern = RegExp('([0-9]+)\\.([0-9]+)\\.([0-9]+)'); + bool platformVersionCheck(int minMajor, int minMinor) { final match = _versionPattern.matchAsPrefix(Platform.version); if (match == null) return false; diff --git a/test/test_with_coverage_test.dart b/test/test_with_coverage_test.dart index ccde4016..689452d2 100644 --- a/test/test_with_coverage_test.dart +++ b/test/test_with_coverage_test.dart @@ -3,6 +3,7 @@ // BSD-style license that can be found in the LICENSE file. @Timeout(Duration(seconds: 60)) +library; import 'dart:convert'; import 'dart:io'; diff --git a/test/util_test.dart b/test/util_test.dart index b6806b40..6a4e5564 100644 --- a/test/util_test.dart +++ b/test/util_test.dart @@ -2,6 +2,8 @@ // 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. +// ignore_for_file: only_throw_errors + import 'dart:async'; import 'package:coverage/src/util.dart'; @@ -80,6 +82,7 @@ void main() { try { await retry(failCountTimes, _delay, timeout: unsafeTimeoutDuration); + // ignore: avoid_catching_errors } on StateError catch (e) { expect(e.message, 'Failed to complete within 25ms'); caught = true; @@ -193,11 +196,13 @@ void main() { runTest( 0, - 'coverage:ignore-start found at content-0.dart:3 before previous coverage:ignore-start ended', + 'coverage:ignore-start found at content-0.dart:' + '3 before previous coverage:ignore-start ended', ); runTest( 1, - 'coverage:ignore-start found at content-1.dart:3 before previous coverage:ignore-start ended', + 'coverage:ignore-start found at content-1.dart:' + '3 before previous coverage:ignore-start ended', ); runTest( 2, @@ -221,7 +226,8 @@ void main() { ); runTest( 7, - 'coverage:ignore-start found at content-7.dart:1 has no matching coverage:ignore-end', + 'coverage:ignore-start found at content-7.dart:' + '1 has no matching coverage:ignore-end', ); });