test(ghidra): use host-native absolute session root fixtures

This commit is contained in:
N0zoM1z0
2026-10-09 13:20:49 +00:00
parent a8b8288396
commit 1e83d270c2
+12 -3
View File
@@ -1,4 +1,4 @@
import { join, sep } from "node:path";
import { join, resolve, sep } from "node:path";
import { describe, expect, it } from "vitest";
import { ghidraSessionRoot } from "./GhidraSessionRoot.js";
@@ -7,8 +7,8 @@ const hasDotPrefixElement = (directory: string): boolean =>
directory.split(sep).some((element) => element.startsWith("."));
const POSIX = process.platform !== "win32";
const posixFallback = join(sep, "tmp");
const posixBase = (...segments: string[]) => join(sep, ...segments);
const posixFallback = join(resolve(sep), "tmp");
const posixBase = (...segments: string[]) => join(resolve(sep), ...segments);
describe("ghidraSessionRoot", () => {
it("keeps an inherited base that Ghidra accepts", () => {
@@ -53,6 +53,15 @@ describe("ghidraSessionRoot", () => {
expect(hasDotPrefixElement(directory)).toBe(false);
});
it("uses the nearest safe ancestor when the platform has no fallback", () => {
expect(
ghidraSessionRoot({
base: posixBase("Users", "operator", ".cache", "scratch"),
platform: "win32",
}),
).toBe(posixBase("Users", "operator"));
});
it.skipIf(!POSIX)("prefers the platform temp directory by default", () => {
expect(
ghidraSessionRoot({ base: posixBase("home", "operator", ".cache") }),