Skip to content

Commit

Permalink
test: Disabled code coverage collection on Travis windows workers
Browse files Browse the repository at this point in the history
  • Loading branch information
rpl committed Oct 25, 2019
1 parent 8a33614 commit 783ec5c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"build": "node scripts/build",
"start": "node scripts/develop",
"test": "node scripts/test",
"test-coverage": "nyc npm run test",
"test-coverage": "node scripts/test --coverage",
"test-functional": "node scripts/test-functional",
"publish-coverage": "nyc report --reporter=text-lcov | coveralls",
"audit-deps": "node ./scripts/audit-deps",
Expand Down
19 changes: 12 additions & 7 deletions scripts/lib/mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@ const shell = require('shelljs');

const config = require('./config');

// Get the explicit path to mocha (needed to make it find mocha binary on travis windows workers).
const mochaPath = String(shell.which('mocha'));

const runMocha = (args, execMochaOptions = {}) => {
const res = spawnSync(mochaPath, args, {
// Get the explicit path (needed on travis windows workers).
function which(...args) {
return String(shell.which(...args));
}

const runMocha = (args, execMochaOptions = {}, coverageEnabled) => {
const mochaPath = which('mocha');
const binArgs = coverageEnabled ? [mochaPath, ...args] : args;
const binPath = coverageEnabled ? which('nyc') : mochaPath;
const res = spawnSync(binPath, binArgs, {
...execMochaOptions,
stdio: 'inherit',
});
Expand All @@ -21,8 +26,8 @@ const runMocha = (args, execMochaOptions = {}) => {
return res.status === 0;
};

exports.mochaUnit = (execMochaOptions) => {
return runMocha(config.mocha.unit, execMochaOptions);
exports.mochaUnit = (execMochaOptions, coverageEnabled) => {
return runMocha(config.mocha.unit, execMochaOptions, coverageEnabled);
};

exports.mochaFunctional = (execMochaOptions) => {
Expand Down
16 changes: 14 additions & 2 deletions scripts/test
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
#!/usr/bin/env node

let COVERAGE = process.argv.includes('--coverage');

const {TRAVIS_OS_NAME} = process.env;
if (TRAVIS_OS_NAME === 'windows') {
console.log(
'Skipping coverage collection because running on',
TRAVIS_OS_NAME,
'(See issue https://github.com/mozilla/web-ext/issues/1739)'
);
COVERAGE = false;
}

const eslint = require('./lib/eslint');
const {flowCheck} = require('./lib/flow');
const {mochaUnit} = require('./lib/mocha');
Expand All @@ -14,6 +26,6 @@ if (!flowCheck()) {
process.exit(1);
}

console.log('Running mocha unit tests...');
const ok = mochaUnit();
console.log('Running mocha unit tests...', COVERAGE ? '(COVERAGE)' : '');
const ok = mochaUnit({}, COVERAGE);
process.exit(ok ? 0 : 1);

0 comments on commit 783ec5c

Please sign in to comment.