Merge coverage check into regular unit test check

Fixes #2542
This commit is contained in:
Daniel Imms
2019-11-06 11:04:37 -08:00
parent d4dbdac73f
commit d079775690
3 changed files with 24 additions and 15 deletions
+3 -14
View File
@@ -25,26 +25,15 @@ jobs:
displayName: Cache node modules
- script: yarn --frozen-lockfile
displayName: 'Install dependencies and build'
- script: yarn test-unit --forbid-only
- script: yarn test-coverage --forbid-only
displayName: 'Unit tests'
- script: yarn lint
displayName: 'Lint'
- script: |
NODE_PATH=$(pwd)/out ./node_modules/.bin/nyc ./node_modules/.bin/mocha './out/*test.js' './out/**/*test.js'
./node_modules/.bin/nyc report --reporter=cobertura
displayName: 'Coverage report'
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/*coverage.xml'
displayName: 'Publish coverage'
- task: mspremier.BuildQualityChecks.QualityChecks-task.BuildQualityChecks@6
displayName: 'Check build quality'
inputs:
checkCoverage: true
coverageType: lines
coverageThreshold: 60
coverageFailOption: fixed
- job: macOS
pool:
@@ -63,7 +52,7 @@ jobs:
displayName: Cache node modules
- script: yarn --frozen-lockfile
displayName: 'Install dependencies and build'
- script: yarn test-unit --forbid-only
- script: yarn test-coverage --forbid-only
displayName: 'Unit tests'
- script: yarn lint
displayName: 'Lint'
@@ -85,7 +74,7 @@ jobs:
displayName: Cache node modules
- script: yarn --frozen-lockfile
displayName: 'Install dependencies and build'
- script: yarn test-unit --forbid-only
- script: yarn test-coverage --forbid-only
displayName: 'Unit tests'
- script: yarn lint
displayName: 'Lint'
+20 -1
View File
@@ -28,6 +28,26 @@ if (process.argv.length > 2) {
}
}
const checkCoverage = flagArgs.indexOf('--coverage') >= 0;
if (checkCoverage) {
flagArgs.splice(flagArgs.indexOf('--coverage'), 1);
const executable = path.resolve(__dirname, '../node_modules/.bin/nyc');
const args = ['--check-coverage', '--lines=100', path.resolve(__dirname, '../node_modules/.bin/mocha'), ...testFiles, ...flagArgs];
console.info('executable', executable);
console.info('args', args);
const run = cp.spawnSync(
executable,
args,
{
cwd: path.resolve(__dirname, '..'),
env,
stdio: 'inherit'
}
);
process.exit(run.status);
}
const run = cp.spawnSync(
path.resolve(__dirname, '../node_modules/.bin/mocha'),
[...testFiles, ...flagArgs],
@@ -37,5 +57,4 @@ const run = cp.spawnSync(
stdio: 'inherit'
}
);
process.exit(run.status);
+1
View File
@@ -16,6 +16,7 @@
"posttest": "npm run lint",
"test-api": "mocha \"**/*.api.js\"",
"test-unit": "node ./bin/test.js",
"test-coverage": "node ./bin/test.js --coverage",
"build": "tsc -b ./tsconfig.all.json",
"prepare": "npm run setup",
"setup": "npm run build",