diff --git a/extras/tooling/bin/coverage.dart b/extras/tooling/bin/coverage.dart deleted file mode 100644 index ff8c1011..00000000 --- a/extras/tooling/bin/coverage.dart +++ /dev/null @@ -1,72 +0,0 @@ -// Adapted from https://github.com/dart-lang/coverage/blob/master/bin/format_coverage.dart -// because that file doesn't work with the output of the test package. - -// Copyright (c) 2013, 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 'package:coverage/coverage.dart'; -import 'package:path/path.dart' as p; - -// ignore_for_file: avoid_print - -final File outputFile = File('lcov.info'); - -Future main() async { - if (outputFile.existsSync()) { - outputFile.deleteSync(); - } - - await runForProject('moor'); - await runForProject('sqlparser'); -} - -Future runForProject(String projectName) async { - final files = filesToProcess(projectName); - print('$projectName: Collecting across ${files.length} files'); - - final hitmap = await parseCoverage(files, 1); - - final resolver = MoorResolver( - projectRoot: projectName, - packagesPath: p.join(projectName, '.dart_tool', 'package_config.json')); - - final output = - await LcovFormatter(resolver, reportOn: [p.join(projectName, 'lib')]) - .format(hitmap); - - await outputFile.writeAsString(output, mode: FileMode.append); -} - -List filesToProcess(String moorSubproject) { - final filePattern = RegExp(r'^.*\.json$'); - final coverageOutput = p.join(moorSubproject, 'coverage', 'test'); - - if (FileSystemEntity.isDirectorySync(coverageOutput)) { - return Directory(coverageOutput) - .listSync(recursive: true) - .whereType() - .where((e) => filePattern.hasMatch(p.basename(e.path))) - .toList(); - } - throw AssertionError('Moor subproject at $moorSubproject does not exist'); -} - -class MoorResolver extends Resolver { - final String? projectRoot; - - MoorResolver({this.projectRoot, String? packagesPath}) - : super(packagesPath: packagesPath); - - @override - String? resolveSymbolicLinks(String path) { - if (p.isAbsolute(path)) { - return super.resolveSymbolicLinks(path); - } else { - return super.resolveSymbolicLinks(p.join(projectRoot!, path)); - } - } -} diff --git a/extras/tooling/pubspec.yaml b/extras/tooling/pubspec.yaml index 9d62ee48..d3db18c8 100644 --- a/extras/tooling/pubspec.yaml +++ b/extras/tooling/pubspec.yaml @@ -7,5 +7,4 @@ environment: dependencies: analyzer: ^2.5.0 - coverage: ^1.0.2 path: ^1.8.0