diff --git a/CLAUDE.md b/CLAUDE.md index 1e3d54df..63b1880d 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -56,7 +56,6 @@ React Native CodePush is a native module that enables over-the-air updates for R - For the fast local loop: run `test:setup:ios` once per template/dependency change, then re-run `test:fast:ios` repeatedly while iterating on test/scenario code — this skips `pod install` and re-provisioning on every iteration. - There's still no "just build, no tests" npm script — for a raw build only, lift the `xcodebuild` invocation out of `RNIOS.buildApp` in `test/test.ts` and run it by hand against the provisioned `TestCodePush.xcworkspace`. - When debugging a CI failure, don't trust the first plausible-looking theory from log noise — reproduce the exact failing command locally on matching hardware/toolchain before writing up a root cause. This is faster than iterating against multi-hour CI runs and catches wrong hypotheses early. -- Before running `npm run test:setup:ios`, shut down all booted simulators (`xcrun simctl shutdown all`) — the test framework's simulator picker hangs silently (no error) if simulators are already booted outside it. - `npm run test:setup:ios` provisions a full test app outside the repo (under a system temp/`test-run` dir), not inside `test/` — expect to search for it rather than finding it checked into the repo tree. - The provisioned test app's `node_modules/@bitrise/code-push-sdk` is a real copy, not a symlink — editing `ios/` (or `android/`) native source in the repo has zero effect on `test:fast:ios` runs until you re-copy those files into that `node_modules` path (or rerun `test:setup:ios`). diff --git a/code-push-plugin-testing-framework/script/platform.js b/code-push-plugin-testing-framework/script/platform.js index 56bd16af..ec297b4f 100644 --- a/code-push-plugin-testing-framework/script/platform.js +++ b/code-push-plugin-testing-framework/script/platform.js @@ -347,36 +347,27 @@ var IOSEmulatorManager = (function () { /** * Returns the target emulator, which is specified through the command line. */ - IOSEmulatorManager.prototype.getTargetEmulator = function () { - let _this = this; - if (this.targetEmulator) - return Q(this.targetEmulator); - else { - let deferred = Q.defer(); - let targetIOSEmulator = process.env.IOS_EMU; - if (!targetIOSEmulator) { - // If no iOS simulator is specified, get the most recent iOS simulator to run tests on. - testUtil_1.TestUtil.getProcessOutput("xcrun simctl list", { noLogCommand: true, noLogStdOut: true, noLogStdErr: true }) - .then((listOfDevicesWithDevicePairs) => { - let listOfDevices = listOfDevicesWithDevicePairs.slice(listOfDevicesWithDevicePairs.indexOf("-- iOS"), listOfDevicesWithDevicePairs.indexOf("-- tvOS")); - let phoneDevice = /iPhone\ \S*\ ?.*?\(([0-9A-Z-]*)\)/g; - let match = phoneDevice.exec(listOfDevices); - deferred.resolve(match[1]); - }, (error) => { - deferred.reject(error); - }); - } - else { - // Use the simulator specified on the command line. - deferred.resolve(targetIOSEmulator); + IOSEmulatorManager.prototype.getTargetEmulator = async function () { + if (this.targetEmulator) { + return this.targetEmulator; + } + let targetEmulator = process.env.IOS_EMU; + if (!targetEmulator) { + try { + const bootedUdid = await testUtil_1.TestUtil.getProcessOutput("xcrun simctl getenv booted SIMULATOR_UDID", { noLogCommand: true, noLogStdOut: true, noLogStdErr: true }); + targetEmulator = bootedUdid.trim(); + } catch { + // No simulator is currently booted - fall back to the most recent iOS simulator. + const listOfDevicesWithDevicePairs = await testUtil_1.TestUtil.getProcessOutput("xcrun simctl list", { noLogCommand: true, noLogStdOut: true, noLogStdErr: true }); + const listOfDevices = listOfDevicesWithDevicePairs.slice(listOfDevicesWithDevicePairs.indexOf("-- iOS"), listOfDevicesWithDevicePairs.indexOf("-- tvOS")); + const phoneDevice = /iPhone\ \S*\ ?.*?\(([0-9A-Z-]*)\)/g; + const match = phoneDevice.exec(listOfDevices); + targetEmulator = match[1]; } - return deferred.promise - .then((targetEmulator) => { - _this.targetEmulator = targetEmulator; - console.log("Using iOS simulator named " + _this.targetEmulator); - return _this.targetEmulator; - }); } + this.targetEmulator = targetEmulator; + console.log("Using iOS simulator named " + this.targetEmulator); + return this.targetEmulator; }; /** * Boots the target emulator.