Skip to content

Consolidate integration tests to single emulator/simulator sessions - #24

Merged
jappeace merged 8 commits into
jappeace:masterfrom
jappeace-sloth:consolidate-emulator-tests
Apr 6, 2026
Merged

jappeace merged 8 commits into
jappeace:masterfrom
jappeace-sloth:consolidate-emulator-tests

Conversation

@jappeace-sloth

Copy link
Copy Markdown

Summary

  • Add nix/emulator-all.nix: single Android emulator boot covering lifecycle + UI rendering + two-button sequence + scroll demo (Phase 1 & 2). Generates /bin/test-all.
  • Add nix/simulator-all.nix: single iOS simulator boot covering the same suites. Generates /bin/test-all-ios.
  • Update nix/ci.nix: replace 8 individual test attrs with emulator-all-test + ios; rename old ios to ios-lib for artifact upload.
  • Update .github/workflows/ci.yaml: collapse 4 jobs into 2 (android, ios) each running nix-build nix/ci.nix. Old per-suite .nix files kept for local debugging.

Motivation

Previously each integration test booted its own emulator/simulator (4× per platform), incurring 3–15 min overhead per boot cycle. This consolidation halves the number of CI jobs and reduces total boot time from ~4× to ~1× per platform.

Test plan

  • nix-build nix/ci.nix passes on Linux (builds + runs emulator-all-test)
  • nix-build nix/ci.nix -A ios passes on macOS (builds + runs simulator-all-test)
  • CI green on this PR

🤖 Generated with Claude Code

jappeace-sloth and others added 8 commits April 6, 2026 11:22
Previously each integration test (lifecycle, UI, buttons, scroll) booted its
own emulator or simulator, creating 4 separate boot/teardown cycles per
platform with 3-15 minutes overhead each.

Changes:
- Add nix/emulator-all.nix: single Android emulator session covering
  lifecycle + UI rendering + two-button sequence + scroll demo in one boot
  cycle. Generates /bin/test-all.
- Add nix/simulator-all.nix: single iOS simulator session covering all
  the same suites. Generates /bin/test-all-ios.
- nix/ci.nix: replace 8 individual emulator/simulator test attrs with
  emulator-all-test (Android) and ios (simulator-all). Rename old ios
  attr to ios-lib for artifact upload.
- .github/workflows/ci.yaml: collapse 4 jobs (android, ios,
  android-ui-buttons, ios-ui-buttons) into 2 jobs running nix-build
  nix/ci.nix. Old per-suite nix files are kept for local debugging.

Prompt: Implement the plan to consolidate integration tests to single emulator/simulator sessions.
Tokens: ~18k input, ~8k output.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
runTest uses __noChroot = true which is forbidden when sandbox = true on
GitHub Actions runners. The existing tests always ran scripts manually
outside nix (nix-build ... -o result && ./result/bin/script). Match that
same pattern for the consolidated tests.

Changes:
- nix/ci.nix: remove runTest wrapper; expose emulator-all and
  simulator-all as plain build-script derivations
- .github/workflows/ci.yaml: explicit per-attr nix-builds + manual
  script execution for both android and ios jobs

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace stream log polling for 'Click dispatched: callbackId=0' with
a sleep-then-log-show approach. The --autotest auto-tap fires 3s after
render; we now wait 15s (generous buffer) then read from the persistent
OS log store via 'xcrun simctl spawn ... log show --start PHASE2_START'.

This mirrors Phase 1c's successful log show pattern and avoids the
stream log buffering issue that caused the Phase 2 failure in CI run
24030949525.

Prompt: continue fixing iOS Phase 2 scroll click detection failure
Tokens: ~12k

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace 400+ lines of inline Nix test bash with plain scripts that assume a
running emulator/simulator and receive env vars from the harness. Each script
covers one suite (lifecycle, ui, buttons, scroll) and can be read/edited without
Nix knowledge or run in isolation.

Changes:
- test/android/helpers.sh: install_apk, wait_for_logcat, tap_button, assert_logcat
- test/android/lifecycle.sh, ui.sh, buttons.sh, scroll.sh: suite scripts
- test/ios/helpers.sh: wait_for_log, assert_log, get_full_log
- test/ios/lifecycle.sh, ui.sh, buttons.sh, scroll.sh: suite scripts
- nix/emulator-all.nix: add testScripts binding, replace inline phases with 4 bash invocations
- nix/simulator-all.nix: same for iOS
- nix/lib.nix: remove mkEmulatorTest/mkSimulatorTest (superseded), remove emulator infra
- Delete nix/emulator{,-ui,-ui-buttons,-scroll}.nix and nix/simulator{,-ui,-ui-buttons,-scroll}.nix

Prompt: Extract test logic into bash scripts, Nix as harness (Option A)
Tokens: ~80k

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The fixed 15s sleep after detecting setRoot wasn't always long enough for
'Click dispatched' to appear in the persistent log store. Replace with an
active poll (up to 30s) for 'Click dispatched' in the stream log, followed
by a 5s buffer before retrieving the persistent log. This matches how the
buttons test already polls for its terminal event.

Tokens: ~5k

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Android: nix-build nix/ci.nix (builds all Linux attrs)
iOS: nix-build nix/ci.nix -A simulator-all -A ios-lib

Removes the separate build+run steps for emulator/simulator tests.

Tokens: ~2k

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Android: nix-build ci.nix, then nix-build -A emulator-all -o result && run
iOS: nix-build -A simulator-all -A ios-lib, then nix-build -A simulator-all -o result && run
The second nix-build is instant since the store entry is already cached.

Tokens: ~2k

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The --autotest flag calls HaskellBridge.onUIEvent(0) directly, bypassing
the ObjC IOSBridgeHandler.handleTap: method where 'Click dispatched' was
logged. Add os_log in HaskellBridge.onUIEvent so the message is emitted
for both --autotest and physical UIButton taps.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jappeace
jappeace merged commit b1d4a9e into jappeace:master Apr 6, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants