mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-15 19:32:20 +03:00
`main` has been red since b342c1a361 on the vitest and integration gates:
✖ tests/unit/autoCombo/provider-family-combos.test.ts > auto/<family>
✖ chat pipeline applies Codex OAuth fingerprint and priority tier inside combos
Both call resetStorage() from beforeEach, which does an fs.rmSync(TEST_DATA_DIR,
{recursive: true, force: true}) with no retry, and intermittently loses the race
with a not-yet-released SQLite handle (ENOTEMPTY).
release/v3.8.51 fixed this in #11968 with a mechanical codemod adding
maxRetries/retryDelay to every recursive rm/rmSync/rmdirSync under tests/, but
that PR landed only on the release branch. Because main only receives work at
the release squash, it stayed broken for the whole cycle — and repo-wide gates
then turn every open PR into main red on checks unrelated to their diff.
This is the --base main twin: re-runs the same codemod that already shipped on
the release branch (scripts/ad-hoc/codemod-rm-maxretries.mjs), so the two
branches converge on identical test-teardown semantics. Test-only; no product
logic is touched.
The remaining three failures reported on #12133 (unit full suite exceeding its
4800s ceiling, package-artifact exceeding 1200s, and the boot-smoke that is
skipped as a consequence) are runner-contention timeouts, not code defects —
validate-release-green.mjs runs those heavy gates concurrently on one shared
hosted runner. There is no fix to port for those.
63 lines
2.1 KiB
TypeScript
63 lines
2.1 KiB
TypeScript
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { writeFileSync, mkdtempSync, rmSync } from "node:fs";
|
|
import { join } from "node:path";
|
|
import { tmpdir } from "node:os";
|
|
import { validateBinaryMagic, platformBinaryLabel } from "../../../bin/cli/runtime/magicBytes.mjs";
|
|
|
|
const dir = mkdtempSync(join(tmpdir(), "magic-test-"));
|
|
|
|
test("detects ELF", () => {
|
|
const p = join(dir, "fake.so");
|
|
writeFileSync(p, Buffer.from([0x7f, 0x45, 0x4c, 0x46, 0, 0, 0, 0]));
|
|
assert.equal(validateBinaryMagic(p), "elf");
|
|
});
|
|
|
|
test("detects Mach-O 64-bit BE", () => {
|
|
const p = join(dir, "fake.dylib");
|
|
writeFileSync(p, Buffer.from([0xfe, 0xed, 0xfa, 0xcf, 0, 0, 0, 0]));
|
|
assert.equal(validateBinaryMagic(p), "macho");
|
|
});
|
|
|
|
test("detects Mach-O LE", () => {
|
|
const p = join(dir, "fake-le.dylib");
|
|
writeFileSync(p, Buffer.from([0xcf, 0xfa, 0xed, 0xfe, 0, 0, 0, 0]));
|
|
assert.equal(validateBinaryMagic(p), "macho-le");
|
|
});
|
|
|
|
test("detects Mach-O fat binary", () => {
|
|
const p = join(dir, "fake.fat");
|
|
writeFileSync(p, Buffer.from([0xca, 0xfe, 0xba, 0xbe, 0, 0, 0, 0]));
|
|
assert.equal(validateBinaryMagic(p), "macho-fat");
|
|
});
|
|
|
|
test("detects PE (MZ)", () => {
|
|
const p = join(dir, "fake.node");
|
|
writeFileSync(p, Buffer.from([0x4d, 0x5a, 0, 0, 0, 0, 0, 0]));
|
|
assert.equal(validateBinaryMagic(p), "pe");
|
|
});
|
|
|
|
test("returns null for non-binary", () => {
|
|
const p = join(dir, "fake.txt");
|
|
writeFileSync(p, "hello world", "utf-8");
|
|
assert.equal(validateBinaryMagic(p), null);
|
|
});
|
|
|
|
test("returns null for missing file", () => {
|
|
assert.equal(validateBinaryMagic(join(dir, "nope.bin")), null);
|
|
});
|
|
|
|
test("returns null for too-short file", () => {
|
|
const p = join(dir, "short.bin");
|
|
writeFileSync(p, Buffer.from([0x7f, 0x45]));
|
|
assert.equal(validateBinaryMagic(p), null);
|
|
});
|
|
|
|
test("platformBinaryLabel matches process.platform", () => {
|
|
const expected =
|
|
process.platform === "win32" ? "pe" : process.platform === "darwin" ? "macho" : "elf";
|
|
assert.equal(platformBinaryLabel(), expected);
|
|
});
|
|
|
|
test.after(() => rmSync(dir, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 }));
|