Skip to content

Commit

Permalink
fixed an issue where settings.testWorkersEnabled was true when single…
Browse files Browse the repository at this point in the history
… test file was being run
  • Loading branch information
beatfactor committed Jan 8, 2023
1 parent 34322ca commit 23f85bd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/settings/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const lodashMerge = require('lodash.merge');
const CI_Info = require('ci-info');
const Defaults = require('./defaults.js');
const Utils = require('../utils');
const {isObject, isUndefined, isDefined, isNumber} = Utils;
const {isObject, isUndefined, isDefined, isNumber, singleSourceFile} = Utils;

class Settings {

Expand Down Expand Up @@ -330,7 +330,7 @@ class Settings {
this.settings.test_workers.workers = this.argv.workers || this.settings.test_workers.workers;
}

this.settings.testWorkersEnabled = this.testWorkersEnabled;
this.settings.testWorkersEnabled = this.testWorkersEnabled && !singleSourceFile(this.argv);

return this;
}
Expand Down
4 changes: 2 additions & 2 deletions test/src/runner/cli/testCliRunnerParallel.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe('Test CLI Runner in Parallel', function () {
assert.strictEqual(runner.isTestWorkersEnabled(), false);
});

it('mobile config setup on with worker threads - disabled parallelsim ', function() {
it('mobile config setup on with worker threads - disabled parallelism ', function() {
class RunnerBaseMock extends RunnerBase {
static readTestSource(settings, argv) {
assert.strictEqual(settings.testWorkersEnabled, true);
Expand Down Expand Up @@ -120,7 +120,7 @@ describe('Test CLI Runner in Parallel', function () {
assert.strictEqual(runner.parallelMode(), false);
});

it('mobile config setup on with multiple envs - enable parallelsim ', function() {
it('mobile config setup on with multiple envs - enable parallelism ', function() {
class RunnerBaseMock extends RunnerBase {
static readTestSource(settings, argv) {
assert.strictEqual(settings.testWorkersEnabled, true);
Expand Down
20 changes: 20 additions & 0 deletions test/src/runner/testRunTestsuite.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,4 +260,24 @@ describe('testRunTestSuite', function () {
skip_testcases_on_fail: true
}));
});

it('testRunner with parallel mode and single test source', function () {
let testsPath = path.join(__dirname, '../../sampletests/withdescribe/failures/sampleSkipTestcases.js');
let globals = {
calls: 0,
retryAssertionTimeout: 0,
reporter(results, cb) {
assert.strictEqual(this.settings.testWorkersEnabled, false);
cb();
}
};

return runTests({
_source: [testsPath]
}, settings({
globals,
output: false,
test_workers: true,
}));
});
});

0 comments on commit 23f85bd

Please sign in to comment.