Skip to content

Commit

Permalink
wip: revive worker context
Browse files Browse the repository at this point in the history
  • Loading branch information
noomorph committed May 27, 2022
1 parent 0c0f356 commit 37be973
Show file tree
Hide file tree
Showing 26 changed files with 377 additions and 351 deletions.
16 changes: 15 additions & 1 deletion detox/realms/root/DetoxRootContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const _ = require('lodash');
const configuration = require('../../src/configuration');
const DeviceRegistry = require('../../src/devices/DeviceRegistry');
const GenyDeviceRegistryFactory = require('../../src/devices/allocation/drivers/android/genycloud/GenyDeviceRegistryFactory');
const environmentFactory = require('../../src/environmentFactory');
const NullLogger = require('../../src/logger/NullLogger');
const DetoxServer = require('../../src/server/DetoxServer');

Expand All @@ -19,6 +20,7 @@ class DetoxRootContext {
this._wss = null;
this._ipc = null;
this._logger = new NullLogger();
this._globalLifecycleHandler = null;

this.setup = this.setup.bind(this);
this.teardown = this.teardown.bind(this);
Expand Down Expand Up @@ -48,6 +50,10 @@ class DetoxRootContext {
this._wss = null;
}

if (this._globalLifecycleHandler) {
await this._globalLifecycleHandler.globalCleanup();
}

// TODO: move the artifacts
}

Expand All @@ -66,6 +72,7 @@ class DetoxRootContext {

async _doSetup() {
const config = this._config;

this._logger = new BunyanLogger({
loglevel: config.cliConfig.loglevel || 'info',
});
Expand All @@ -90,7 +97,14 @@ class DetoxRootContext {
});

await this._ipc.start();
const { cliConfig, sessionConfig } = config;

const { cliConfig, deviceConfig, sessionConfig } = config;

this._globalLifecycleHandler = await environmentFactory.createGlobalLifecycleHandler(deviceConfig);

if (this._globalLifecycleHandler) {
await this._globalLifecycleHandler.globalInit();
}

if (!cliConfig.keepLockFile) {
await this._resetLockFile();
Expand Down
1 change: 1 addition & 0 deletions detox/realms/root/IPCServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class IPCServer {
this._ipc.config.id = this._id;
this._ipc.config.retry = 1500;
this._ipc.config.sync = true;
this._ipc.config.silent = true;

return new Promise((resolve) => {
// TODO: handle reject
Expand Down
29 changes: 29 additions & 0 deletions detox/realms/runner/DetoxRunnerContext.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const NullLogger = require('../../src/logger/NullLogger');

class DetoxRunnerContext {
constructor() {
this.setup = this.setup.bind(this);
this.teardown = this.teardown.bind(this);
this._logger = new NullLogger();
}

async setup() {

}

async teardown() {

}

get config() {
return null;
}

get log() {
return this._logger;
}
}

DetoxRunnerContext.DetoxReporter = require('./reporters/DetoxReporter');

module.exports = DetoxRunnerContext;
9 changes: 2 additions & 7 deletions detox/realms/runner/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
const NullLogger = require('../../src/logger/NullLogger');
const log = new NullLogger();

module.exports = {
DetoxReporter: require('./reporters/DetoxReporter'),
log,
};
const DetoxRunnerContext = require('./DetoxRunnerContext');
module.exports = new DetoxRunnerContext();

0 comments on commit 37be973

Please sign in to comment.