Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(logging): Made some logging clearer and make sure not to overwrite exit codes #163

Merged
merged 1 commit into from
Nov 28, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions lib/cmds/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ if (argv._[0] === 'start-run') {

// Manage processes used in android emulation
let androidProcesses: ChildProcess[] = [];
let androidActiveAVDs: string[] = [];

/**
* Parses the options and starts the selenium standalone server.
Expand Down Expand Up @@ -212,7 +213,10 @@ function start(options: Options) {
seleniumProcess.on('exit', (code: number) => {
logger.info('Selenium Standalone has exited with code ' + code);
shutdownEverything();
process.exit(code);
process.exit(process.exitCode || code);
});
seleniumProcess.on('error', (error: Error) => {
logger.warn('Selenium Standalone server encountered an error: ' + error);
});
process.stdin.resume();
process.stdin.on('data', (chunk: Buffer) => {
Expand Down Expand Up @@ -242,32 +246,41 @@ function startAndroid(
avds.length + ' android devices');
}
avds.forEach((avd: string, i: number) => {
logger.info('Booting up AVD ' + avd);
// Credit to appium-ci, which this code was adapted from
let emuBin = 'emulator'; // TODO(sjelin): get the 64bit linux version working
let emuArgs = [
'-avd',
avd + '-v' + sdk.versionCustom + '-wd-manager',
'-netfast',
];
let portArg = null;
if (!useSnapshots) {
emuArgs = emuArgs.concat(['-no-snapshot-load', '-no-snapshot-save']);
}
if (port) {
emuArgs = emuArgs.concat(['-port', '' + (port + 2 * i)]);
portArg = port + i * 2;
emuArgs = emuArgs.concat(['-port', '' + portArg]);
}
if (emuBin !== 'emulator') {
emuArgs = emuArgs.concat(['-qemu', '-enable-kvm']);
}
androidProcesses.push(spawn(path.resolve(sdkPath, 'tools', emuBin), emuArgs, stdio));
logger.info(
'Starting ' + avd + ' on ' + (portArg == null ? 'default port' : 'port ' + portArg));
let child = spawn(path.resolve(sdkPath, 'tools', emuBin), emuArgs, stdio);
child.on('error', (error: Error) => {
logger.warn(avd + ' encountered an error: ' + error);
});
androidProcesses.push(child);
androidActiveAVDs.push(avd);
});
}

function killAndroid() {
androidProcesses.forEach((androidProcess: ChildProcess) => {
androidProcess.kill();
});
androidProcesses.length = 0;
for (var i = 0; i < androidProcesses.length; i++) {
logger.info('Shutting down ' + androidActiveAVDs[i]);
androidProcesses[i].kill();
}
androidProcesses.length = androidActiveAVDs.length = 0;
}

// Manage appium process
Expand Down