test(targets): share single-architecture fixtures (#16642)

This commit is contained in:
Vincent Koc authored and GitHub committed 2026-12-04 15:35:05 +08:00
1 parent ced3d7837c
commit a6896054e7
1 file changed
+24 -42
@@ -34,14 +34,26 @@ const identity = { path: "/fixture/target", sha256: "a".repeat(64) } as const;
const archive = { ...identity, kind: "archive" } as const;
const artifact = { ...identity, kind: "artifact" } as const;
const TARGETS: TargetFixtures = {
"mach-o": {
const singleArchitectureTarget = <
Format extends TargetFormat,
Architecture extends Extract<
BinaryTarget,
{ kind: "executable" }
>["architecture"],
>(
format: Format,
architecture: Architecture,
) =>
({
...identity,
kind: "executable",
format: "mach-o",
architecture: "arm64",
availableArchitectures: ["arm64"],
},
format,
architecture,
availableArchitectures: [architecture],
}) as const;
const TARGETS: TargetFixtures = {
"mach-o": singleArchitectureTarget("mach-o", "arm64"),
"mach-o-universal": {
...identity,
kind: "executable",
@@ -50,51 +62,21 @@ const TARGETS: TargetFixtures = {
availableArchitectures: ["x86_64", "arm64"],
universalSlice: { offset: 0x4000, size: 0x4000 },
},
elf: {
...identity,
kind: "executable",
format: "elf",
architecture: "x86_64",
availableArchitectures: ["x86_64"],
},
elf: singleArchitectureTarget("elf", "x86_64"),
pe: {
...identity,
kind: "executable",
format: "pe",
architecture: "x86_64",
availableArchitectures: ["x86_64"],
...singleArchitectureTarget("pe", "x86_64"),
executableRole: "application",
managed: false,
},
"dos-mz": {
...identity,
kind: "executable",
format: "dos-mz",
architecture: "x86",
availableArchitectures: ["x86"],
},
"dos-com": {
...identity,
kind: "executable",
format: "dos-com",
architecture: "x86",
availableArchitectures: ["x86"],
},
"dos-mz": singleArchitectureTarget("dos-mz", "x86"),
"dos-com": singleArchitectureTarget("dos-com", "x86"),
// A raw-only family: detected formats must not admit it.
"raw-binary": {
...identity,
kind: "executable",
format: "raw-binary",
architecture: "m68k",
availableArchitectures: ["m68k"],
...singleArchitectureTarget("raw-binary", "m68k"),
rawLoad: rawLoadAtEntry("0x1000"),
},
"gamecube-dol": {
...identity,
kind: "executable",
format: "gamecube-dol",
architecture: "powerpc",
availableArchitectures: ["powerpc"],
...singleArchitectureTarget("gamecube-dol", "powerpc"),
byteOrder: "big",
bits: 32,
entryPoint: "0x80003100",