Repository navigation
Conversation
ofalvai
force-pushed
the
push-yulnvzmsuklr
branch
from
August 24, 2026 16:19
f68e996 to
44370bb
Compare
The beforeEach hook in testBuilder swallowed every error from prepareEmulatorForTest, so an emulator in a bad state surfaced later as an unrelated assertion failure somewhere else in the scenario. It now logs and rethrows. Rethrowing on its own would have broken every scenario, because iOS "simctl terminate" exits non-zero when the app is not running, and the app is not running before the first test of a scenario. Verified on Xcode 26.6 / iOS 26.5: terminate reports "found nothing to terminate" identically whether the app was never installed or is merely idle, so the error text and the exit code cannot tell a missing app apart from a broken simulator. simctl appinfo, get_app_container and listapps do not help either, as they only report whether the app is installed, and their output is unchanged by the app running or not. So IOSEmulatorManager.endRunningApplication now establishes the running state up front with "simctl spawn booted launchctl list", where a running app appears as UIKitApplication:<bundle id> with a live pid, and skips terminate when the app is not running. Everything else propagates. Android needs no equivalent guard: "am force-stop" exits 0 whether or not the app is installed or running (verified against an emulator), and "pm clear" is already guarded by an existence check. Adding one there would only add an adb round-trip per test. Verified end to end against a live simulator and emulator for the installed-but-idle, never-installed and actually-running cases. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
ofalvai
force-pushed
the
push-yulnvzmsuklr
branch
from
November 10, 2026 20:23
44370bb to
fed8004
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The async change breaks the declared Q.Promise contract on iOS, causing callers that use supported methods such as .done() or .fail() to throw TypeErrors.
3 open issues
What changed in this PR
This PR improves emulator-preparation diagnostics in the CodePush test framework and adds an iOS running-state check before terminating an app.
Changes:
- Logs preparation failures in the test hook and rethrows them.
- Uses the simulator’s launchd job list to decide whether to call
simctl terminate.
| File | Description |
|---|---|
code-push-plugin-testing-framework/script/testBuilder.js |
Adds logging and rethrowing for preparation failures. |
code-push-plugin-testing-framework/script/platform.js |
Adds an iOS running-state guard before app termination. |
Review effort: Balanced
Comment on lines
+409
to
416
| IOSEmulatorManager.prototype.endRunningApplication = async function (appId) { | ||
| const isAppRunning = await isAppRunningOnIOS(appId); | ||
| if (!isAppRunning) { | ||
| return null; | ||
| } | ||
| await testUtil_1.TestUtil.getProcessOutput("xcrun simctl terminate booted " + appId, undefined); | ||
| return null; | ||
| }; |
| if (!isAppRunning) { | ||
| return null; | ||
| } | ||
| await testUtil_1.TestUtil.getProcessOutput("xcrun simctl terminate booted " + appId, undefined); |
| */ | ||
| async function isAppRunningOnIOS(appId) { | ||
| const output = await testUtil_1.TestUtil.getProcessOutput("xcrun simctl spawn booted launchctl list", { noLogCommand: true, noLogStdOut: true, noLogStdErr: true }); | ||
| return output.includes(appId); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Why
The
beforeEachhook in the test builder swallowed every error fromprepareEmulatorForTest. A simulator or emulator in a bad state didn't fail there. It showed up later as an unrelated assertion failure somewhere else in the scenario, which sent debugging in the wrong direction.What changed
endRunningApplicationchecks whether the app is running before callingsimctl terminate, and skips terminate when it isn't.Why iOS needs the running check
Rethrowing alone would break every scenario.
simctl terminateexits non-zero when the app isn't running, and the app is never running before a scenario's first test.Terminate's own failure can't tell "app not running" apart from "simulator broken". On Xcode 26.6 / iOS 26.5 it prints
found nothing to terminatewith the same exit code whether the app was never installed or is just idle.simctl appinfo,get_app_containerandlistappsdon't help either. They only report whether the app is installed, and their output doesn't change while it runs.So the check asks launchd instead.
simctl spawn booted launchctl listshows a running app asUIKitApplication:<bundle id>with a live pid. Any failure from terminate itself still propagates.Why Android has no equivalent
am force-stopexits 0 whether or not the app is installed or running (checked against an emulator), andpm clearalready has an existence check. A guard there would only add an adb round-trip per test.Verification
Ran end to end against a live simulator and emulator for three cases: installed but idle, never installed, and running.
🤖 Generated with Claude Code