diff --git a/src/artifacts/apple/MachoLoadCommandReader.test.ts b/src/artifacts/apple/MachoLoadCommandReader.test.ts index 7e4119bdc8..503d9f0f6f 100644 --- a/src/artifacts/apple/MachoLoadCommandReader.test.ts +++ b/src/artifacts/apple/MachoLoadCommandReader.test.ts @@ -476,8 +476,12 @@ it.each([false, true] as const)( }, ); +// dyld absolute paths start with "/". On Windows the test root is a drive path +// (`E:\...`), so a load path built from it is not dyld-absolute there. describe("absolute dyld candidate paths at the filesystem reader boundary", () => { - it.each(["install-name", "rpath"] as const)( + it + .skipIf(process.platform === "win32") + .each(["install-name", "rpath"] as const)( "resolves an absolute in-root %s while preserving its source path", async (kind) => { const root = await createTestTempDirectory("rea-dylib-absolute-in-root-"); @@ -586,7 +590,13 @@ describe("absolute dyld candidate paths at the filesystem reader boundary", () = resolution: { status: "undetermined", image: null }, }); expect(trace.edges[1]).toMatchObject({ - candidates: [{ outcome: "escapes-target", resolved_path: null }], + candidates: [ + { + outcome: + process.platform === "win32" ? "undetermined" : "escapes-target", + resolved_path: null, + }, + ], resolution: { status: "undetermined", image: null }, }); expect(trace.edges[2]).toMatchObject({ @@ -605,48 +615,52 @@ describe("absolute dyld candidate paths at the filesystem reader boundary", () = }); describe("absolute dyld candidate traversal", () => { - it("maps an absolute candidate spelled through the selected root symlink", async () => { - const root = await createTestTempDirectory( - "rea-dylib-absolute-root-alias-", - ); - const aliasRoot = join(root, "bundle-alias"); - const bridgePath = "Frameworks/libBridge.dylib"; - const bridgeAbsolute = `${aliasRoot}/${bridgePath}`; - const executable = machoImage({ - commands: [ - buildVersionCommand(1), - dylibCommand(LC.LOAD_DYLIB, bridgeAbsolute), - ], - }); - const bridge = machoImage({ - fileType: FILE_TYPE.dylib, - commands: [buildVersionCommand(1)], - }); - await symlink(".", aliasRoot); - await mkdir(join(root, "Frameworks"), { recursive: true }); - await writeFile(join(root, "App"), executable); - await writeFile(join(root, bridgePath), bridge); + // Needs symlink privilege, and its install name is built from a drive path. + it.skipIf(process.platform === "win32")( + "maps an absolute candidate spelled through the selected root symlink", + async () => { + const root = await createTestTempDirectory( + "rea-dylib-absolute-root-alias-", + ); + const aliasRoot = join(root, "bundle-alias"); + const bridgePath = "Frameworks/libBridge.dylib"; + const bridgeAbsolute = `${aliasRoot}/${bridgePath}`; + const executable = machoImage({ + commands: [ + buildVersionCommand(1), + dylibCommand(LC.LOAD_DYLIB, bridgeAbsolute), + ], + }); + const bridge = machoImage({ + fileType: FILE_TYPE.dylib, + commands: [buildVersionCommand(1)], + }); + await symlink(".", aliasRoot); + await mkdir(join(root, "Frameworks"), { recursive: true }); + await writeFile(join(root, "App"), executable); + await writeFile(join(root, bridgePath), bridge); - const trace = await traceDylibResolution({ - rootPath: aliasRoot, - targetPath: `${aliasRoot}/App`, - targetSha256: createHash("sha256").update(executable).digest("hex"), - enumerateRoots: false, - parameters: { roots: ["App"] }, - }); + const trace = await traceDylibResolution({ + rootPath: aliasRoot, + targetPath: `${aliasRoot}/App`, + targetSha256: createHash("sha256").update(executable).digest("hex"), + enumerateRoots: false, + parameters: { roots: ["App"] }, + }); - expect(trace.edges[0]).toMatchObject({ - install_name: bridgeAbsolute, - candidates: [ - { - path: bridgeAbsolute, - outcome: "resolved", - resolved_path: bridgePath, - }, - ], - resolution: { status: "resolved", image: bridgePath }, - }); - }); + expect(trace.edges[0]).toMatchObject({ + install_name: bridgeAbsolute, + candidates: [ + { + path: bridgeAbsolute, + outcome: "resolved", + resolved_path: bridgePath, + }, + ], + resolution: { status: "resolved", image: bridgePath }, + }); + }, + ); it.skipIf(process.platform === "win32")( "preserves symlink-then-parent traversal for an absolute in-root path", diff --git a/tests/boundary/inspector/javascriptRuntimeObservation.test.ts b/tests/boundary/inspector/javascriptRuntimeObservation.test.ts index e5f5e8004e..e6e142976c 100644 --- a/tests/boundary/inspector/javascriptRuntimeObservation.test.ts +++ b/tests/boundary/inspector/javascriptRuntimeObservation.test.ts @@ -288,19 +288,27 @@ test("lists all connectable targets on the selected endpoint across directories" if (!listed.ok) throw listed.error; const targets = listed.value.targets; expect(targets).toHaveLength(207); - expect(new Set(targets.map(({ target_id }) => target_id)).size).toBe(207); - expect( - targets.find(({ target_id }) => target_id === fake.targetId)?.location, - ).toMatchObject({ kind: "file", file_path: fixture.entry }); - expect( - targets.find(({ target_id }) => target_id === fake.targetIds[1]) - ?.location, - ).toMatchObject({ kind: "file", file_path: outside }); - expect( - targets.find( - ({ target_id }) => target_id === "00000000-0000-4000-8000-000000000207", - )?.location, - ).toMatchObject({ kind: "file", file_path: fixture.entry }); + expect(new Set(targets.map(({ target_id }) => target_id))).toEqual( + new Set(fake.targetIds), + ); + // Node discovery turns backslashes into underscores on Windows. + for (const [targetId, path] of [ + [fake.targetId, fixture.entry], + [fake.targetIds[1], outside], + ["00000000-0000-4000-8000-000000000207", fixture.entry], + ] as const) { + expect( + targets.find(({ target_id }) => target_id === targetId)?.location, + ).toMatchObject( + process.platform === "win32" + ? { + kind: "unresolved", + reported_url: nodeDiscoveryTargetUrl(path), + reason: "unverifiable-file-location", + } + : { kind: "file", file_path: path }, + ); + } } finally { await fake.close(); }