Skip to content

The Gradle plugin discards adb's exit code and standard error #340

Description

@DanielJette

Found while fixing #245, and only partly addressed there.

runProcess reads the process's standard output and nothing else (Plugins/Gradle/src/main/kotlin/dev/testify/internal/ClientUtilities.kt):

val process = Runtime.getRuntime().exec(command)
val result = streamData.handleInputStream(process.inputStream)
process.waitFor()
return result

Two signals are thrown away:

  1. Standard error. Anything adb or the device-side command writes there is invisible to the caller.
  2. The exit code. waitFor()'s return value is discarded, so a command that failed outright looks the same as one that succeeded.

The concrete case this produced: with the application under test not installed, screenshotTest on a com.android.test module printed INSTRUMENTATION_STATUS: Error=Unable to find instrumentation target package, ran zero tests, and reported BUILD SUCCESSFUL. #333 fixes that one path by giving runProcess an opt-in redirectErrorStream that the am instrument call uses.

Every other call site still has the gap. screenshotPull, screenshotClear, reportPull and the device-setup tasks all go through Adb.execute(), so an adb failure in any of them is silent — a pull that copies nothing looks like a pull with nothing to copy.

Suggested fix: check the exit code in runProcess and surface a non-zero one. That is the better signal than string-matching stderr, but it needs checking per call site first: some commands are expected to fail benignly, and listFiles already appends 2>/dev/null precisely because a missing directory is normal. A blanket throw would break those.

Worth doing as its own change, with the call sites audited, rather than widening #333.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions