Detox: Regex for Android bundle id causing failures

Created on 4 Sep 2018  路  17Comments  路  Source: wix/Detox

Using Mac - High Sierra

Description

Line 113 of src/devices/android/ADB.js is:
const bundleIdRegex = pipeCommands.escape.inQuotedRegexp(bundleId) + '[ ]*$';

I'm not sure what the '[ ]*$' is for, or maybe I'm building my application incorrectly. I'm only able to get detox 9.0.1 to work correctly when I delete the + '[ ]*$' from that file. I know this is somewhere between and an issue and a question, but can someone clear this up for me.

Sample error:
detox[9144] ERROR: [exec.js/EXEC_FAIL, #19]
detox[9144] ERROR: [exec.js/EXEC_FAIL, #20] "/Users/me/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell ps | grep "com.myapp.myappportal[ ]*$"" failed with code = 1, stdout and stderr:

acceptebug

All 17 comments

Okay, let's debug it.

Run your app on the emulator and run the command you mentioned

/Users/me/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell ps | grep "com.myapp.myappportal[ ]*$"

Does it print more specific errors?

Thanks noomorph, when I run

tomatobrown@BH12588:~/github/Detox (tmp/bundleid_fix):/Users/tomatobrown/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell ps | grep "com.myapp.myappportal[ ]*$"
tomatobrown@BH12588:~/github/Detox (tmp/bundleid_fix):/Users/tomatobrown/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell ps | grep "com.myapp.myappportal"
u0_a679   9208  1184  1406708 151692 ffffffff b7671255 S com.myapp.myappportal
tomatobrown@BH12588:~/github/Detox (tmp/bundleid_fix):

No error message returns, it just makes a new line.

For what it's worth, the old way works

tomatobrown@BH12588:~/github/Detox (tmp/bundleid_fix):/Users/tomatobrown/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell ps | grep "com.myapp.myappportal\\s*$"
u0_a679   9208  1184  1406708 151692 ffffffff b7671255 S com.myapp.myappportal
tomatobrown@BH12588:~/github/Detox (tmp/bundleid_fix):

@tomatobrown , weird. Can you pipe adb -s emulator-5554 shell ps into a file and send it as-is in an attachment, please? Need to see in hex

here it is @noomorph
adp_ps.txt

Thanks. I'll look at it first thing tomorrow

@tomatobrown , I've found the issue. Your ps output somehow returns ^M line breaks (with DOS endings). I have no slightest idea why but I'll try to extend the regexp for this case.

Thanks @noomorph and for what it's worth, I've confirmed that this same issue exists on at least 3 other Mac's other than mine, so I think the issue might be bigger than it appears.

It's still weird nevertheless. I hope to finish the PR soon, but out of curiosity what emulator and SDKs are you using? On our CI it passes alright and locally I could not reproduce. Thanks for dumping adb ps output into a file. Otherwise, I would not be able to fix your issue.

I've been using a Nexus 5 - with Android 7.1.1 (Nougat)

@DanielMSchmidt could you please take a look

@tomatobrown , I have one more request, could you dump also your

adb shell dumpsys power

into a text file as-is?

@tomatobrown , I was looking at this StackOverflow issue and it made me wonder... which shell you are using? Are you sure your _tty_ is not something exotic?

Here it is:
shell_dump.txt

I'm just using the terminal on High Sierra

@tomatobrown , something's wrong... it has DOS CRLF line endings too. It's not good. If my memory does not fail me, you're the first developer who reports this particular issue.

Should I tell you that I have more than four different PCs (running Windows 10, Ubuntu 18.04, MacOS Sierra, MacOS High Sierra) in my household + I look at our Jenkins CI? And still I was not able to reproduce your issue... What is even worse - I just have realized that in order to fix it, I might need to rewrite the whole ADB helper class in Detox. And that won't get me closer to the source of your issue, which is very daunting.

One more thing. Dump this command adb exec-out dumpsys power into a file, please. I hope it will have LF endings, otherwise your emulator is weird.

And ping me directly (the email is in my profile). I might need your further assistance in this later on.

Thanks for the cooperation.

I can reproduce the issue together with two friends of mine, all on
slightly different hardware

This also happened to both our build and local tests. The only strange behavior that it works for apks built for debug but not for release ones. We're using MacOS High Sierra iTerm/Terminal.

Out stop gap solution was to downgrade to v8.0.0

Was this page helpful?
0 / 5 - 0 ratings

Related issues

carlosalmonte04 picture carlosalmonte04  路  4Comments

jrobber picture jrobber  路  3Comments

aamorozov picture aamorozov  路  3Comments

alexmngn picture alexmngn  路  3Comments

JB-CHAUVIN picture JB-CHAUVIN  路  3Comments