Test and coverage the sql parser

This commit is contained in:
Simon Binder 2019-07-28 09:49:14 +02:00
parent b4cdcf0431
commit 4c7874dd91
No known key found for this signature in database
GPG Key ID: 7891917E4147B8C0
10 changed files with 58 additions and 8 deletions

View File

@ -3,8 +3,15 @@ container:
image: "google/dart:latest"
task:
name: Analysis and Tests
pub_cache:
folder: $HOME/.pub-cache
pub_get_script: tool/pub_get.sh
analyze_script: tool/analyze.sh
test_moor_script: tool/test_moor.sh
test_moor_script: tool/test_moor.sh
test_sqlparser_script: tool/test_sqlparser.sh
upload_coverage_task:
name: Upload coverage
depends_on: [task]
format_coverage_task: tool/upload_coverage.sh

2
.gitignore vendored
View File

@ -1,2 +1,4 @@
**/.idea
**/*.iml
lcov.info

View File

@ -8,7 +8,7 @@ env:
- PKG="sqlparser"
script: ./tool/mono_repo_wrapper.sh
after_success: ./tool/upload_coverage.sh
#after_success: ./tool/upload_coverage.sh
cache:
directories:

View File

@ -9,7 +9,16 @@ Future main() async {
packagesPath: 'moor/.packages',
);
final coverage = await parseCoverage([File('moor/coverage.json')], 1);
final potentialFiles = [
File('moor/coverage.json'),
File('sqlparser/coverage.json'),
];
final existingFiles = [
for (var file in potentialFiles) if (file.existsSync()) file
];
final coverage = await parseCoverage(existingFiles, 1);
// report coverage for the moor and moor_generator package
final lcov = await LcovFormatter(
@ -17,9 +26,10 @@ Future main() async {
reportOn: [
'moor/lib/',
'moor_generator/lib',
'sqlparser/lib',
],
basePath: '.',
).format(coverage);
File('moor/lcov.info').writeAsStringSync(lcov);
File('lcov.info').writeAsStringSync(lcov);
}

View File

@ -9,3 +9,5 @@ build/
# Directory created by dartdoc
doc/api/
coverage.json

View File

@ -16,3 +16,7 @@ dependencies:
dev_dependencies:
test: ^1.6.0
test_core: any # version will be determined by "test"
path: ^1.6.0
coverage:
git: https://github.com/simolus3/coverage.git

View File

@ -0,0 +1,12 @@
import 'dart:convert';
import 'dart:io';
import 'package:coverage/coverage.dart';
import 'package:path/path.dart';
void main() async {
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));
}

View File

@ -0,0 +1,7 @@
import 'package:test_core/src/executable.dart' as test;
void main() async {
await test.main([]);
print('Tests ran, now collecting coverage...');
}

4
tool/test_sqlparser.sh Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env bash
cd sqlparser
dart tool/coverage.dart

View File

@ -1,6 +1,8 @@
#!/usr/bin/env bash
if [ "$PKG" == "moor" ]; then
pushd moor
bash <(curl -s https://codecov.io/bash) -f lcov.info
fi
# The formatter is in the moor directory
pushd moor
dart tool/format_coverage.dart
popd
bash <(curl -s https://codecov.io/bash) -f lcov.info