From 7bc57e1e64915a26c32f89fb53d0321193a37160 Mon Sep 17 00:00:00 2001 From: TonyWu <75903587+TonyWu2333@users.noreply.github.com> Date: Tue, 13 Oct 2026 05:07:16 +0800 Subject: [PATCH] test(apple): skip ibtool-compiled NIB tests when Xcode ibtool is unavailable (#2070) Command Line Tools install the /usr/bin/ibtool and xcrun shims without ibtool itself, so the existing /usr/bin/ibtool existence guard never skipped the storyboard test, and the native NIB hierarchy suite had no guard. On a Command Line Tools-only macOS host these seven tests failed at fixture compilation. Probe xcrun --find ibtool once and use it for both suites. --- .../filesystem/interfaceBuilderBundle.test.ts | 4 ++-- tests/boundary/filesystem/nibNativeHierarchy.test.ts | 3 ++- tests/fixtures/ibtool.ts | 11 +++++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 tests/fixtures/ibtool.ts diff --git a/tests/boundary/filesystem/interfaceBuilderBundle.test.ts b/tests/boundary/filesystem/interfaceBuilderBundle.test.ts index c30908794..4446c80dc 100644 --- a/tests/boundary/filesystem/interfaceBuilderBundle.test.ts +++ b/tests/boundary/filesystem/interfaceBuilderBundle.test.ts @@ -1,4 +1,3 @@ -import { existsSync } from "node:fs"; import { execFile } from "node:child_process"; import { mkdir, writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -10,6 +9,7 @@ import { describe, expect, it } from "vitest"; import { analyzeInterfaceBuilderBundle } from "../../../src/artifacts/apple/InterfaceBuilderAnalysis.js"; import { encodeNibArchiveFixture } from "../../../src/artifacts/apple/NibArchive.fixture.js"; import { thinMach } from "../../../src/domain/binaryTarget.fixture.js"; +import { xcodeIbtoolAvailable } from "../../fixtures/ibtool.js"; import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js"; import { interfaceBuilderAnalysisSchema } from "../../../src/domain/apple/interfaceBuilderGraph.js"; @@ -913,7 +913,7 @@ describe("bounded Interface Builder archive decoding", () => { ); }); - it.skipIf(process.platform !== "darwin" || !existsSync("/usr/bin/ibtool"))( + it.skipIf(!xcodeIbtoolAvailable)( "decodes an Xcode-compiled storyboard NIB and recovers its UI routes", async () => { const root = await createTestTempDirectory("rea-ib-compiled-test-"); diff --git a/tests/boundary/filesystem/nibNativeHierarchy.test.ts b/tests/boundary/filesystem/nibNativeHierarchy.test.ts index 2d956246a..e2b948f57 100644 --- a/tests/boundary/filesystem/nibNativeHierarchy.test.ts +++ b/tests/boundary/filesystem/nibNativeHierarchy.test.ts @@ -5,6 +5,7 @@ import { promisify } from "node:util"; import { describe, expect, it } from "vitest"; +import { xcodeIbtoolAvailable } from "../../fixtures/ibtool.js"; import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js"; import { decodeNibArchive } from "../../../src/artifacts/apple/NibArchive.js"; import { analyzeInterfaceBuilderBundle } from "../../../src/artifacts/apple/InterfaceBuilderAnalysis.js"; @@ -57,7 +58,7 @@ const compileNestedViews = async (depth: number, withWindow = false) => { return { bundle, archive: decodeNibArchive(await readFile(nib)) }; }; -describe.skipIf(process.platform !== "darwin")( +describe.skipIf(!xcodeIbtoolAvailable)( "native compiled NIB view hierarchy", () => { it.each([4, 40])( diff --git a/tests/fixtures/ibtool.ts b/tests/fixtures/ibtool.ts new file mode 100644 index 000000000..c7aef773f --- /dev/null +++ b/tests/fixtures/ibtool.ts @@ -0,0 +1,11 @@ +import { spawnSync } from "node:child_process"; + +/** + * Whether Xcode's ibtool can compile Interface Builder sources on this host. + * Command Line Tools install the /usr/bin/ibtool and xcrun shims without the + * tool itself, so probe resolution instead of checking the shim path. + */ +export const xcodeIbtoolAvailable = + process.platform === "darwin" && + spawnSync("/usr/bin/xcrun", ["--find", "ibtool"], { stdio: "ignore" }) + .status === 0;