Skip to content

Commit

Permalink
Merge pull request appium#181 from appium/isaac-errors
Browse files Browse the repository at this point in the history
Stop swallowing errors in adb exec
  • Loading branch information
imurchie committed Nov 6, 2016
2 parents 7cd1b7b + a0bc9ec commit d834891
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
language: node_js
node_js:
- "0.12"
- "4"
- "6"
env:
global:
- _FORCE_LOGS=1
Expand Down
14 changes: 6 additions & 8 deletions lib/tools/system-calls.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,28 +182,26 @@ systemCallMethods.adbExec = async function (cmd, opts = {}) {
let protocolFaultError = new RegExp("protocol fault \\(no status\\)", "i").test(e);
let deviceNotFoundError = new RegExp("error: device ('.+' )?not found", "i").test(e);
if (protocolFaultError || deviceNotFoundError) {
log.info(`error sending command, reconnecting device and retrying: ${cmd}`);
log.info(`Error sending command, reconnecting device and retrying: ${cmd}`);
await sleep(1000);
await this.getDevicesWithRetry();
}
if (e.stderr) {
return e.stderr;
}

if (e.stdout) {
let stdout = e.stdout;
stdout = stdout.replace(linkerWarningRe, '').trim();
return stdout;
}
throw new Error(`Error executing adbExec. Original error: ${e.message}` +
JSON.stringify(e));
throw new Error(`Error executing adbExec. Original error: '${e.message}'; ` +
`Stderr: '${(e.stderr || '').trim()}'; Code: '${e.code}'`);
}
};
return await retry(2, execFunc);
};

systemCallMethods.shell = async function (cmd, opts = {}) {
if (!await this.isDeviceConnected()) {
throw new Error(`No device connected, cannot run adb shell command "${cmd.join(' ')}"`);
throw new Error(`No device connected, cannot run adb shell command '${cmd.join(' ')}'`);
}
let execCmd = ['shell'];
if (cmd instanceof Array) {
Expand All @@ -217,7 +215,7 @@ systemCallMethods.shell = async function (cmd, opts = {}) {
systemCallMethods.createSubProcess = function (args = []) {
// add the default arguments
args = this.executable.defaultArgs.concat(args);
log.debug(`Creating ADB subprocess with args: ${args.join(', ')}`);
log.debug(`Creating ADB subprocess with args: ${JSON.stringify(args)}`);
return new SubProcess(this.getAdbPath(), args);
};

Expand Down

0 comments on commit d834891

Please sign in to comment.