Support parallel tests in coverage

This commit is contained in:
Christopher C. Wells 2020-08-16 14:03:50 -07:00
parent f60c7884fe
commit 0fd8f1a3a7
2 changed files with 14 additions and 2 deletions

View File

@ -10,6 +10,9 @@ source =
core core
dashboard dashboard
reports reports
parallel = true
concurrency = multiprocessing
data_file = data/.coverage
[html] [html]
directory = htmlcov directory = htmlcov

View File

@ -34,6 +34,10 @@ function clean() {
* @param cb * @param cb
*/ */
function coverage(cb) { function coverage(cb) {
// Erase any previous coverage results.
es('pipenv run coverage erase', {stdio: 'inherit'});
// Run tests with coverage.
spawn( spawn(
'pipenv', 'pipenv',
[ [
@ -50,13 +54,18 @@ function coverage(cb) {
stdio: 'inherit' stdio: 'inherit'
} }
).on('exit', function() { ).on('exit', function() {
// Add coverage for isolated tests. // Run isolated tests with coverage.
config.testsConfig.isolated.forEach(function(test_name) { config.testsConfig.isolated.forEach(function(test_name) {
es( es(
'pipenv run coverage run -a manage.py test ' + test_name, 'pipenv run coverage run manage.py test ' + test_name,
{stdio: 'inherit'} {stdio: 'inherit'}
); );
}) })
// Combine coverage results.
es('pipenv run coverage combine', {stdio: 'inherit'});
// Execute callback.
cb(); cb();
}); });
} }