Skip to content

Commit 7450efc

Browse files
jonpryordellis1972
authored andcommitted
[tests] Improve reliability of emulator attach (dotnet#313)
Sometimes [the PR builder won't launch the emulator][0]: Tool .../emulator execution started with arguments: -avd "XamarinAndroidUnitTestRunner" -port "5600" Task Adb Arguments: -s emulator-5600 wait-for-device Task Adb Arguments: -s emulator-5600 install -r ".../Mono.Android_Tests-Signed.apk" error: device 'emulator-5600' not found ... emulator: WARNING: Increasing RAM size to 1GB ... (Omitting lots of additional output...) What *appears* to be happening is that emulator creation and launching is occasionally happening *after* we attempt to install the `.apk` onto the device, which doesn't really make sense. Resort to the standby of the lazy: add a **sleep**(1) invocation before we call `adb wait-for-device`, on the hopes that 10 seconds is sufficient time to allow the emulator creation and launch to proceed far enough for `adb wait-for-device` to actually *do something*, in turn allowing `adb install` to likewise *do something*. [0]: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android-pr-builder/300/console
1 parent 4dfc20b commit 7450efc

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

build-tools/scripts/UnitTestApks.targets

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<CheckAdbTarget
1616
Condition=" '$(RequireNewEmulator)' != 'True' "
1717
AdbTarget="$(AdbTarget)"
18+
ToolExe="$(AdbToolExe)"
1819
ToolPath="$(AdbToolPath)">
1920
<Output TaskParameter="AdbTarget" PropertyName="_AdbTarget" />
2021
<Output TaskParameter="IsValidTarget" PropertyName="_ValidAdbTarget" />
@@ -39,9 +40,15 @@
3940
<Output TaskParameter="AdbTarget" PropertyName="_EmuTarget" />
4041
<Output TaskParameter="AdbProcess" PropertyName="_EmuProcess" />
4142
</StartAndroidEmulator>
43+
<Exec
44+
Condition=" '$(_ValidAdbTarget)' != 'True' "
45+
Command="sleep 10"
46+
/>
4247
<Adb
4348
Condition=" '$(_ValidAdbTarget)' != 'True' "
4449
Arguments="$(_AdbTarget) wait-for-device"
50+
ToolExe="$(AdbToolExe)"
51+
ToolPath="$(AdbToolPath)"
4552
/>
4653
<Message
4754
Condition=" '$(_EmuTarget)' != '' "
@@ -53,6 +60,8 @@
5360
<Adb
5461
Condition=" '$(_EmuTarget)' != '' "
5562
Arguments="$(_EmuTarget) emu kill"
63+
ToolExe="$(AdbToolExe)"
64+
ToolPath="$(AdbToolPath)"
5665
/>
5766
</Target>
5867

0 commit comments

Comments
 (0)