Skip to content

Commit

Permalink
Features/use worker threads (#3592)
Browse files Browse the repository at this point in the history
  • Loading branch information
gravityvi authored Mar 14, 2023
1 parent a157817 commit 08e1ea6
Show file tree
Hide file tree
Showing 19 changed files with 981 additions and 130 deletions.
6 changes: 3 additions & 3 deletions lib/reporter/global-reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ module.exports = class GlobalReporter {
setupChildProcessListener(emitter) {
if (!Concurrency.isTestWorker()) {
emitter.on('message', data => {
data = JSON.parse(data);
data = this.settings.use_child_process ? JSON.parse(data) : data;
this.addTestSuiteResults(data.results, data.httpOutput);
});
}
Expand All @@ -108,7 +108,7 @@ module.exports = class GlobalReporter {
}

print() {
if (Concurrency.isChildProcess() || !this.settings.output) {
if (Concurrency.isWorker() || !this.settings.output) {
return this;
}

Expand Down Expand Up @@ -381,7 +381,7 @@ module.exports = class GlobalReporter {
}

save() {
if (Concurrency.isChildProcess()) {
if (Concurrency.isWorker()) {
return Promise.resolve();
}

Expand Down
12 changes: 6 additions & 6 deletions lib/reporter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,9 @@ class Reporter extends SimplifiedReporter {
let currentTestResult = this.testResults.currentTestResult;

const Concurrency = require('../runner/concurrency');
const isChildProcess = Concurrency.isChildProcess();
if (isChildProcess || !this.settings.detailed_output || this.unitTestsMode) {
this.printSimplifiedTestResult(ok, elapsedTime, isChildProcess);
const isWorker = Concurrency.isWorker();
if (isWorker || !this.settings.detailed_output || this.unitTestsMode) {
this.printSimplifiedTestResult(ok, elapsedTime, isWorker);

return;
}
Expand All @@ -310,14 +310,14 @@ class Reporter extends SimplifiedReporter {
/**
* @param {boolean} ok
* @param {number} elapsedTime
* @param {boolean} isChildProcess
* @param {boolean} isWorker
*/
printSimplifiedTestResult(ok, elapsedTime, isChildProcess) {
printSimplifiedTestResult(ok, elapsedTime, isWorker) {
const {currentTest} = this;

let result = [colors[ok ? 'green': 'red'](Utils.symbols[ok ? 'ok' : 'fail'])];
if (!this.unitTestsMode) {
if (isChildProcess) {
if (isWorker) {
result.push(colors.white(process.env.__NIGHTWATCH_ENV, colors.background.black));
}

Expand Down
6 changes: 3 additions & 3 deletions lib/runner/cli/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ class CliRunner {
}

runGlobalHook(key, args = [], isParallelHook = false) {
if (isParallelHook && Concurrency.isChildProcess() || !isParallelHook && !Concurrency.isChildProcess()) {
if (isParallelHook && Concurrency.isWorker() || !isParallelHook && !Concurrency.isWorker()) {
return this.globals.runGlobalHook(key, args);
}

Expand Down Expand Up @@ -395,7 +395,7 @@ class CliRunner {

if (isMobile(desiredCapabilities)) {

if (Concurrency.isChildProcess()) {
if (Concurrency.isWorker()) {
Logger.info('Disabling parallelism while running tests on mobile platform');
}

Expand Down Expand Up @@ -595,7 +595,7 @@ class CliRunner {
return err;
})
.then(errorOrFailed => {
if (typeof done == 'function' && !Concurrency.isChildProcess()) {
if (typeof done == 'function' && !Concurrency.isWorker()) {
if (errorOrFailed instanceof Error) {
return done(errorOrFailed);
}
Expand Down
Loading

0 comments on commit 08e1ea6

Please sign in to comment.