From a1c83572b4f84ddbcbf916fc970b88718f8a204b Mon Sep 17 00:00:00 2001 From: Eduardo Speroni Date: Fri, 30 Oct 2026 15:36:15 -0300 Subject: [PATCH 01/12] fix(build): build libffi for arm64 Mac Catalyst build_libffi.sh had no arm64-maccatalyst slice, so the Catalyst framework's -lffi found no archive and the linker fell back to the macOS SDK's libffi.tbd: the shipped Catalyst slice links Apple's /usr/lib/libffi.dylib while the runtime compiles against our fork's headers (vector types and the fork's closure layout included). arm64 macabi has no deployment target below 14.0, so the slice gets its own minimum. --- NativeScript/lib/arm64-maccatalyst/libffi.a | Bin 0 -> 57424 bytes build_libffi.sh | 6 ++++++ 2 files changed, 6 insertions(+) create mode 100644 NativeScript/lib/arm64-maccatalyst/libffi.a diff --git a/NativeScript/lib/arm64-maccatalyst/libffi.a b/NativeScript/lib/arm64-maccatalyst/libffi.a new file mode 100644 index 0000000000000000000000000000000000000000..ab876e2f8be6389272712e4012b51ba0e2761d7b GIT binary patch literal 57424 zcmeHwe|%KOb?@B0E9tI4AjC=t8LS19L?Xx$AVBUzWpkP~GJGNW(YApnkwL(9^ z$T%OCh}Z%-t%PZUNgCwfv|0sPzeMyS61&L3b!D445IZif&y58pej)b7t-`XSuhfy7t!8n-+d)QK2gm7B0JG@#5me zMYn*sq;Me^276&);nJcamuunDr6PJ&s;=LB_x)d4ecP8^ci&OrxotH=IHllG8QZ^- zv0^)8qkm3R#)gs^%M>tQz}p4?egXeoq+0{X7BTi00yYT#cR_BN#@LSpTp{HAtH93) zc+`fMFEI8C0nZ8ek$_(n>1qUgU*xMHA1e1YLEj_bTtS~o<$>J!0sc(6v~($?NogJLu^`D(W5 z8ydGf=o4b27#n?!-Zn!}6y4Xjc~e}XI6`ddgsGYu>o&JVm8unlg^P+!*>cL#7{cO3 zF@&W>F$A-SEpb9Q#VnKvQ9_9jC6owep<5g4HW+#GZfx;BEc+=jRS#=cQ(KF-rN!H> zw>9cWW<=-dp?(o8(%ZyCT$#>@@{o6{H%y8W#W~UP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j~3!Iy}CUAbn+Q7TH>jEKF z?Q!9o-b2$@1_IORTWQvFPMzKV{C0N$V?KRXI?MP$y1lEH<-SRNJNb}*ZU>e;GhW5m z*du~Q{3<&OY!x{Bn(K{LQ+&c3WAOSId{YcwZNj;H*zA8PXa>&G9x&r}R&cKw$G)J# zjKjuXABD5DwPxJT8oq4Cv1eFi!mB6yOU(6uP>aS<|09^U!~V)D20x_<$B*;eO>IUp zu-=B-l5naITOQ%hOTZsd*?gIve6F%A;qGONyW(5^7sxDv4$etuUGISI5_(AOv)xoC!mF^?lKRGRyF1V#;*h?X z%loI|B)@vH`*|so@CUVMyvpt_h|)LgP0jj-^y4wWbFtMHR$Ev)VCjIR1C|b0I$-I5r301@SUO42pJmJV1t zVCjIR1C|b0I$-I5r301@SUO42pJmJV1tVCjIR1C|b0I$-I5r301@ zSUO42pJmJV1tVCjIR1C|b0I$-I5r33%(bs(KxNuRdL9bh)&yL=0` z+QZTZYdl!kt;RDb;)-%0?v!rZ-_HHs9EyZM@qBo?MLbcSNIZ49 zZ3_F3U!O-gQy437Bd)?&vP(b!jyC}!%8dl^f6h-S6F9*n;FLe{38Jy4d<}341j+C) z;nWs>gVIbmB323fPT;ww_`1MlJ1!TvZ1 Date: Fri, 30 Oct 2026 15:36:15 -0300 Subject: [PATCH 02/12] fix(metadata-generator): resolve the deployment target in Catalyst builds Xcode does not export IPHONEOS_DEPLOYMENT_TARGET to Mac Catalyst script phases, so the fallback raised KeyError and, since the phase does not fail the build, left a 0-byte metadata file. Fall back to LLVM_TARGET_TRIPLE_OS_VERSION, which Catalyst builds always carry. --- metadata-generator/build-step-metadata-generator.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/metadata-generator/build-step-metadata-generator.py b/metadata-generator/build-step-metadata-generator.py index a35054ec3..230d90be5 100755 --- a/metadata-generator/build-step-metadata-generator.py +++ b/metadata-generator/build-step-metadata-generator.py @@ -87,9 +87,11 @@ def map_and_list(func, iterable): src_root = env("SRCROOT") deployment_target_flag_name = env_or_empty("DEPLOYMENT_TARGET_CLANG_FLAG_NAME") or default_deployment_target_flag_name # Xcode does not export MACCATALYST_DEPLOYMENT_TARGET unless the project sets it, -# so fall back to the iOS deployment target rather than dying with a KeyError. +# and may not export IPHONEOS_DEPLOYMENT_TARGET to Catalyst script phases either; +# LLVM_TARGET_TRIPLE_OS_VERSION (e.g. "ios13.1") always carries the iOS version. deployment_target = env_or_none(env_or_empty("DEPLOYMENT_TARGET_CLANG_ENV_NAME") or default_deployment_target_clang_env_name) \ - or env("IPHONEOS_DEPLOYMENT_TARGET") + or env_or_none("IPHONEOS_DEPLOYMENT_TARGET") \ + or env_or_empty("LLVM_TARGET_TRIPLE_OS_VERSION").lstrip("abcdefghijklmnopqrstuvwxyz") std = env("GCC_C_LANGUAGE_STANDARD") header_search_paths = env_or_empty("HEADER_SEARCH_PATHS") header_search_paths_parsed = map_and_list((lambda s: "-I" + s), shlex.split(header_search_paths)) From 478c9eb4286c5ae68664919fe762dc76e35ec332 Mon Sep 17 00:00:00 2001 From: Eduardo Speroni Date: Fri, 30 Oct 2026 15:36:15 -0300 Subject: [PATCH 03/12] feat(runtime): run V8's JIT on Mac Catalyst when the process may map JIT memory Catalyst V8 now ships with Sparkplug, Maglev and TurboFan. A hardened runtime process may only map JIT memory with com.apple.security.cs.allow-jit (or allow-unsigned-executable-memory), and V8 does not fall back on its own, so before V8::Initialize the runtime probes an mmap(MAP_JIT) allocation and passes --jitless when it fails. `"ios": { "jit": false }` in the app's package.json forces the interpreter. iOS is unchanged: its V8 is lite mode, which implies --jitless. --- NativeScript/runtime/Runtime.mm | 51 +++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/NativeScript/runtime/Runtime.mm b/NativeScript/runtime/Runtime.mm index 26b0236a5..58da09427 100644 --- a/NativeScript/runtime/Runtime.mm +++ b/NativeScript/runtime/Runtime.mm @@ -32,9 +32,14 @@ #include "IsolateWrapper.h" +#include #include #include #include +#if TARGET_OS_MACCATALYST +#include +#include +#endif #include "HttpLoader.h" #include "ModuleBinding.hpp" #include "ModuleInternalCallbacks.h" @@ -218,6 +223,42 @@ void DisposeIsolateWhenPossible(Isolate* isolate, int gateId) { ExternalMemory::StartMemoryPressureMonitoring(); } +#if TARGET_OS_MACCATALYST +// Mac Catalyst ships V8 with its JIT tiers, but a hardened-runtime process may +// only map JIT memory with com.apple.security.cs.allow-jit (or +// allow-unsigned-executable-memory). V8 does not fall back on its own: without +// --jitless it dies at its first code-space allocation, so ask the kernel the +// same question V8 will. +static bool CanMapJitMemory() { + const size_t size = static_cast(getpagesize()); + void* memory = mmap(nullptr, size, PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_PRIVATE | MAP_ANON | MAP_JIT, -1, 0); + if (memory == MAP_FAILED) { + return false; + } + munmap(memory, size); + return true; +} + +// `"ios": { "jit": false }` in the app's package.json forces the interpreter; +// otherwise the JIT runs whenever the process may map JIT memory. +static bool ShouldEnableJit() { + id iosConfig = Runtime::GetAppConfigValue("ios"); + id jitValue = [iosConfig isKindOfClass:[NSDictionary class]] ? iosConfig[@"jit"] : nil; + if ([jitValue isKindOfClass:[NSNumber class]] && ![jitValue boolValue]) { + return false; + } + if (CanMapJitMemory()) { + return true; + } + if (jitValue != nil) { + Log(@"NativeScript: \"ios.jit\" is set, but this process may not map JIT memory (missing " + @"the com.apple.security.cs.allow-jit entitlement?). Running without the JIT."); + } + return false; +} +#endif + Runtime::Runtime(const RuntimeOptions& options) : workerId_(options.workerId) { currentRuntime_ = this; workerCache_ = Caches::Workers; @@ -229,10 +270,14 @@ void DisposeIsolateWhenPossible(Isolate* isolate, int gateId) { // : platform::NewDefaultPlatform(); // Flags must be set before V8::Initialize(), which freezes them; changing a - // flag afterwards aborts the process. Don't pass --jitless either: - // v8_enable_lite_mode already implies it and makes the flag read-only, - // which is likewise fatal to set. + // flag afterwards aborts the process. iOS V8 is built in lite mode, which + // already implies --jitless; only Mac Catalyst decides at launch. std::string flags = RuntimeConfig.IsDebug ? "--expose_gc" : "--expose_gc --no-lazy"; +#if TARGET_OS_MACCATALYST + if (!ShouldEnableJit()) { + flags += " --jitless"; + } +#endif V8::SetFlagsFromString(flags.c_str(), flags.size()); // wrap the default platform so foreground tasks ride each runtime From 3dfb70661cf39d37bc97180c9f0f15c7e1e284ee Mon Sep 17 00:00:00 2001 From: Eduardo Speroni Date: Fri, 30 Oct 2026 15:36:17 -0300 Subject: [PATCH 04/12] test: run the suite on Mac Catalyst with the JIT TestRunner and its dependencies now build for Mac Catalyst (arm64), ad-hoc signed with hardened runtime and allow-jit like a shipped app, and `./run_tests.sh --catalyst` runs the suite on the host Mac. A CI job does the same on macos-15. CatalystJitTests asserts that V8 holds executable memory there, which it maps only with its JIT on. The UI-testing runner needs macOS Automation Mode without authentication (preconfigured on GitHub's macOS images); run_tests.sh checks for it. --- .../collect-test-diagnostics/action.yml | 16 ++++ .github/workflows/pull_request.yml | 57 ++++++++++++ TestFixtures/Functions/TNSFunctions.h | 4 + TestFixtures/Functions/TNSFunctions.m | 19 ++++ TestFixtures/NapiCoverageModule.mm | 4 +- TestFixtures/exported-symbols.txt | 1 + TestRunner/TestRunner-Catalyst.entitlements | 12 +++ TestRunner/app/tests/CatalystJitTests.js | 9 ++ TestRunner/app/tests/index.js | 3 + run_tests.sh | 87 ++++++++++++++++++- v8ios.xcodeproj/project.pbxproj | 41 +++++++-- 11 files changed, 240 insertions(+), 13 deletions(-) create mode 100644 TestRunner/TestRunner-Catalyst.entitlements create mode 100644 TestRunner/app/tests/CatalystJitTests.js diff --git a/.github/actions/collect-test-diagnostics/action.yml b/.github/actions/collect-test-diagnostics/action.yml index 49603765c..f9569678e 100644 --- a/.github/actions/collect-test-diagnostics/action.yml +++ b/.github/actions/collect-test-diagnostics/action.yml @@ -14,6 +14,11 @@ inputs: Name of the uploaded artifact. Artifact names are unique per workflow run, so jobs that can both fail in one run need distinct names. default: test-diagnostics + host-process-log: + description: > + "true" when the app ran on the host (Mac Catalyst): also save the host's + unified log for TestRunner processes. + default: "false" runs: using: composite steps: @@ -45,6 +50,17 @@ runs: else echo "No booted simulator; relying on the xcresult's captured app output." fi + if [ "${{ inputs.host-process-log }}" = "true" ]; then + echo "Collecting host unified log slice" + log show --style compact --last 45m \ + --predicate 'process CONTAINS "TestRunner"' \ + > "$DIAG/host-unified.log" 2>/dev/null & + LOG_PID=$! + ( sleep 120 && kill -9 "$LOG_PID" ) 2>/dev/null & + KILLER_PID=$! + wait "$LOG_PID" || echo "log show failed or was killed after 120s" + kill "$KILLER_PID" 2>/dev/null || true + fi echo "Collected diagnostics:" du -sh "$DIAG"/* 2>/dev/null || true - name: Upload test diagnostics diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 48d14c481..07e58e5c5 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -190,3 +190,60 @@ jobs: path: | ${{env.TEST_FOLDER}}/test_results.xcresult ${{env.TEST_FOLDER}}/test_results_attempt1.xcresult + test-catalyst: + name: Test (Mac Catalyst) + runs-on: macos-15 + needs: build + steps: + - uses: maxim-lobanov/setup-xcode@ed7a3b1fda3918c0306d1b724322adc0b8cc0a90 # v1.7.0 + with: + xcode-version: ${{env.XCODE_VERSION}} + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + submodules: true + persist-credentials: false # disable to prevent leaking credentials to build scripts + - name: LLVM cache + uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: ./llvm + key: ${{ hashFiles('download_llvm.sh') }} + - uses: ./.github/actions/setup-build-env + with: + install-test-tools: "true" + - name: Prepare test folder + run: echo TEST_FOLDER=$(pwd)/build/tests/catalyst >> $GITHUB_ENV + - name: Xcode Tests + uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4.0.0 + with: + timeout_minutes: 40 + max_attempts: 2 + command: ./run_tests.sh --catalyst + # run_tests.sh empties its results folder, so move the failed + # attempt's bundle out of it first. + on_retry_command: rm -rf $TEST_FOLDER-attempt1; mv $TEST_FOLDER $TEST_FOLDER-attempt1 2>/dev/null || true + - name: Test report summary + if: ${{ !cancelled() }} + uses: mikepenz/action-junit-report@a9170d5795813c01ab4901ffb045b52bab4ab09d # v6.5.0 + with: + report_paths: build/tests/catalyst/test-out/*junit*.xml + annotate_only: true + detailed_summary: true + - name: Validate Test Results + run: | + find $TEST_FOLDER/test-out -name "*junit*.xml" -maxdepth 1 -print0 | xargs -n 1 -0 npx junit-cli-report-viewer + find $TEST_FOLDER/test-out -name "*junit*.xml" -maxdepth 1 -print0 | xargs -n 1 -0 npx verify-junit-xml + - name: Collect test diagnostics + if: failure() + uses: ./.github/actions/collect-test-diagnostics + with: + test-folder: ${{env.TEST_FOLDER}} + artifact-name: test-diagnostics-catalyst + host-process-log: "true" + - name: Archive Test Result Data + if: always() + uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 + with: + name: test-results-catalyst + path: | + ${{env.TEST_FOLDER}}/test_results.xcresult + ${{env.TEST_FOLDER}}-attempt1/test_results.xcresult diff --git a/TestFixtures/Functions/TNSFunctions.h b/TestFixtures/Functions/TNSFunctions.h index dba6339d8..1282453c3 100644 --- a/TestFixtures/Functions/TNSFunctions.h +++ b/TestFixtures/Functions/TNSFunctions.h @@ -3,3 +3,7 @@ CFArrayRef CFArrayCreateWithString(CFStringRef string); // Declared for the metadata generator but intentionally left undefined, so the // symbol is listed in metadata yet absent at runtime. void TNSFunctionMissingAtRuntime(void); + +// Whether the process holds executable memory carrying V8's VM tag (255). +// V8 maps executable memory only when its JIT is on. +bool TNSHasExecutableV8Memory(void); diff --git a/TestFixtures/Functions/TNSFunctions.m b/TestFixtures/Functions/TNSFunctions.m index 0977578ab..c2a639a3d 100644 --- a/TestFixtures/Functions/TNSFunctions.m +++ b/TestFixtures/Functions/TNSFunctions.m @@ -1,4 +1,23 @@ #import "TNSFunctions.h" +#include + +bool TNSHasExecutableV8Memory(void) { + vm_address_t address = 0; + for (;;) { + vm_size_t size = 0; + natural_t depth = 0; + struct vm_region_submap_info_64 info; + mach_msg_type_number_t count = VM_REGION_SUBMAP_INFO_COUNT_64; + if (vm_region_recurse_64(mach_task_self(), &address, &size, &depth, + (vm_region_recurse_info_t)&info, &count) != KERN_SUCCESS) { + return false; + } + if (info.user_tag == 255 && (info.protection & VM_PROT_EXECUTE)) { + return true; + } + address += size; + } +} CFArrayRef CFArrayCreateWithString(CFStringRef string) { const void* values[] = { string }; diff --git a/TestFixtures/NapiCoverageModule.mm b/TestFixtures/NapiCoverageModule.mm index 0b9b0be01..36f2a85c2 100644 --- a/TestFixtures/NapiCoverageModule.mm +++ b/TestFixtures/NapiCoverageModule.mm @@ -176,7 +176,7 @@ static napi_value StringStatus(napi_env env, napi_callback_info info) { //=== Numbers ============================================================== -static napi_value NumberParts(napi_env env, napi_callback_info info) { +static napi_value NumberPartsMethod(napi_env env, napi_callback_info info) { size_t argc = 1; napi_value args[1]; NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL)); @@ -1365,7 +1365,7 @@ static napi_value InitNapiCoverageModule(napi_env env, napi_value exports) { NAPI_METHOD("createStrings", CreateStrings), NAPI_METHOD("createExternalLatin1", CreateExternalLatin1), NAPI_METHOD("stringStatus", StringStatus), - NAPI_METHOD("numberParts", NumberParts), + NAPI_METHOD("numberParts", NumberPartsMethod), NAPI_METHOD("createNumbers", CreateNumbers), NAPI_METHOD("numberStatus", NumberStatus), NAPI_METHOD("createSymbol", CreateSymbol), diff --git a/TestFixtures/exported-symbols.txt b/TestFixtures/exported-symbols.txt index 8b21d395d..63d355dfd 100644 --- a/TestFixtures/exported-symbols.txt +++ b/TestFixtures/exported-symbols.txt @@ -1,4 +1,5 @@ _CFArrayCreateWithString +_TNSHasExecutableV8Memory _functionExplicitCreateNSObject _functionImplicitCreate _functionReturningFunctionPtrAsVoidPtr diff --git a/TestRunner/TestRunner-Catalyst.entitlements b/TestRunner/TestRunner-Catalyst.entitlements new file mode 100644 index 000000000..005a379fb --- /dev/null +++ b/TestRunner/TestRunner-Catalyst.entitlements @@ -0,0 +1,12 @@ + + + + + com.apple.security.cs.allow-jit + + + com.apple.security.cs.disable-library-validation + + + diff --git a/TestRunner/app/tests/CatalystJitTests.js b/TestRunner/app/tests/CatalystJitTests.js new file mode 100644 index 000000000..aa4caaf1d --- /dev/null +++ b/TestRunner/app/tests/CatalystJitTests.js @@ -0,0 +1,9 @@ +// TestRunner's Catalyst build is signed with com.apple.security.cs.allow-jit, +// so the runtime must leave V8's JIT on there. +if (NSProcessInfo.processInfo.macCatalystApp) { + describe("Mac Catalyst JIT", function () { + it("runs V8 with its JIT when the process may map JIT memory", function () { + expect(TNSHasExecutableV8Memory()).toBe(true); + }); + }); +} diff --git a/TestRunner/app/tests/index.js b/TestRunner/app/tests/index.js index 2699fc8e0..5c4f49b0f 100644 --- a/TestRunner/app/tests/index.js +++ b/TestRunner/app/tests/index.js @@ -215,6 +215,9 @@ require("./WorkerTerminateTests"); // interop.setExternalSize and the runtime's own external memory charges require("./ExternalMemoryTests"); +// The runtime's launch-time JIT decision on Mac Catalyst +require("./CatalystJitTests"); + // Tests common for all runtimes (git submodule of NativeScript/common-runtime-tests-app). require("../shared/index").runAllTests(); diff --git a/run_tests.sh b/run_tests.sh index d54644e59..e8c719adf 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -266,13 +266,17 @@ usage() { cat < Existing simulator by name (e.g. 'iPhone 16 Pro') -u, --udid Existing simulator by UDID --temp-sim Create a throwaway ${SIM_PREFIX}* simulator for this run and delete it afterwards --keep-sim Run on ${SIM_PREFIX}, creating and booting it if needed, and leave it booted for later runs + --catalyst Build TestRunner for Mac Catalyst and run the suite on this + Mac (hardened runtime, ad-hoc signed, allow-jit entitlement). + Cannot be combined with any simulator option. Only one + Catalyst run per Mac at a time: later ones wait for it. Simulator management (no tests run): --create-sim Create and boot ${SIM_PREFIX}, print its UDID, exit @@ -294,7 +298,8 @@ Run options: -t, --temp-folder Write results to a random temp folder instead of build/tests/ -h, --help Show this help -Results go to build/tests/ (one simulator can only run one suite at a time). +Results go to build/tests/ (one simulator can only run one suite at a time), +or build/tests/catalyst with --catalyst. EOF } @@ -314,6 +319,7 @@ SIM_DEVICE_TYPE="" SIM_RUNTIME="" DELETE_TARGET="" TEST_FOLDER="" +CATALYST=0 set_sim_mode() { if [ -n "$SIM_MODE" ] && [ "$SIM_MODE" != "$1" ]; then @@ -360,6 +366,7 @@ while [ $# -gt 0 ]; do set_sim_mode "delete-sim"; shift "$OPT_SHIFT" ;; --list-sims) set_sim_mode "list-sims"; shift ;; --delete-sims) set_sim_mode "delete-sims"; shift ;; + --catalyst) CATALYST=1; shift ;; -a|--asan) ASAN=1; shift ;; -t|--temp-folder) TEMP_FOLDER=1; shift ;; -h|--help) usage; exit 0 ;; @@ -367,6 +374,25 @@ while [ $# -gt 0 ]; do esac done +if [ "$CATALYST" -eq 1 ]; then + if [ -n "$SIM_MODE" ] || [ -n "$DEVICE_NAME" ] || [ -n "$DEVICE_UDID" ] || [ -n "$SIM_NAME" ] \ + || [ -n "$SIM_DEVICE_TYPE" ] || [ -n "$SIM_RUNTIME" ]; then + die_usage "--catalyst runs on this Mac and cannot be combined with simulator options." + fi + # TestRunner's Catalyst build is arm64-only (EXCLUDED_ARCHS[sdk=macosx*]). + if [ "$(uname -m)" != "arm64" ]; then + echo "--catalyst needs an Apple Silicon Mac." >&2 + exit 1 + fi + # TestRunnerTests is a UI-testing bundle; on macOS its runner must switch the + # session into Automation Mode, which otherwise asks for an admin password and + # times out unattended. GitHub's macOS runner images come preconfigured. + if ! automationmodetool 2>/dev/null | grep -q "DOES NOT REQUIRE"; then + echo "--catalyst needs Automation Mode without authentication. Enable it once with:" >&2 + echo " sudo automationmodetool enable-automationmode-without-authentication" >&2 + exit 1 + fi +fi if [ -n "$SIM_MODE" ] && { [ -n "$DEVICE_NAME" ] || [ -n "$DEVICE_UDID" ]; }; then die_usage "--$SIM_MODE cannot be combined with --device or --udid." fi @@ -402,6 +428,12 @@ for devices in json.load(sys.stdin)['devices'].values(): # always say which simulator was used and whether it still exists. finish_run() { local status=$? + if [ "$CATALYST" -eq 1 ]; then + release_catalyst_lock + [ -n "$TEST_FOLDER" ] && echo "Test folder: $TEST_FOLDER" + echo "Simulator: none (--catalyst ran on this Mac)" + exit "$status" + fi [ -n "$DEVICE_UDID" ] || exit "$status" local label disposition label=$(sim_label "$DEVICE_UDID") @@ -425,7 +457,48 @@ finish_run() { exit "$status" } +# XCUIApplication.launch() terminates any running app with the same bundle +# identifier, so concurrent Catalyst runs from different checkouts would kill +# each other's TestRunner. Serialize them per user with a mkdir lock. +CATALYST_LOCK="${TMPDIR:-/tmp}/ns-test-catalyst.lock" +CATALYST_LOCK_HELD=0 + +acquire_catalyst_lock() { + local waited=0 holder + until mkdir "$CATALYST_LOCK" 2>/dev/null; do + holder=$(cat "$CATALYST_LOCK/pid" 2>/dev/null) + if [ -n "$holder" ] && ! kill -0 "$holder" 2>/dev/null; then + echo "Removing stale Catalyst run lock (pid $holder is gone)." >&2 + rm -rf "$CATALYST_LOCK" + continue + fi + if [ "$waited" -eq 0 ]; then + echo "Another --catalyst run (pid ${holder:-unknown}) is in progress; waiting for it to finish..." >&2 + waited=1 + fi + sleep 10 + done + echo $$ > "$CATALYST_LOCK/pid" + CATALYST_LOCK_HELD=1 +} + +release_catalyst_lock() { + if [ "$CATALYST_LOCK_HELD" -eq 1 ]; then + rm -rf "$CATALYST_LOCK" + CATALYST_LOCK_HELD=0 + fi +} + +if [ "$CATALYST" -eq 1 ]; then + SIM_MODE="catalyst" +fi + case "$SIM_MODE" in + catalyst) + trap finish_run EXIT + trap 'exit 130' INT TERM + acquire_catalyst_lock + ;; list-sims) print_temp_sims exit $? @@ -466,13 +539,19 @@ esac trap finish_run EXIT trap 'exit 130' INT TERM -DESTINATION="platform=iOS Simulator,id=$DEVICE_UDID" +if [ "$CATALYST" -eq 1 ]; then + DESTINATION="platform=macOS,variant=Mac Catalyst,arch=arm64" + RESULTS_NAME="catalyst" +else + DESTINATION="platform=iOS Simulator,id=$DEVICE_UDID" + RESULTS_NAME="$DEVICE_UDID" +fi mkdir -p "$TESTS_ROOT" if [ "$TEMP_FOLDER" -eq 1 ]; then TEST_FOLDER=$(mktemp -d "$TESTS_ROOT/tmp.XXXXXXXX") else - TEST_FOLDER="$TESTS_ROOT/$DEVICE_UDID" + TEST_FOLDER="$TESTS_ROOT/$RESULTS_NAME" rm -rf "$TEST_FOLDER" mkdir -p "$TEST_FOLDER" fi diff --git a/v8ios.xcodeproj/project.pbxproj b/v8ios.xcodeproj/project.pbxproj index 74d96f196..a58fa4a59 100644 --- a/v8ios.xcodeproj/project.pbxproj +++ b/v8ios.xcodeproj/project.pbxproj @@ -78,8 +78,8 @@ C22536B6241A318900192740 /* ffi.h in Headers */ = {isa = PBXBuildFile; fileRef = C22536B1241A318900192740 /* ffi.h */; }; C22536B7241A318900192740 /* ffitarget.h in Headers */ = {isa = PBXBuildFile; fileRef = C22536B3241A318900192740 /* ffitarget.h */; }; C22536B8241A318900192740 /* ffi.h in Headers */ = {isa = PBXBuildFile; fileRef = C22536B4241A318900192740 /* ffi.h */; }; - C2253789241A41C500192740 /* TKLiveSync.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C2253782241A41C500192740 /* TKLiveSync.framework */; platformFilters = (ios, xros, ); }; - C225378A241A41C500192740 /* TKLiveSync.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = C2253782241A41C500192740 /* TKLiveSync.framework */; platformFilters = (ios, xros, ); settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + C2253789241A41C500192740 /* TKLiveSync.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C2253782241A41C500192740 /* TKLiveSync.framework */; platformFilters = (ios, maccatalyst, xros, ); }; + C225378A241A41C500192740 /* TKLiveSync.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = C2253782241A41C500192740 /* TKLiveSync.framework */; platformFilters = (ios, maccatalyst, xros, ); settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; C2253790241A421E00192740 /* zip_fopen_index_encrypted.c in Sources */ = {isa = PBXBuildFile; fileRef = C2A5E05A2328CA6F00A91A76 /* zip_fopen_index_encrypted.c */; }; C2253791241A422400192740 /* zip_get_num_entries.c in Sources */ = {isa = PBXBuildFile; fileRef = C2A5E0422328CA6F00A91A76 /* zip_get_num_entries.c */; }; C2253805241A5C3200192740 /* zip_get_encryption_implementation.c in Sources */ = {isa = PBXBuildFile; fileRef = C2A5E0302328CA6F00A91A76 /* zip_get_encryption_implementation.c */; }; @@ -254,8 +254,8 @@ C2A6EF3123745A0B00E8FBE7 /* MetadataInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = C2A6EF3023745A0B00E8FBE7 /* MetadataInlines.h */; }; C2C8EE7222CE323C001F8CEC /* ConcurrentMap.h in Headers */ = {isa = PBXBuildFile; fileRef = C2C8EE7022CE323C001F8CEC /* ConcurrentMap.h */; }; C2C8EE7422CE3266001F8CEC /* ConcurrentQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C2C8EE7322CE3266001F8CEC /* ConcurrentQueue.cpp */; }; - C2C8EE7522CE54EE001F8CEC /* NativeScript.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C2DDEB32229EAB3B00345BFE /* NativeScript.framework */; platformFilters = (ios, xros, ); }; - C2C8EE7622CE54EE001F8CEC /* NativeScript.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = C2DDEB32229EAB3B00345BFE /* NativeScript.framework */; platformFilters = (ios, xros, ); settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + C2C8EE7522CE54EE001F8CEC /* NativeScript.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C2DDEB32229EAB3B00345BFE /* NativeScript.framework */; platformFilters = (ios, maccatalyst, xros, ); }; + C2C8EE7622CE54EE001F8CEC /* NativeScript.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = C2DDEB32229EAB3B00345BFE /* NativeScript.framework */; platformFilters = (ios, maccatalyst, xros, ); settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; C2C8EE7A22CF64E4001F8CEC /* SimpleAllocator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C2C8EE7822CF64E4001F8CEC /* SimpleAllocator.cpp */; }; C2C8EE7B22CF64E4001F8CEC /* SimpleAllocator.h in Headers */ = {isa = PBXBuildFile; fileRef = C2C8EE7922CF64E4001F8CEC /* SimpleAllocator.h */; }; C2CC8EEA22BBA01E00B78928 /* FastEnumerationAdapter.mm in Sources */ = {isa = PBXBuildFile; fileRef = C2CC8EE822BBA01E00B78928 /* FastEnumerationAdapter.mm */; }; @@ -2165,7 +2165,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "cd ${PROJECT_DIR}/metadata-generator/build/bin\ncp ../../build-step-metadata-generator.py .\n./build-step-metadata-generator.py\n\n# create temporary empty metadata files for XCode LD/LDPLUSPLUS flag analysis\nfor arch in $VALID_ARCHS\ndo :\n echo \"creating empty $CONFIGURATION_BUILD_DIR/metadata-$arch.bin\"\n touch \"$CONFIGURATION_BUILD_DIR/metadata-$arch.bin\"\ndone\n"; + shellScript = "set -e\ncd ${PROJECT_DIR}/metadata-generator/build/bin\ncp ../../build-step-metadata-generator.py .\n./build-step-metadata-generator.py\n\n# create temporary empty metadata files for XCode LD/LDPLUSPLUS flag analysis\nfor arch in $VALID_ARCHS\ndo :\n echo \"creating empty $CONFIGURATION_BUILD_DIR/metadata-$arch.bin\"\n touch \"$CONFIGURATION_BUILD_DIR/metadata-$arch.bin\"\ndone\n"; }; /* End PBXShellScriptBuildPhase section */ @@ -2456,6 +2456,7 @@ isa = PBXTargetDependency; platformFilters = ( ios, + maccatalyst, xros, ); target = C2253781241A41C500192740 /* TKLiveSync */; @@ -2465,6 +2466,7 @@ isa = PBXTargetDependency; platformFilters = ( ios, + maccatalyst, xros, ); target = C2DDEB31229EAB3B00345BFE /* NativeScript */; @@ -2490,6 +2492,7 @@ isa = PBXTargetDependency; platformFilters = ( ios, + maccatalyst, xros, ); target = C29374E1229FC0F60075CB16 /* TestFixtures */; @@ -2588,7 +2591,9 @@ SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator"; ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO; CLANG_ENABLE_MODULES = NO; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "-"; CODE_SIGN_STYLE = Automatic; + "ENABLE_HARDENED_RUNTIME[sdk=macosx*]" = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)", @@ -2599,12 +2604,15 @@ "$(inherited)", "@executable_path/Frameworks", ); + MACOSX_DEPLOYMENT_TARGET = 10.15; PRODUCT_BUNDLE_IDENTIFIER = org.nativescript.TestRunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTS_MACCATALYST = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = 1; + "TARGETED_DEVICE_FAMILY[sdk=macosx*]" = 2; TEST_TARGET_NAME = TestRunner; }; name = Debug; @@ -2615,7 +2623,9 @@ SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator"; ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO; CLANG_ENABLE_MODULES = NO; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "-"; CODE_SIGN_STYLE = Automatic; + "ENABLE_HARDENED_RUNTIME[sdk=macosx*]" = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)", @@ -2626,12 +2636,15 @@ "$(inherited)", "@executable_path/Frameworks", ); + MACOSX_DEPLOYMENT_TARGET = 10.15; PRODUCT_BUNDLE_IDENTIFIER = org.nativescript.TestRunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTS_MACCATALYST = YES; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-O"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = 1; + "TARGETED_DEVICE_FAMILY[sdk=macosx*]" = 2; TEST_TARGET_NAME = TestRunner; }; name = Release; @@ -2850,6 +2863,7 @@ OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; + SUPPORTS_MACCATALYST = YES; SYMROOT = build; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -2873,6 +2887,7 @@ OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; + SUPPORTS_MACCATALYST = YES; SYMROOT = build; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -2884,10 +2899,15 @@ CLANG_CXX_LANGUAGE_STANDARD = "c++20"; CLANG_CXX_LIBRARY = "compiler-default"; CLANG_ENABLE_MODULES = NO; + "CODE_SIGN_ENTITLEMENTS[sdk=macosx*]" = "TestRunner/TestRunner-Catalyst.entitlements"; CODE_SIGN_IDENTITY = "Apple Development"; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "-"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = CS838V553Y; + "DEVELOPMENT_TEAM[sdk=macosx*]" = ""; + "ENABLE_HARDENED_RUNTIME[sdk=macosx*]" = YES; EXCLUDED_ARCHS = ""; + "EXCLUDED_ARCHS[sdk=macosx*]" = x86_64; EXPORTED_SYMBOLS_FILE = "$(PROJECT_DIR)/TestFixtures/exported-symbols.txt"; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; GCC_C_LANGUAGE_STANDARD = gnu99; @@ -2926,10 +2946,11 @@ SDKROOT = iphoneos; STRIPFLAGS = "-s $(PROJECT_DIR)/TestFixtures/exported-symbols.txt"; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator"; - SUPPORTS_MACCATALYST = NO; + SUPPORTS_MACCATALYST = YES; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO; TARGETED_DEVICE_FAMILY = "1,7"; + "TARGETED_DEVICE_FAMILY[sdk=macosx*]" = 2; USER_HEADER_SEARCH_PATHS = ""; }; name = Debug; @@ -2940,10 +2961,15 @@ CLANG_CXX_LANGUAGE_STANDARD = "c++20"; CLANG_CXX_LIBRARY = "compiler-default"; CLANG_ENABLE_MODULES = NO; + "CODE_SIGN_ENTITLEMENTS[sdk=macosx*]" = "TestRunner/TestRunner-Catalyst.entitlements"; CODE_SIGN_IDENTITY = "Apple Development"; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "-"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 8V7T28DG39; + "DEVELOPMENT_TEAM[sdk=macosx*]" = ""; + "ENABLE_HARDENED_RUNTIME[sdk=macosx*]" = YES; EXCLUDED_ARCHS = ""; + "EXCLUDED_ARCHS[sdk=macosx*]" = x86_64; EXPORTED_SYMBOLS_FILE = "$(PROJECT_DIR)/TestFixtures/exported-symbols.txt"; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; GCC_C_LANGUAGE_STANDARD = gnu99; @@ -2982,10 +3008,11 @@ SDKROOT = iphoneos; STRIPFLAGS = "-s $(PROJECT_DIR)/TestFixtures/exported-symbols.txt"; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator"; - SUPPORTS_MACCATALYST = NO; + SUPPORTS_MACCATALYST = YES; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO; TARGETED_DEVICE_FAMILY = "1,7"; + "TARGETED_DEVICE_FAMILY[sdk=macosx*]" = 2; USER_HEADER_SEARCH_PATHS = ""; }; name = Release; From 73f7df801381e6c0c1c58167018ab0cf6926d99a Mon Sep 17 00:00:00 2001 From: Eduardo Speroni Date: Sun, 1 Nov 2026 17:20:28 -0300 Subject: [PATCH 05/12] feat(template): grant Catalyst apps allow-jit instead of unsigned executable memory Only V8's JIT needs an executable-memory exception, and allow-jit covers it (MAP_JIT under the hardened runtime). allow-unsigned-executable-memory is a broader exception nothing else uses: libffi closures come from signed trampoline pages and work under the hardened runtime with no entitlement. --- .../__PROJECT_NAME__/__PROJECT_NAME__.entitlements | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project-template-ios/__PROJECT_NAME__/__PROJECT_NAME__.entitlements b/project-template-ios/__PROJECT_NAME__/__PROJECT_NAME__.entitlements index f9105be8a..b79f6de0a 100644 --- a/project-template-ios/__PROJECT_NAME__/__PROJECT_NAME__.entitlements +++ b/project-template-ios/__PROJECT_NAME__/__PROJECT_NAME__.entitlements @@ -4,7 +4,7 @@ com.apple.security.app-sandbox - com.apple.security.cs.allow-unsigned-executable-memory + com.apple.security.cs.allow-jit com.apple.security.network.client From ccd21af74029d4b1a3bf7f8374c06459ad23b2f7 Mon Sep 17 00:00:00 2001 From: Eduardo Speroni Date: Sun, 1 Nov 2026 17:50:11 -0300 Subject: [PATCH 06/12] test: let the Mac Catalyst UI-test runner listen for the app's results Xcode signs the macOS UI-test runner sandboxed with network.client only, so ModuleTestServer's loopback NWListener failed with EPERM before any spec ran. Give TestRunnerTests Catalyst-only entitlements with network.server. --- .../TestRunnerTests-Catalyst.entitlements | 14 ++++++++++++++ v8ios.xcodeproj/project.pbxproj | 2 ++ 2 files changed, 16 insertions(+) create mode 100644 TestRunnerTests/TestRunnerTests-Catalyst.entitlements diff --git a/TestRunnerTests/TestRunnerTests-Catalyst.entitlements b/TestRunnerTests/TestRunnerTests-Catalyst.entitlements new file mode 100644 index 000000000..afff7270e --- /dev/null +++ b/TestRunnerTests/TestRunnerTests-Catalyst.entitlements @@ -0,0 +1,14 @@ + + + + + + com.apple.security.app-sandbox + + com.apple.security.network.client + + com.apple.security.network.server + + + diff --git a/v8ios.xcodeproj/project.pbxproj b/v8ios.xcodeproj/project.pbxproj index a58fa4a59..ecaad04b0 100644 --- a/v8ios.xcodeproj/project.pbxproj +++ b/v8ios.xcodeproj/project.pbxproj @@ -2591,6 +2591,7 @@ SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator"; ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO; CLANG_ENABLE_MODULES = NO; + "CODE_SIGN_ENTITLEMENTS[sdk=macosx*]" = "TestRunnerTests/TestRunnerTests-Catalyst.entitlements"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "-"; CODE_SIGN_STYLE = Automatic; "ENABLE_HARDENED_RUNTIME[sdk=macosx*]" = NO; @@ -2623,6 +2624,7 @@ SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator"; ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO; CLANG_ENABLE_MODULES = NO; + "CODE_SIGN_ENTITLEMENTS[sdk=macosx*]" = "TestRunnerTests/TestRunnerTests-Catalyst.entitlements"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "-"; CODE_SIGN_STYLE = Automatic; "ENABLE_HARDENED_RUNTIME[sdk=macosx*]" = NO; From 5b89392e7b695604a2ce9c40ef8296f4e60c78d4 Mon Sep 17 00:00:00 2001 From: Eduardo Speroni Date: Sun, 1 Nov 2026 17:50:11 -0300 Subject: [PATCH 07/12] test: locate the app folder from resourcePath so specs pass on Mac Catalyst A Catalyst bundle keeps app/ under Contents/Resources, while bundlePath + "/app" only matches the flat iOS layout; resourcePath is the bundle path on iOS. Also bumps the shared tests for the case-insensitive file system expectation in TNS require > Case Sensitive. --- TestRunner/app/tests/RemoteModuleSecurityTests.js | 3 +-- TestRunner/app/tests/index.js | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/TestRunner/app/tests/RemoteModuleSecurityTests.js b/TestRunner/app/tests/RemoteModuleSecurityTests.js index f560c0d56..a926ff931 100644 --- a/TestRunner/app/tests/RemoteModuleSecurityTests.js +++ b/TestRunner/app/tests/RemoteModuleSecurityTests.js @@ -81,8 +81,7 @@ describe("Remote Module Security", function() { // We can't directly access the parsed config from JS in debug mode, // but we can verify the package.json file structure const fs = NSFileManager.defaultManager; - const bundlePath = NSBundle.mainBundle.bundlePath; - const packagePath = bundlePath + "/app/package.json"; + const packagePath = NSBundle.mainBundle.resourcePath + "/app/package.json"; const exists = fs.fileExistsAtPath(packagePath); expect(exists).toBe(true); diff --git a/TestRunner/app/tests/index.js b/TestRunner/app/tests/index.js index 5c4f49b0f..958befa3d 100644 --- a/TestRunner/app/tests/index.js +++ b/TestRunner/app/tests/index.js @@ -92,7 +92,8 @@ global.__JUnitSaveResults = function (text) { attemptReport(1); }; -global.__approot = NSString.stringWithString(NSBundle.mainBundle.bundlePath).stringByResolvingSymlinksInPath; +// resourcePath, not bundlePath: a Mac Catalyst bundle keeps app/ under Contents/Resources. +global.__approot = NSString.stringWithString(NSBundle.mainBundle.resourcePath).stringByResolvingSymlinksInPath; var jasmineBoot = require("../Infrastructure/Jasmine/boot"); From 75edc8583051b3c303647717ac19983668083c89 Mon Sep 17 00:00:00 2001 From: Eduardo Speroni Date: Sun, 1 Nov 2026 17:59:50 -0300 Subject: [PATCH 08/12] build(v8): bump to v8-14.9.207.39-9 for the Mac Catalyst JIT build Catalyst archives now carry Sparkplug, Maglev and TurboFan plus the patch that gives Catalyst macOS's MAP_JIT write toggle (NativeScript/v8-buildscripts#10). iOS archives are unchanged (still lite mode). --- V8_RELEASE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/V8_RELEASE b/V8_RELEASE index ac872018f..d5a564b23 100644 --- a/V8_RELEASE +++ b/V8_RELEASE @@ -1 +1 @@ -v8-14.9.207.39-7 +v8-14.9.207.39-9 From 16499ac729980ea5f5eea5daf56cd6fb85b62fff Mon Sep 17 00:00:00 2001 From: Eduardo Speroni Date: Tue, 17 Nov 2026 23:45:15 -0300 Subject: [PATCH 09/12] fix(test): serialize --catalyst runs with flock instead of a pid-file lock The mkdir lock removed stale locks by pid, which raced: two waiters that saw the same dead pid could each delete it, the second deleting the lock the first had just taken. A lock directory left without a pid file (a run killed between mkdir and writing it) also never counted as stale, so every later run waited forever. Hold flock(2) on a lock file through fd 9 instead. The kernel releases it when the script exits, however it exits, so there is no stale lock to detect or remove. perl takes the lock on the inherited descriptor, since bash has no flock builtin and macOS ships no flock(1). The lock lives in $TMPDIR, which is per user, so the usage text now says one Catalyst run per user rather than per Mac. --- run_tests.sh | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/run_tests.sh b/run_tests.sh index e8c719adf..51bf0642f 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -276,7 +276,7 @@ Destination (default: the single booted simulator, else a prompt): --catalyst Build TestRunner for Mac Catalyst and run the suite on this Mac (hardened runtime, ad-hoc signed, allow-jit entitlement). Cannot be combined with any simulator option. Only one - Catalyst run per Mac at a time: later ones wait for it. + Catalyst run per user at a time: later ones wait for it. Simulator management (no tests run): --create-sim Create and boot ${SIM_PREFIX}, print its UDID, exit @@ -459,32 +459,31 @@ finish_run() { # XCUIApplication.launch() terminates any running app with the same bundle # identifier, so concurrent Catalyst runs from different checkouts would kill -# each other's TestRunner. Serialize them per user with a mkdir lock. -CATALYST_LOCK="${TMPDIR:-/tmp}/ns-test-catalyst.lock" +# each other's TestRunner. Serialize them per user with flock(2) on fd 9: the +# kernel drops the lock when this script exits, however it exits, so a lock is +# never left behind. Bash has no flock builtin and macOS ships no flock(1), so +# perl takes the lock on the inherited descriptor; it outlives perl because +# this shell keeps fd 9 open. +CATALYST_LOCK="${TMPDIR:-/tmp}/ns-test-catalyst.flock" CATALYST_LOCK_HELD=0 +lock_fd9() { + perl -MFcntl=:flock -e 'open(my $fh, ">&=", 9) or die "fd 9: $!\n"; exit(flock($fh, LOCK_EX | ($ARGV[0] ? LOCK_NB : 0)) ? 0 : 1)' "$1" +} + acquire_catalyst_lock() { - local waited=0 holder - until mkdir "$CATALYST_LOCK" 2>/dev/null; do - holder=$(cat "$CATALYST_LOCK/pid" 2>/dev/null) - if [ -n "$holder" ] && ! kill -0 "$holder" 2>/dev/null; then - echo "Removing stale Catalyst run lock (pid $holder is gone)." >&2 - rm -rf "$CATALYST_LOCK" - continue - fi - if [ "$waited" -eq 0 ]; then - echo "Another --catalyst run (pid ${holder:-unknown}) is in progress; waiting for it to finish..." >&2 - waited=1 - fi - sleep 10 - done - echo $$ > "$CATALYST_LOCK/pid" + exec 9>>"$CATALYST_LOCK" + if ! lock_fd9 1; then + echo "Another --catalyst run (pid $(cat "$CATALYST_LOCK" 2>/dev/null || echo unknown)) is in progress; waiting for it to finish..." >&2 + lock_fd9 0 || { echo "Could not lock $CATALYST_LOCK" >&2; exit 1; } + fi + echo $$ > "$CATALYST_LOCK" CATALYST_LOCK_HELD=1 } release_catalyst_lock() { if [ "$CATALYST_LOCK_HELD" -eq 1 ]; then - rm -rf "$CATALYST_LOCK" + exec 9>&- CATALYST_LOCK_HELD=0 fi } From 57332d935c590593b4fe16f38b8e17f0da410015 Mon Sep 17 00:00:00 2001 From: Eduardo Speroni Date: Tue, 17 Nov 2026 23:45:15 -0300 Subject: [PATCH 10/12] ci: require the Mac Catalyst JUnit report and test the JIT fallback paths Main's CI no longer installs xcparse, so run_tests.sh --catalyst extracts no JUnit report there, and the Validate step passed on an empty folder: xargs runs nothing on empty input. The Catalyst job now exports the attachments with export-test-attachments.sh like the iOS job, and both test jobs fail when no report arrived. The XCUITest run only covers allow-jit with the JIT on. The new scripts/check-catalyst-jit.sh re-signs copies of the built app (hardened runtime, ad-hoc) and runs the whole suite in each, launched directly so it needs no Automation Mode: - no JIT entitlement: the MAP_JIT probe fails and the runtime must pass --jitless instead of aborting at startup; - allow-jit with "ios": {"jit": false}: the override must win; - allow-unsigned-executable-memory only: the JIT must stay on, which is what apps still carrying the old template entitlement get. CatalystJitTests takes -expect-jitless for the first two, so the spec fails when the JIT state is not the expected one. Also align the Catalyst job's action pins with main's. --- .github/workflows/pull_request.yml | 23 +++- TestRunner/app/tests/CatalystJitTests.js | 18 ++- scripts/check-catalyst-jit.sh | 165 +++++++++++++++++++++++ 3 files changed, 200 insertions(+), 6 deletions(-) create mode 100755 scripts/check-catalyst-jit.sh diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 07e58e5c5..0c68aa42c 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -174,6 +174,9 @@ jobs: detailed_summary: true - name: Validate Test Results run: | + # JS spec results only reach CI through these reports, and xargs runs + # nothing on empty input, so a missing report must fail here. + ls "$TEST_FOLDER"/test-out/*junit*.xml > /dev/null 2>&1 || { echo "::error::No JUnit report in $TEST_FOLDER/test-out"; exit 1; } find $TEST_FOLDER/test-out -name "*junit*.xml" -maxdepth 1 -print0 | xargs -n 1 -0 npx junit-cli-report-viewer find $TEST_FOLDER/test-out -name "*junit*.xml" -maxdepth 1 -print0 | xargs -n 1 -0 npx verify-junit-xml - name: Collect test diagnostics @@ -221,17 +224,31 @@ jobs: # run_tests.sh empties its results folder, so move the failed # attempt's bundle out of it first. on_retry_command: rm -rf $TEST_FOLDER-attempt1; mv $TEST_FOLDER $TEST_FOLDER-attempt1 2>/dev/null || true + - name: Extract test results + if: ${{ !cancelled() }} + run: | + if [ -d "$TEST_FOLDER/test_results.xcresult" ]; then + ./scripts/export-test-attachments.sh --result "$TEST_FOLDER/test_results.xcresult" --output "$TEST_FOLDER/test-out" + fi - name: Test report summary if: ${{ !cancelled() }} - uses: mikepenz/action-junit-report@a9170d5795813c01ab4901ffb045b52bab4ab09d # v6.5.0 + uses: mikepenz/action-junit-report@6ef3fdcfcd5f0b5d14df3e659ef19b8c6820f93d # v6.6.1 with: report_paths: build/tests/catalyst/test-out/*junit*.xml annotate_only: true detailed_summary: true - name: Validate Test Results run: | + # JS spec results only reach CI through these reports, and xargs runs + # nothing on empty input, so a missing report must fail here. + ls "$TEST_FOLDER"/test-out/*junit*.xml > /dev/null 2>&1 || { echo "::error::No JUnit report in $TEST_FOLDER/test-out"; exit 1; } find $TEST_FOLDER/test-out -name "*junit*.xml" -maxdepth 1 -print0 | xargs -n 1 -0 npx junit-cli-report-viewer find $TEST_FOLDER/test-out -name "*junit*.xml" -maxdepth 1 -print0 | xargs -n 1 -0 npx verify-junit-xml + - name: JIT fallback check + # The suite above only covers allow-jit with the JIT on. Re-sign the + # built app into the configurations where the runtime must fall back to + # --jitless (or may JIT without allow-jit) and run the suite in each. + run: ./scripts/check-catalyst-jit.sh --app build/Debug-maccatalyst/TestRunner.app --output "$TEST_FOLDER/jit-check" - name: Collect test diagnostics if: failure() uses: ./.github/actions/collect-test-diagnostics @@ -241,9 +258,11 @@ jobs: host-process-log: "true" - name: Archive Test Result Data if: always() - uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: test-results-catalyst path: | ${{env.TEST_FOLDER}}/test_results.xcresult ${{env.TEST_FOLDER}}-attempt1/test_results.xcresult + ${{env.TEST_FOLDER}}/jit-check/*.log + ${{env.TEST_FOLDER}}/jit-check/*-junit.xml diff --git a/TestRunner/app/tests/CatalystJitTests.js b/TestRunner/app/tests/CatalystJitTests.js index aa4caaf1d..8610ab3ca 100644 --- a/TestRunner/app/tests/CatalystJitTests.js +++ b/TestRunner/app/tests/CatalystJitTests.js @@ -1,9 +1,19 @@ // TestRunner's Catalyst build is signed with com.apple.security.cs.allow-jit, -// so the runtime must leave V8's JIT on there. +// so the runtime must leave V8's JIT on there. scripts/check-catalyst-jit.sh +// re-signs it into configurations where the runtime must fall back to +// --jitless, and launches those with -expect-jitless. if (NSProcessInfo.processInfo.macCatalystApp) { + var expectJitless = NSProcessInfo.processInfo.arguments.containsObject("-expect-jitless"); + describe("Mac Catalyst JIT", function () { - it("runs V8 with its JIT when the process may map JIT memory", function () { - expect(TNSHasExecutableV8Memory()).toBe(true); - }); + if (expectJitless) { + it("runs V8 jitless when the process may not use the JIT", function () { + expect(TNSHasExecutableV8Memory()).toBe(false); + }); + } else { + it("runs V8 with its JIT when the process may map JIT memory", function () { + expect(TNSHasExecutableV8Memory()).toBe(true); + }); + } }); } diff --git a/scripts/check-catalyst-jit.sh b/scripts/check-catalyst-jit.sh new file mode 100755 index 000000000..ca47f6442 --- /dev/null +++ b/scripts/check-catalyst-jit.sh @@ -0,0 +1,165 @@ +#!/bin/bash +# Re-sign a built Mac Catalyst TestRunner.app into the signing and app-config +# combinations the runtime's launch-time JIT decision has to handle, run the +# suite in each, and fail if a run crashes, hangs or reports a failing spec. +# +# no-jit-entitlement hardened, no JIT entitlement -> must run jitless +# jit-off-in-config allow-jit, "ios": {"jit": false} -> must run jitless +# unsigned-executable-memory allow-unsigned-executable-memory -> must JIT +# +# The app is launched directly, not through XCUITest, so this needs no +# Automation Mode. CFFIXED_USER_HOME keeps the junit report TNSSaveResults +# writes to ~/Documents inside the output folder. +set -euo pipefail + +usage() { + echo "Usage: ./scripts/check-catalyst-jit.sh --app --output [--timeout ]" + echo "" + echo " --app Mac Catalyst TestRunner.app to re-sign (left untouched; copies are signed)" + echo " --output folder for the re-signed copies, .log and -junit.xml" + echo " --timeout per-variant limit for the suite to report (default: 600)" + echo " -h, --help show this help" +} + +APP="" +OUTPUT="" +TIMEOUT=600 +while [ $# -gt 0 ]; do + case "$1" in + --app) + [ $# -ge 2 ] || { echo "--app needs a value" >&2; usage >&2; exit 1; } + APP="$2" + shift 2 + ;; + --output) + [ $# -ge 2 ] || { echo "--output needs a value" >&2; usage >&2; exit 1; } + OUTPUT="$2" + shift 2 + ;; + --timeout) + [ $# -ge 2 ] || { echo "--timeout needs a value" >&2; usage >&2; exit 1; } + TIMEOUT="$2" + shift 2 + ;; + -h|--help) + usage + exit 0 + ;; + *) + echo "Unknown argument: $1" >&2 + usage >&2 + exit 1 + ;; + esac +done + +[ -n "$APP" ] && [ -n "$OUTPUT" ] || { usage >&2; exit 1; } +[ -x "$APP/Contents/MacOS/TestRunner" ] || { echo "$APP is not a Mac Catalyst TestRunner.app" >&2; exit 1; } +case "$TIMEOUT" in + ''|*[!0-9]*) echo "--timeout must be a number of seconds" >&2; exit 1 ;; +esac + +mkdir -p "$OUTPUT" +OUTPUT=$(cd "$OUTPUT" && pwd) + +APP_PID="" +trap '[ -n "$APP_PID" ] && kill "$APP_PID" 2>/dev/null; true' EXIT + +write_entitlements() { + local file="$1" entitlement + shift + { + echo '' + echo '' + echo '' + for entitlement in "$@"; do + echo " com.apple.security.cs.$entitlement" + done + echo '' + } > "$file" +} + +# run_variant ... +# Called as `run_variant ... || ...`, which turns off set -e inside it, so every +# step that can fail returns explicitly. +run_variant() { + local name="$1" expect="$2" config_jit="$3" + shift 3 + local dir="$OUTPUT/$name" + local app="$dir/TestRunner.app" + local report="$dir/home/Documents/junit-result.xml" + local log="$OUTPUT/$name.log" + + echo "---- $name: expecting $expect" + rm -rf "$dir" "$log" "$OUTPUT/$name-junit.xml" + mkdir -p "$dir/home/Documents" + ditto "$APP" "$app" || return 1 + + if [ -n "$config_jit" ]; then + node -e ' + const fs = require("fs"); + const [file, jit] = process.argv.slice(1); + const pkg = JSON.parse(fs.readFileSync(file, "utf8")); + pkg.ios = Object.assign({}, pkg.ios, { jit: jit === "true" }); + fs.writeFileSync(file, JSON.stringify(pkg, null, 4)); + ' "$app/Contents/Resources/app/package.json" "$config_jit" || return 1 + fi + + # Library validation would reject the ad-hoc signed embedded frameworks. + write_entitlements "$dir/entitlements.plist" disable-library-validation "$@" || return 1 + codesign --force --options runtime --entitlements "$dir/entitlements.plist" --sign - "$app" 2>/dev/null || return 1 + codesign --verify --strict "$app" || return 1 + local signature + signature=$(codesign -dv "$app" 2>&1) || return 1 + if ! printf '%s\n' "$signature" | grep -q 'flags=.*runtime'; then + echo "$name: re-signed app lacks the hardened runtime, so the variant would test nothing" >&2 + return 1 + fi + + if [ "$expect" = "jitless" ]; then + CFFIXED_USER_HOME="$dir/home" OS_ACTIVITY_DT_MODE=1 "$app/Contents/MacOS/TestRunner" -expect-jitless > "$log" 2>&1 & + else + CFFIXED_USER_HOME="$dir/home" OS_ACTIVITY_DT_MODE=1 "$app/Contents/MacOS/TestRunner" > "$log" 2>&1 & + fi + APP_PID=$! + + local deadline=$((SECONDS + TIMEOUT)) status=0 + while [ ! -f "$report" ]; do + if ! kill -0 "$APP_PID" 2>/dev/null; then + wait "$APP_PID" || status=$? + APP_PID="" + echo "$name: TestRunner exited (status $status) before reporting; see $log" >&2 + return 1 + fi + if [ "$SECONDS" -ge "$deadline" ]; then + echo "$name: no junit report after ${TIMEOUT}s; see $log" >&2 + return 1 + fi + sleep 2 + done + kill "$APP_PID" 2>/dev/null || true + wait "$APP_PID" 2>/dev/null || true + APP_PID="" + + cp "$report" "$OUTPUT/$name-junit.xml" + local tests failures + tests=$(grep -c '&2 + grep -B1 -e '&2 || true + return 1 + fi + echo "$name: $tests specs, 0 failures" +} + +FAILED=() +run_variant no-jit-entitlement jitless "" || FAILED+=(no-jit-entitlement) +run_variant jit-off-in-config jitless false allow-jit || FAILED+=(jit-off-in-config) +run_variant unsigned-executable-memory jit "" allow-unsigned-executable-memory || FAILED+=(unsigned-executable-memory) + +if [ "${#FAILED[@]}" -gt 0 ]; then + echo "Failed variants: ${FAILED[*]}" >&2 + exit 1 +fi +echo "All Mac Catalyst JIT variants passed." From f289632660b622f7e735a04eb260940ce8b4815a Mon Sep 17 00:00:00 2001 From: Eduardo Speroni Date: Wed, 18 Nov 2026 00:11:46 -0300 Subject: [PATCH 11/12] ci: keep the directly launched Catalyst suite's timers exact, probe MAP_JIT enforcement On the GitHub runner the JIT check's three runs failed the same two timer specs: a 100 ms interval ticked 6 times in a second instead of 10. Launched directly instead of by XCUITest, the app isn't in front, so App Nap and timer coalescing apply. TestRunner now holds a UserInitiated | LatencyCritical NSProcessInfo activity for the run on Mac Catalyst. The runner also let the hardened, unentitled copy map JIT memory, so V8 kept its JIT there and the no-entitlement variant could not exercise the fallback. The script now compiles a hardened, unentitled MAP_JIT probe first and skips that variant with a notice when the probe succeeds. --- TestRunner/app/tests/index.js | 9 +++++++ scripts/check-catalyst-jit.sh | 44 ++++++++++++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/TestRunner/app/tests/index.js b/TestRunner/app/tests/index.js index 958befa3d..95b1bed03 100644 --- a/TestRunner/app/tests/index.js +++ b/TestRunner/app/tests/index.js @@ -4,6 +4,15 @@ console.log('Application Start!'); // The report delivery deadline (REPORT_DEADLINE_SECONDS) counts from launch. var appStartMs = Date.now(); +// Timer specs count ticks. A Mac Catalyst app that isn't in front (launched +// directly instead of by XCUITest) gets App Nap and timer coalescing, which +// drop ticks; this activity opts the whole run out. LatencyCritical is wider +// than 32 bits, so the flags are added: `|` would truncate it. +if (NSProcessInfo.processInfo.macCatalystApp) { + global.__testRunActivity = NSProcessInfo.processInfo.beginActivityWithOptionsReason( + NSActivityOptions.UserInitiated + NSActivityOptions.LatencyCritical, "TestRunner suite"); +} + require("../Infrastructure/simulator"); global.utf8 = require("../Infrastructure/utf8") diff --git a/scripts/check-catalyst-jit.sh b/scripts/check-catalyst-jit.sh index ca47f6442..04fb733d3 100755 --- a/scripts/check-catalyst-jit.sh +++ b/scripts/check-catalyst-jit.sh @@ -7,6 +7,11 @@ # jit-off-in-config allow-jit, "ios": {"jit": false} -> must run jitless # unsigned-executable-memory allow-unsigned-executable-memory -> must JIT # +# Some machines (GitHub's macOS runners among them) let a hardened process map +# JIT memory with no entitlement. The no-entitlement variant can't test the +# fallback there, so it is skipped when a hardened, unentitled probe binary +# gets MAP_JIT. +# # The app is launched directly, not through XCUITest, so this needs no # Automation Mode. CFFIXED_USER_HOME keeps the junit report TNSSaveResults # writes to ~/Documents inside the output folder. @@ -153,8 +158,45 @@ run_variant() { echo "$name: $tests specs, 0 failures" } +notice() { + if [ -n "${GITHUB_ACTIONS:-}" ]; then + echo "::notice::$1" + else + echo "$1" + fi +} + +# Exits 0 when a hardened, ad-hoc signed binary with no entitlements can map +# JIT memory, i.e. this machine doesn't enforce the hardened runtime's JIT rule. +jit_unrestricted() { + local dir="$OUTPUT/map-jit-probe" + rm -rf "$dir" && mkdir -p "$dir" || return 2 + printf '%s\n' \ + '#include ' \ + 'int main(void) {' \ + ' void *p = mmap(0, 16384, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANON | MAP_JIT, -1, 0);' \ + ' return p == MAP_FAILED;' \ + '}' > "$dir/probe.c" + xcrun clang -o "$dir/probe" "$dir/probe.c" || return 2 + codesign --force --options runtime --sign - "$dir/probe" 2>/dev/null || return 2 + "$dir/probe" +} + FAILED=() -run_variant no-jit-entitlement jitless "" || FAILED+=(no-jit-entitlement) +probe_status=0 +jit_unrestricted || probe_status=$? +case "$probe_status" in + 0) + notice "Skipping no-jit-entitlement: this machine lets hardened processes map JIT memory without an entitlement, so the fallback can't be exercised here, and unsigned-executable-memory passes regardless of the entitlement." + ;; + 1) + run_variant no-jit-entitlement jitless "" || FAILED+=(no-jit-entitlement) + ;; + *) + echo "Could not build the MAP_JIT probe" >&2 + FAILED+=(map-jit-probe) + ;; +esac run_variant jit-off-in-config jitless false allow-jit || FAILED+=(jit-off-in-config) run_variant unsigned-executable-memory jit "" allow-unsigned-executable-memory || FAILED+=(unsigned-executable-memory) From 0718e4a8843196f128e909c43514399877a223d3 Mon Sep 17 00:00:00 2001 From: Eduardo Speroni Date: Wed, 18 Nov 2026 00:45:18 -0300 Subject: [PATCH 12/12] ci: run the Mac Catalyst JIT fallback check locally, not on CI On GitHub's macOS runners the check can't do its job. A hardened process there maps JIT memory with no entitlement, so the no-entitlement variant is skipped and the allow-unsigned-executable-memory one passes regardless. A directly launched app there also misses timer ticks the timer specs count (7-8 of 10), with or without an NSProcessInfo activity. Drop the CI step and the activity; scripts/check-catalyst-jit.sh stays as the local check, which runs all three variants on a Mac that enforces the rule. --- .github/workflows/pull_request.yml | 7 ------- TestRunner/app/tests/index.js | 9 --------- scripts/check-catalyst-jit.sh | 11 +++++++---- 3 files changed, 7 insertions(+), 20 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 0c68aa42c..7dfafa7c6 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -244,11 +244,6 @@ jobs: ls "$TEST_FOLDER"/test-out/*junit*.xml > /dev/null 2>&1 || { echo "::error::No JUnit report in $TEST_FOLDER/test-out"; exit 1; } find $TEST_FOLDER/test-out -name "*junit*.xml" -maxdepth 1 -print0 | xargs -n 1 -0 npx junit-cli-report-viewer find $TEST_FOLDER/test-out -name "*junit*.xml" -maxdepth 1 -print0 | xargs -n 1 -0 npx verify-junit-xml - - name: JIT fallback check - # The suite above only covers allow-jit with the JIT on. Re-sign the - # built app into the configurations where the runtime must fall back to - # --jitless (or may JIT without allow-jit) and run the suite in each. - run: ./scripts/check-catalyst-jit.sh --app build/Debug-maccatalyst/TestRunner.app --output "$TEST_FOLDER/jit-check" - name: Collect test diagnostics if: failure() uses: ./.github/actions/collect-test-diagnostics @@ -264,5 +259,3 @@ jobs: path: | ${{env.TEST_FOLDER}}/test_results.xcresult ${{env.TEST_FOLDER}}-attempt1/test_results.xcresult - ${{env.TEST_FOLDER}}/jit-check/*.log - ${{env.TEST_FOLDER}}/jit-check/*-junit.xml diff --git a/TestRunner/app/tests/index.js b/TestRunner/app/tests/index.js index 95b1bed03..958befa3d 100644 --- a/TestRunner/app/tests/index.js +++ b/TestRunner/app/tests/index.js @@ -4,15 +4,6 @@ console.log('Application Start!'); // The report delivery deadline (REPORT_DEADLINE_SECONDS) counts from launch. var appStartMs = Date.now(); -// Timer specs count ticks. A Mac Catalyst app that isn't in front (launched -// directly instead of by XCUITest) gets App Nap and timer coalescing, which -// drop ticks; this activity opts the whole run out. LatencyCritical is wider -// than 32 bits, so the flags are added: `|` would truncate it. -if (NSProcessInfo.processInfo.macCatalystApp) { - global.__testRunActivity = NSProcessInfo.processInfo.beginActivityWithOptionsReason( - NSActivityOptions.UserInitiated + NSActivityOptions.LatencyCritical, "TestRunner suite"); -} - require("../Infrastructure/simulator"); global.utf8 = require("../Infrastructure/utf8") diff --git a/scripts/check-catalyst-jit.sh b/scripts/check-catalyst-jit.sh index 04fb733d3..0e82e2b89 100755 --- a/scripts/check-catalyst-jit.sh +++ b/scripts/check-catalyst-jit.sh @@ -7,10 +7,13 @@ # jit-off-in-config allow-jit, "ios": {"jit": false} -> must run jitless # unsigned-executable-memory allow-unsigned-executable-memory -> must JIT # -# Some machines (GitHub's macOS runners among them) let a hardened process map -# JIT memory with no entitlement. The no-entitlement variant can't test the -# fallback there, so it is skipped when a hardened, unentitled probe binary -# gets MAP_JIT. +# Run it locally after a Catalyst build (./run_tests.sh --catalyst, or an +# xcodebuild build for the Mac Catalyst destination). It isn't a CI step: +# GitHub's macOS runners let a hardened process map JIT memory with no +# entitlement, so only the ios.jit override is testable there, and a directly +# launched app on them misses timer ticks the timer specs count. On such a +# machine the no-entitlement variant is skipped, because a hardened, unentitled +# probe binary gets MAP_JIT. # # The app is launched directly, not through XCUITest, so this needs no # Automation Mode. CFFIXED_USER_HOME keeps the junit report TNSSaveResults