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

feat: Throw InvalidContextError if instrumentation process crashes unexpectedly #591

Merged
merged 1 commit into from
Jul 23, 2020
Merged
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions lib/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,14 @@ class EspressoDriver extends BaseDriver {
}
}

async executeCommand (cmd, ...args) {
if (cmd !== 'deleteSession' && this.espresso?.didInstrumentationCrash) {
throw new errors.InvalidContextError(
'The instrumentation process has unexpectedly crashed. Check the logcat output for more details.');
}
return await super.executeCommand(cmd, ...args);
}

async deleteSession () {
logger.debug('Deleting espresso session');
await this.mobileStopScreenStreaming();
Expand Down
3 changes: 3 additions & 0 deletions lib/espresso-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class EspressoRunner {

this.serverLaunchTimeout = opts.serverLaunchTimeout || ESPRESSO_SERVER_LAUNCH_TIMEOUT;
this.androidInstallTimeout = opts.androidInstallTimeout;
this.didInstrumentationCrash = false;

this.disableSuppressAccessibilityService = opts.disableSuppressAccessibilityService;

Expand Down Expand Up @@ -238,6 +239,8 @@ class EspressoRunner {
// A 'SocketException' indicates that we couldn't connect to the Espresso Server, because the INTERNET permission is not set
if (line.toLowerCase().includes('java.net.socketexception')) {
hasSocketError = true;
} else if (line.includes('Process crashed')) {
this.didInstrumentationCrash = true;
}
});

Expand Down