Skip to content

Commit

Permalink
Fail if parallel is not a numeric value
Browse files Browse the repository at this point in the history
  • Loading branch information
step2yeung committed Nov 22, 2019
1 parent 221908f commit d7bb163
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions config/ember-try.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const command = [
'--split',
'3',
'--parallel',
'1',
'--random',
process.env.TRAVIS_PULL_REQUEST
].filter(Boolean).join(' ');
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/exam.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module.exports = TestCommand.extend({
},
{
name: 'parallel',
type: Number,
type: [Number, String],
description: 'Runs your split tests on parallel child processes.'
},
{
Expand Down
9 changes: 9 additions & 0 deletions lib/utils/tests-options-validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,15 @@ module.exports = class TestsOptionsValidator {
* @return {boolean}
*/
validateParallel() {
const parallelValue = parseInt(this.options.parallel, 10);

if (isNaN(parallelValue)) {
throw new SilentError(
`EmberExam: You must specify a Numeric value to 'parallel'. Value passed: ${this.options.parallel}`
);
}
this.options.parallel = parallelValue;

if (typeof this.options.replayBrowser !== 'undefined') {
throw new SilentError(
'EmberExam: You must not use the `replay-browser` option with the `parallel` option.'
Expand Down
8 changes: 8 additions & 0 deletions node-tests/unit/utils/tests-options-validator-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,14 @@ describe('TestOptionsValidator', function() {
});

describe('shouldParallelize', function() {
it('should throw an error if `parallel` is not a numeric value', function() {
shouldThrow(
'Parallel',
{ parallel: '--reporter' },
/EmberExam: You must specify a Numeric value to 'parallel'. Value passed: --reporter/
);
});

it('should throw an error if `split` is not being used', function() {
shouldThrow(
'Parallel',
Expand Down

0 comments on commit d7bb163

Please sign in to comment.