Skip to content

Commit

Permalink
Merge pull request #1177 from RhinobyteSoftware/ryant/master/Issue1176
Browse files Browse the repository at this point in the history
PR (Issue #1176) - Stop Forcing -gpu host on android emulators
Fix #1176
  • Loading branch information
d4vidi authored Mar 14, 2019
2 parents 8cc9468 + 3899ea2 commit e7cbb69
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
6 changes: 5 additions & 1 deletion detox/local-cli/detox-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ program
'Specify test file to run')
.option('-H, --headless',
'[Android Only] Launch Emulator in headless mode. Useful when running on CI.')
.option('--gpu [gpu mode]',
'[Android Only] Launch Emulator with the specific -gpu [gpu mode] parameter.')
.option('-w, --workers <n>',
'[iOS Only] Specifies number of workers the test runner should spawn, requires a test runner with parallel execution support (Detox CLI currently supports Jest)', 1)
.option('-n, --device-name [name]',
Expand Down Expand Up @@ -127,13 +129,14 @@ function runMocha() {
const screenshots = program.takeScreenshots ? `--take-screenshots ${program.takeScreenshots}` : '';
const videos = program.recordVideos ? `--record-videos ${program.recordVideos}` : '';
const headless = program.headless ? `--headless` : '';
const gpu = program.gpu ? `--gpu ${program.gpu}` : '';
const color = program.color ? '' : '--no-colors';
const deviceName = program.deviceName ? `--device-name "${program.deviceName}"` : '';

const debugSynchronization = program.debugSynchronization ? `--debug-synchronization ${program.debugSynchronization}` : '';
const binPath = path.join('node_modules', '.bin', 'mocha');
const command = `${binPath} ${testFolder} ${configFile} ${configuration} ${loglevel} ${color} ` +
`${cleanup} ${reuse} ${debugSynchronization} ${platformString} ${headless} ` +
`${cleanup} ${reuse} ${debugSynchronization} ${platformString} ${headless} ${gpu} ` +
`${logs} ${screenshots} ${videos} ${artifactsLocation} ${deviceName} ${collectExtraArgs()}`;

console.log(command);
Expand All @@ -154,6 +157,7 @@ function runJest() {
cleanup: program.cleanup,
reuse: program.reuse,
debugSynchronization: program.debugSynchronization,
gpu: program.gpu,
headless: program.headless,
artifactsLocation: program.artifactsLocation,
recordLogs: program.recordLogs,
Expand Down
15 changes: 12 additions & 3 deletions detox/src/devices/android/Emulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,16 @@ class Emulator {
async boot(emulatorName) {
const emulatorArgs = _.compact([
'-verbose',
'-gpu', this.gpuMethod(),
'-no-audio',
argparse.getArgValue('headless') ? '-no-window' : '',
`@${emulatorName}`
]);

const gpuMethod = this.gpuMethod();
if(gpuMethod) {
emulatorArgs.push('-gpu', gpuMethod);
}

let childProcessOutput;
const tempLog = `./${emulatorName}.log`;
const stdout = fs.openSync(tempLog, 'a');
Expand Down Expand Up @@ -82,6 +86,11 @@ class Emulator {
}

gpuMethod() {
const gpuArgument = argparse.getArgValue('gpu');
if(gpuArgument) {
return gpuArgument;
}

if (argparse.getArgValue('headless')) {
switch (os.platform()) {
case 'darwin':
Expand All @@ -93,9 +102,9 @@ class Emulator {
default:
return 'auto';
}
} else {
return 'host';
}

return undefined;
}
}

Expand Down

0 comments on commit e7cbb69

Please sign in to comment.