drift/moor/tool/format_coverage.dart

33 lines
1023 B
Dart

import 'dart:io';
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 {
// 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 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: ['sqlparser/lib'],
basePath: '.',
).format(sqlCoverage);
// ignore: prefer_interpolation_to_compose_strings
final output = moorWithFixesPaths.join('\n') + '\n' + lcov;
File('lcov.info').writeAsStringSync(output);
}