mirror of https://github.com/AMT-Cheif/drift.git
Use package:test_coverage for moor subproject
This commit is contained in:
parent
234a96cd5e
commit
5a0c0d9212
|
@ -31,6 +31,10 @@ doc/api/
|
|||
android/
|
||||
ios/
|
||||
|
||||
# coverage
|
||||
test/.test_coverage.dart
|
||||
coverage_badge.svg
|
||||
|
||||
### Intellij ###
|
||||
.idea/**/*
|
||||
# End of https://www.gitignore.io/api/dart,intellij
|
||||
|
|
|
@ -22,16 +22,13 @@ dev_dependencies:
|
|||
build_runner: '>=1.3.0 <2.0.0'
|
||||
build_test: ^0.10.8
|
||||
test: ^1.6.4
|
||||
test_core: '>=0.2.0 <1.0.0'
|
||||
mockito: ^4.1.0
|
||||
grinder: ^0.8.3
|
||||
coverage: ^0.12.4
|
||||
coverage: any # will be determined by test_coverage
|
||||
test_coverage: ^0.3.0
|
||||
|
||||
dependency_overrides:
|
||||
moor_generator:
|
||||
path: ../moor_generator
|
||||
sqlparser:
|
||||
path: ../sqlparser
|
||||
# Temporarily use my fork because it can collect coverage when running tests with the test runner
|
||||
coverage:
|
||||
git: https://github.com/simolus3/coverage.git
|
||||
path: ../sqlparser
|
|
@ -1,18 +0,0 @@
|
|||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:grinder/grinder_sdk.dart';
|
||||
import 'package:coverage/coverage.dart';
|
||||
import 'package:path/path.dart';
|
||||
|
||||
Future<void> main(List<String> args) async {
|
||||
Pub.run('build_runner', arguments: ['build', '--delete-conflicting-outputs']);
|
||||
|
||||
// Next, run the test script in another dart process that has the vm services
|
||||
// enabled.
|
||||
final tests = join(File.fromUri(Platform.script).parent.path, 'tester.dart');
|
||||
final coverage = await runAndCollect(tests, onExit: true, printOutput: true);
|
||||
|
||||
File('coverage.json').writeAsStringSync(json.encode(coverage));
|
||||
}
|
|
@ -5,22 +5,27 @@ import 'package:coverage/coverage.dart';
|
|||
// note that this script will be run from the parent directory (the root of the
|
||||
// moor repo)
|
||||
Future main() async {
|
||||
final resolver = Resolver(packagesPath: 'moor/.packages');
|
||||
// the lcov file generated by test_coverage has wrong file paths
|
||||
final moorLcov = File('moor/coverage/lcov.info').readAsLinesSync();
|
||||
final moorWithFixesPaths = moorLcov.map((line) {
|
||||
if (line.startsWith('SF:')) {
|
||||
final path = line.split(':')[1];
|
||||
return 'SF:moor/$path';
|
||||
} else {
|
||||
return line;
|
||||
}
|
||||
}).toList();
|
||||
|
||||
final coverage = await parseCoverage([
|
||||
File('moor/coverage.json'),
|
||||
File('sqlparser/coverage.json'),
|
||||
], 1);
|
||||
final sqlCoverage = await parseCoverage([File('sqlparser/coverage.json')], 1);
|
||||
final resolver = Resolver(packagesPath: 'sqlparser/.packages');
|
||||
|
||||
// report coverage for the moor and moor_generator package
|
||||
final lcov = await LcovFormatter(
|
||||
resolver,
|
||||
reportOn: [
|
||||
'moor/lib/',
|
||||
'sqlparser/lib',
|
||||
],
|
||||
reportOn: ['sqlparser/lib'],
|
||||
basePath: '.',
|
||||
).format(coverage);
|
||||
).format(sqlCoverage);
|
||||
|
||||
File('lcov.info').writeAsStringSync(lcov);
|
||||
final output = moorWithFixesPaths.join('\n') + lcov;
|
||||
File('lcov.info').writeAsStringSync(output);
|
||||
}
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
import 'package:test_core/src/executable.dart' as test;
|
||||
|
||||
void main() async {
|
||||
print('inside test file');
|
||||
// Run tests
|
||||
await test.main([]);
|
||||
print('done, script should terminate after coverage is collected');
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
cd moor
|
||||
dart tool/coverage.dart
|
||||
#pub run build_runner test --delete-conflicting-outputs
|
||||
pub run build_runner test --delete-conflicting-outputs
|
||||
pub run test_coverage --no-badge
|
Loading…
Reference in New Issue