-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resolve #22: --unanimous
will exit(0) and output nothing if all hosts agree.
#35
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,9 @@ const yargv = yargs | |
.describe('showSource', 'show input source') | ||
.boolean('showSource') | ||
.alias('showSource', 'i') | ||
.describe('unanimous', 'If all engines agree, exit(0) with no output, otherwise print and exit(1); implies --coalesce') | ||
.boolean('unanimous') | ||
.alias('unanimous', 'u') | ||
.nargs('h', 1) | ||
.describe('async', 'wait for realm destruction before reporting results') | ||
.boolean('async') | ||
|
@@ -72,6 +75,7 @@ const yargv = yargs | |
.example('eshost -h ch-*,node test.js') | ||
.example('eshost -h ch-1.?.? test.js') | ||
.example('eshost --tags latest test.js') | ||
.example('eshost --unanimous test.js') | ||
.fail(function (msg, err) { | ||
if (err) { | ||
console.error(err.stack); | ||
|
@@ -83,6 +87,11 @@ const yargv = yargs | |
|
||
const argv = yargv.argv; | ||
|
||
// --unanimous implies --coalesce | ||
if (argv.unanimous) { | ||
argv.coalesce = true; | ||
} | ||
|
||
let config; | ||
if (argv.c) { | ||
config = new Config(argv.c); | ||
|
@@ -169,11 +178,10 @@ if (hosts.length === 0) { | |
|
||
let reporterOptions = { | ||
showSource: argv.showSource, | ||
coalesce: argv.coalesce | ||
coalesce: argv.coalesce, | ||
showSource: argv.showSource, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplicate key here. |
||
unanimous: argv.unanimous | ||
}; | ||
if (argv.showSource) { | ||
reporterOptions.showSource = true; | ||
} | ||
|
||
let reporter; | ||
if (argv.table) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
const chalk = require('chalk'); | ||
|
||
module.exports = class Reporter { | ||
constructor (options = {}) { | ||
this.options = options; | ||
|
@@ -34,4 +36,16 @@ module.exports = class Reporter { | |
]); | ||
} | ||
} | ||
|
||
static addTo(hostName, result) { | ||
table.push([ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
static addTo(table, host, result) {
table.push([
host.name, result
]);
} |
||
hostName, result | ||
]); | ||
} | ||
|
||
static printSource(source) { | ||
console.log(chalk.blue("## Source")); | ||
console.log(source); | ||
console.log(""); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,17 +2,14 @@ const Reporter = require('../Reporter.js'); | |
const chalk = require('chalk'); | ||
|
||
module.exports = class DefaultReporter extends Reporter { | ||
constructor (options) { | ||
constructor(options) { | ||
super(options); | ||
this.source = undefined; | ||
this.results = []; | ||
this.resultsMap = {}; | ||
} | ||
start(text) { | ||
if (this.options.showSource) { | ||
console.log(chalk.blue('## Source')); | ||
console.log(text); | ||
console.log(""); | ||
} | ||
start(source) { | ||
this.source = source; | ||
} | ||
result(host, result) { | ||
let resultString = result.stdout.trim(); | ||
|
@@ -23,14 +20,27 @@ module.exports = class DefaultReporter extends Reporter { | |
if (this.options.coalesce) { | ||
Reporter.coalesceInto(this.results, host, resultString, this.resultsMap, ", "); | ||
} else { | ||
printHostResult(host.name, resultString); | ||
Reporter.addTo(host.name, resultString); | ||
} | ||
} | ||
end() { | ||
if (this.options.coalesce) { | ||
this.results.forEach(row => { | ||
printHostResult(row[0], row[1]); | ||
}) | ||
if (this.options.unanimous && this.results.length == 1) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand this logic, as the following results are unanimous, but would fail this check. Given:
But that would fail this check and thus fail
|
||
process.exit(0); | ||
// don't print anything | ||
} else { | ||
if (this.options.showSource) { | ||
Reporter.printSource(this.source); | ||
} | ||
|
||
this.results.forEach(row => { | ||
printHostResult(row[0], row[1]); | ||
}) | ||
|
||
if (this.options.unanimous) { | ||
process.exit(1); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing
-e
or--eval