Add coverage reporting for JavaScript and TypeScript files

This commit is contained in:
murgatroid99 2018-05-10 11:21:25 -07:00
parent 0cf24ad004
commit 60b59c455c
4 changed files with 47 additions and 13 deletions

View File

@ -102,7 +102,7 @@ gulp.task('test.only', 'Run tests without rebuilding anything',
['js.core.test', 'native.test.only']);
gulp.task('test', 'Run all tests', (callback) => {
runSequence('build', 'test.only', callback);
runSequence('build', 'test.only', 'internal.test.test', callback);
});
gulp.task('doc.gen', 'Generate documentation', ['native.core.doc.gen']);

View File

@ -17,6 +17,7 @@
"@types/node": "^8.0.32",
"@types/pify": "^3.0.0",
"@types/semver": "^5.5.0",
"coveralls": "^3.0.1",
"del": "^3.0.0",
"execa": "^0.8.0",
"gulp": "^3.9.1",
@ -35,8 +36,11 @@
"mocha": "^3.5.3",
"mocha-jenkins-reporter": "^0.3.9",
"ncp": "^2.0.0",
"nyc": "^11.7.2",
"pify": "^3.0.0",
"run-sequence": "^2.2.0",
"semver": "^5.5.0",
"symlink": "^2.1.0",
"through2": "^2.0.3",
"ts-node": "^3.3.0",
"tslint": "^5.5.0",
@ -48,8 +52,18 @@
"name": "Google Inc."
}
],
"dependencies": {
"run-sequence": "^2.2.0",
"symlink": "^2.1.0"
"nyc": {
"include": [
"packages/grpc-health-check/health.js",
"packages/grpc-js-core/build/src/*",
"packages/grpc-native-core/index.js",
"packages/grpc-native-core/src/*.js",
"packages/grpc-protobufjs/build/src/*"
],
"cache": true
},
"scripts": {
"test": "nyc gulp test",
"coverage": "nyc report --reporter=text-lcov | coveralls"
}
}

View File

@ -39,6 +39,16 @@ npm install --unsafe-perm
mkdir -p reports
export JOBS=8
export JUNIT_REPORT_PATH="reports/node$version/"
export JUNIT_REPORT_STACK=1
gsutil cp gs://grpc-testing-secrets/coveralls_credentials/grpc-node.rc .
set +x
. grpc-node.rc
set -x
export COVERALLS_REPO_TOKEN
export COVERALLS_SERVICE_NAME=Kokoro
export COVERALLS_SERVICE_JOB_ID=$KOKORO_BUILD_ID
# TODO(mlumish): Add electron tests
@ -62,8 +72,8 @@ do
./node_modules/.bin/gulp clean.all
./node_modules/.bin/gulp setup
# Rebuild libraries and run tests.
JUNIT_REPORT_PATH="reports/node$version/" JUNIT_REPORT_STACK=1 ./node_modules/.bin/gulp test || FAILED="true"
# npm test calls nyc gulp test
npm test || FAILED="true"
done
set +ex
@ -72,7 +82,9 @@ set -ex
node merge_kokoro_logs.js
if [ "$FAILED" != "" ]
if [ "$FAILED" == "" ]
then
npm run coverage
else
exit 1
fi

View File

@ -21,6 +21,7 @@ const mocha = require('gulp-mocha');
const execa = require('execa');
const path = require('path');
const del = require('del');
const semver = require('semver');
const linkSync = require('../util').linkSync;
// gulp-help monkeypatches tasks to have an additional description parameter
@ -51,12 +52,19 @@ gulp.task('test', 'Run API-level tests', () => {
.on('end', resolve)
.on('error', reject);
});
const runTestsArgPairs = [
['native', 'native'],
['native', 'js'],
// ['js', 'native'],
// ['js', 'js']
];
let runTestsArgPairs;
if (semver.satisfies(process.version, '>=9.4')) {
runTestsArgPairs = [
['native', 'native'],
['native', 'js'],
// ['js', 'native'],
// ['js', 'js']
];
} else {
runTestsArgPairs = [
['native', 'native']
];
}
return runTestsArgPairs.reduce((previousPromise, argPair) => {
return previousPromise.then(runTestsWithFixture.bind(null, argPair[0], argPair[1]));
}, Promise.resolve());