-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
45 changed files
with
548 additions
and
633 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,5 @@ | ||
function current() { | ||
if (process.env.JEST_WORKER_ID) { | ||
return require('./worker'); | ||
} | ||
|
||
if (process.env.DETOX_IPC_SERVER_ID) { | ||
return require('./runner'); | ||
} | ||
|
||
return require('./root'); | ||
return process.env.DETOX_IPC_SERVER_ID ? require('./secondary') : require('./primary'); | ||
} | ||
|
||
module.exports = current(); |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
const { upperFirst, camelCase } = require('lodash'); | ||
|
||
const { DetoxInternalError } = require('../../src/errors'); | ||
|
||
class IPCServer { | ||
constructor({ id, logger, detoxConfig }) { | ||
this._id = id; | ||
this._logger = logger; | ||
this._state = { | ||
workers: 0, | ||
detoxConfig, | ||
}; | ||
this._ipc = null; | ||
} | ||
|
||
get id() { | ||
return this._id; | ||
} | ||
|
||
async start() { | ||
this._ipc = require('node-ipc'); | ||
this._ipc.config.id = this._id; | ||
this._ipc.config.retry = 1500; | ||
// this._ipc.config.silent = true; | ||
await new Promise((resolve) => { | ||
// TODO: handle reject | ||
this._ipc.serve(() => resolve()); | ||
this._ipc.server.on('registerWorker', this.onRegisterWorker.bind(this)); | ||
this._ipc.server.on('log', this.onLog.bind(this)); | ||
this._ipc.server.start(); | ||
}); | ||
} | ||
|
||
async stop() { | ||
return new Promise((resolve, reject) =>{ | ||
// @ts-ignore | ||
this._ipc.server.server.close(e => e ? reject(e) : resolve()); | ||
}); | ||
} | ||
|
||
onRegisterWorker({ workerId }, socket) { | ||
const workersCount = this._state.workers = Math.max(this._state.workers, +workerId); | ||
const detoxConfig = this._state.detoxConfig; | ||
socket.emit('detoxConfig', detoxConfig); | ||
this._ipc.server.broadcast('workersCount', { value: workersCount }); | ||
} | ||
|
||
onLog({ level, args }) { | ||
this._logger[level](args); | ||
} | ||
} | ||
|
||
module.exports = IPCServer; |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const ipcClient = require('../../src/ipc/client'); | ||
const IPCLogger = require('../../src/logger/IPCLogger'); | ||
const NullLogger = require('../../src/logger/NullLogger'); | ||
|
||
class DetoxRunnerContext { | ||
constructor() { | ||
this.setup = this.setup.bind(this); | ||
this.teardown = this.teardown.bind(this); | ||
/** @type {NullLogger | IPCLogger} */ | ||
this._logger = new NullLogger(); | ||
this._fingerprint = Math.random(); | ||
this._ready = false; | ||
this._config = null; | ||
} | ||
|
||
async setup() { | ||
if (this._ready) { | ||
return; | ||
} | ||
|
||
await ipcClient.init(); | ||
this._config = await ipcClient.getDetoxConfig(); | ||
this._logger = new IPCLogger({ | ||
level: this._config.cliConfig.loglevel, | ||
}); | ||
this._ready = true; | ||
} | ||
|
||
async teardown() { | ||
this._ready = false; | ||
} | ||
|
||
get config() { | ||
return this._config; | ||
} | ||
|
||
get log() { | ||
return this._logger; | ||
} | ||
} | ||
|
||
module.exports = DetoxRunnerContext; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
const DetoxRunnerContext = require('./DetoxRunnerContext'); | ||
module.exports = new DetoxRunnerContext(); |
14 changes: 0 additions & 14 deletions
14
detox/realms/worker/environment/utils/wrapErrorWithNoopLifecycle.js
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('../../migration')(__filename); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.