【发布时间】:2017-12-19 14:17:03
【问题描述】:
我正在尝试在 CI 进程中运行 androidTests。我为此使用 VSTS 构建定义。在测试之前,我必须启动 Android Emulator。我可以使用 Shell 脚本任务来启动模拟器,但由于我无法在后台启动该过程,因此构建流程无法进行下一步。 我已经尝试了下面列出的所有可能性:
nohup $ANDROID_HOME/tools/emulator @emulatorForUITests
nohup $ANDROID_HOME/tools/emulator @emulatorForUITests &
$ANDROID_HOME/tools/emulator @emulatorForUITests &
但模拟器仍在前台运行。我做错了什么还是 VSTS 安全功能?如何在后台启动模拟器?
更新(在 cmets 中回答问题):
- 在前台启动模拟器会阻止构建过程,因此它 必须是非阻塞(后台)任务。模拟器开始于 无论如何,前景(在 UI 中)。如果我使用相同的脚本启动它,但是 直接从终端而不是 VSTS,模拟器启动,测试是 运行,一切正常
- 我使用自己的代理(在 macOS 上)
更新2: 从 VSTS 构建日志:
(...)
2017-07-14T10:11:31.8195010Z emulator: WARNING: userdata partition is resized from 550 M to 800 M
2017-07-14T10:11:31.8202870Z
2017-07-14T10:11:31.8217150Z Hax is enabled
2017-07-14T10:11:31.8230410Z Hax ram_size 0x40000000
2017-07-14T10:11:31.8246000Z HAX is working and emulator runs in fast virt mode.
2017-07-14T10:11:34.0594360Z coreaudio: Could not initialize record - Unknown Audiodevice
2017-07-14T10:11:34.0627730Z coreaudio: Could not initialize record - Unknown Audiodevice
2017-07-14T10:11:34.0649440Z audio: Failed to create voice `goldfish_audio_in'
2017-07-14T10:11:34.0671380Z qemu-system-i386: warning: opening audio input failed
2017-07-14T10:11:34.0875870Z coreaudio: Could not initialize record - Unknown Audiodevice
2017-07-14T10:11:34.0888750Z coreaudio: Could not initialize record - Unknown Audiodevice
2017-07-14T10:11:34.0902400Z audio: Failed to create voice `adc'
2017-07-14T10:11:34.5066290Z emulator: emulator window was out of view and was recentered
2017-07-14T10:11:34.5078580Z
由于模拟器不是后台进程,VSTS 等待emulator 进程完成。
【问题讨论】:
-
你想做UI测试吗?如果是这样,模拟器应该在前台运行以进行 UI 交互。另一方面,如果您在机器上手动运行该命令会产生什么结果?它在后台运行吗?
-
您使用托管代理吗?
-
如果直接从终端运行该脚本,是否需要手动停止终端才能运行其他命令?
-
否,在 Terminal
$ANDROID_HOME/tools/emulator @emulatorForUITests &中启动非阻塞进程并继续到脚本中的下一行 -
你可以在这里发布详细的构建日志吗?
标签: bash android-emulator continuous-integration azure-pipelines-build-task