`embark test —node` help, plus fix for vm option

Add better help info for `embark test —node`.

Fixed issue with `embark test —node vm` where the `vm` was attempted to be parsed as a URL instead of running the simulator.
This commit is contained in:
emizzle 2018-09-13 20:34:15 +10:00
parent 323ec0d529
commit 60703b86c5
2 changed files with 11 additions and 2 deletions

View File

@ -264,12 +264,21 @@ class Cmd {
test() { test() {
program program
.command('test [file]') .command('test [file]')
.option('-n , --node [node]', __('Node to connect to (default: vm)')) .option('-n , --node <node>', __('Node to connect to. Valid values are ["vm", "embark", "<custom node endpoint>"]: \n') +
' vm - ' + __('Starts an Ethereum simulator (ganache) and runs the tests using the simulator') + '\n' +
' embark - ' + __('Uses the node associated with an already running embark process') + '\n' +
' ' + __('<custom node endpoint> - Connects to a running node available at the end point and uses it to run the tests'),
/^(vm|embark|((ws|https?):\/\/([a-zA-Z0-9_.-]*):?([0-9]*)?))$/i, null)
.option('-d , --gasDetails', __('When set, will print the gas cost for each contract deploy')) .option('-d , --gasDetails', __('When set, will print the gas cost for each contract deploy'))
.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'))
.action(function(file, options) { .action(function(file, options) {
if(options.node === null){
console.log(__('Invalid value for option --node. Valid values are ["vm", "embark", "<custom node endpoint>"]".').red);
console.log(options.optionHelp());
process.exit(1);
}
checkDeps(); checkDeps();
i18n.setOrDetectLocale(options.locale); i18n.setOrDetectLocale(options.locale);
embark.runTests({file, loglevel: options.loglevel, gasDetails: options.gasDetails, node: options.node}); embark.runTests({file, loglevel: options.loglevel, gasDetails: options.gasDetails, node: options.node});

View File

@ -58,7 +58,7 @@ class Test {
}); });
} }
if (this.simOptions.host || this.options.node) { if (this.simOptions.host || (this.options.node && this.options.node !== 'vm')) {
let options = this.simOptions; let options = this.simOptions;
if (this.options.node) { if (this.options.node) {
options = utils.deconstructUrl(this.options.node); options = utils.deconstructUrl(this.options.node);