Merge pull request #950 from cryptomental/feature/add-nobrowser-option-to-coverage

cmd, run_tests: Add --nobrowser option for runCoverage.
This commit is contained in:
Iuri Matias 2018-10-02 18:41:06 -04:00 committed by GitHub
commit 9d34bed725
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -275,6 +275,7 @@ class Cmd {
' <endpoint> - ' + __('connect to and use the specified node')) ' <endpoint> - ' + __('connect to and use the specified node'))
.option('-d , --gasDetails', __('print the gas cost for each contract deployment when running the tests')) .option('-d , --gasDetails', __('print the gas cost for each contract deployment when running the tests'))
.option('-c , --coverage', __('generate a coverage report after running the tests (vm only)')) .option('-c , --coverage', __('generate a coverage report after running the tests (vm only)'))
.option('--nobrowser', __('do not start browser after coverage report is generated'))
.option('--locale [locale]', __('language to use (default: en)')) .option('--locale [locale]', __('language to use (default: en)'))
.option('--loglevel [loglevel]', __('level of logging to display') + ' ["error", "warn", "info", "debug", "trace"]', /^(error|warn|info|debug|trace)$/i, 'warn') .option('--loglevel [loglevel]', __('level of logging to display') + ' ["error", "warn", "info", "debug", "trace"]', /^(error|warn|info|debug|trace)$/i, 'warn')
.description(__('run tests')) .description(__('run tests'))
@ -295,7 +296,7 @@ class Cmd {
checkDeps(); checkDeps();
i18n.setOrDetectLocale(options.locale); i18n.setOrDetectLocale(options.locale);
embark.runTests({file, loglevel: options.loglevel, gasDetails: options.gasDetails, embark.runTests({file, loglevel: options.loglevel, gasDetails: options.gasDetails,
node: options.node, coverage: options.coverage}); node: options.node, coverage: options.coverage, noBrowser: options.nobrowser});
}); });
} }

View File

@ -140,6 +140,9 @@ module.exports = {
console.log(`Coverage report created. You can find it here: ${fs.dappPath('coverage/__root__/index.html')}\n`); console.log(`Coverage report created. You can find it here: ${fs.dappPath('coverage/__root__/index.html')}\n`);
const opn = require('opn'); const opn = require('opn');
const _next = () => { next(); }; const _next = () => { next(); };
if (options.noBrowser) {
return next();
}
opn(fs.dappPath('coverage/__root__/index.html'), {wait: false}) opn(fs.dappPath('coverage/__root__/index.html'), {wait: false})
.then(() => new Promise(resolve => setTimeout(resolve, 1000))) .then(() => new Promise(resolve => setTimeout(resolve, 1000)))
.then(_next, _next); .then(_next, _next);