android-emulator-runner icon indicating copy to clipboard operation
android-emulator-runner copied to clipboard

Add option to not kill emulator immediately

Open kschults opened this issue 3 years ago • 3 comments

I'm currently debugging an issue that's happening when I run Espresso tests on an emulator in a Github workflow, and I want to be able to extract the logs from the emulator to investigate.

The problem is that as soon as the connected...Test command fails, this tool runs adb -s emulator-5554 emu kill, taking down the emulator and the logs with it. It would be great to have an option to support running commands after the script before the emulator is killed.

Alternatively, allowing multi-line scripts to continue even if an individual line fails would also work. https://github.com/ReactiveCircus/android-emulator-runner/blob/main/src/main.ts#L179 seems to prevent this.

kschults avatar Jan 14 '22 16:01 kschults

Had the same problem when I wanted to screenshot the device after failing tests.

Have a workaround. Run the tests, take note of the status, but do not let the outside world know it yet, run your other things and only then return the original test status.

script: |
  ./gradlew connectedCheck || touch sorry_but_tests_are_failing

  adb shell screencap /data/local/tmp/screen.png
  adb pull /data/local/tmp/screen.png

  test ! -f sorry_but_tests_are_failing

Full example - https://github.com/ViliusSutkus89/TestingStorageAccessFrameworkClients/blob/master/.github/workflows/build.yml

ViliusSutkus89 avatar Jan 31 '22 23:01 ViliusSutkus89

Thanks for the example, that's exactly what I needed. For testing purposes, I ended up using || true, so thanks for the way to pass on whether or not the tests actually failed!

kschults avatar Feb 01 '22 16:02 kschults

@kschults , now your build badge might not be green anymore :laughing:

ViliusSutkus89 avatar Feb 01 '22 17:02 ViliusSutkus89

Seems like this is resolved, so I will close this out.

mrk-han avatar Oct 20 '22 15:10 mrk-han