Skip to content

Commit

Permalink
Switch coverage computation (#132)
Browse files Browse the repository at this point in the history
* Switch coverage computation

* Add vm-only to tests

* Add changelog

* Add empty line

* Add debug messags
  • Loading branch information
mosuem authored Jul 12, 2023
1 parent 5a9f06b commit 3f4b8d1
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 6 deletions.
2 changes: 2 additions & 0 deletions pkgs/firehose/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ build/
# Omit committing pubspec.lock for library packages; see
# https://dart.dev/guides/libraries/private-files#pubspeclock.
pubspec.lock

coverage/
3 changes: 2 additions & 1 deletion pkgs/firehose/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## 0.3.22-wip
## 0.3.22
- Add docs for the new `environment` input to the publish action.
- Add coverage for web tests.

## 0.3.21
- Allow empty coverage in PR health checks.
Expand Down
36 changes: 32 additions & 4 deletions pkgs/firehose/lib/src/health/coverage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,41 @@ Get coverage for ${package.name} by running coverage in ${package.directory.path
['pub', 'get'],
workingDirectory: package.directory.path,
);
var result = Process.runSync(
print('Get test coverage for web');
var resultChrome = Process.runSync(
'dart',
['pub', 'global', 'run', 'coverage:test_with_coverage'],
['test', '-p', 'chrome', '--coverage=coverage'],
workingDirectory: package.directory.path,
);
print(result.stdout);
print(result.stderr);
print(resultChrome.stdout);
print(resultChrome.stderr);
print('Get test coverage for vm');
var resultVm = Process.runSync(
'dart',
['test', '--coverage=coverage'],
workingDirectory: package.directory.path,
);
print(resultVm.stdout);
print(resultVm.stderr);
var resultLcov = Process.runSync(
'dart',
[
'pub',
'global',
'run',
'coverage:format_coverage',
'--lcov',
'--check-ignore',
'--report-on lib/',
'-i',
'coverage/',
'-o',
'coverage/lcov.info'
],
workingDirectory: package.directory.path,
);
print(resultLcov.stdout);
print(resultLcov.stderr);
return parseLCOV(
path.join(package.directory.path, 'coverage/lcov.info'),
relativeTo: package.repository.baseDirectory.path,
Expand Down
2 changes: 1 addition & 1 deletion pkgs/firehose/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: firehose
description: A tool to automate publishing of Pub packages from GitHub actions.
version: 0.3.22-wip
version: 0.3.22
repository: https://github.com/dart-lang/ecosystem/tree/main/pkgs/firehose

environment:
Expand Down
2 changes: 2 additions & 0 deletions pkgs/firehose/test/changelog_test.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) 2023, 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.
@TestOn('vm')
library;

import 'dart:io';

Expand Down
2 changes: 2 additions & 0 deletions pkgs/firehose/test/coverage_test.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) 2023, 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.
@TestOn('vm')
library;

import 'dart:io';

Expand Down
3 changes: 3 additions & 0 deletions pkgs/firehose/test/license_test.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) 2023, 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.
@TestOn('vm')
library;

import 'dart:io';

Expand All @@ -15,6 +17,7 @@ void main() {
await fileWithLicense.writeAsString(license);
await fileWithoutLicense.writeAsString('');
});

test('Check for licenses', () async {
var filesWithoutLicenses =
await getFilesWithoutLicenses(Directory('test/'));
Expand Down
2 changes: 2 additions & 0 deletions pkgs/firehose/test/pub_test.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) 2023, 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.
@TestOn('vm')
library;

import 'package:firehose/src/pub.dart';
import 'package:test/test.dart';
Expand Down
2 changes: 2 additions & 0 deletions pkgs/firehose/test/pubspec_test.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) 2023, 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.
@TestOn('vm')
library;

import 'dart:io';

Expand Down
2 changes: 2 additions & 0 deletions pkgs/firehose/test/repo_test.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) 2023, 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.
@TestOn('vm')
library;

import 'package:firehose/src/github.dart';
import 'package:firehose/src/repo.dart';
Expand Down

0 comments on commit 3f4b8d1

Please sign in to comment.