Files
OmniRoute/tests/unit/cli-setup-opencode-nested-alias-7682.test.ts
Diego Rodrigues de Sa e Souza 93265eede3 test(infra): retry recursive temp-dir removal on main (main twin of #11968) (#12246)
* test(infra): retry recursive temp-dir removal on main (main twin of #11968)

`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.

* chore(scripts): carry the rm-maxretries codemod onto main alongside its output

The codemod that generated the previous commit lives in the repo on
release/v3.8.51 (added by #11968) but was never on main. Bringing it over keeps
the tool next to the change it produced, so the transformation stays
reproducible and auditable from either branch.
2026-09-01 01:48:00 -03:00

43 lines
1.6 KiB
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import { mkdtempSync, cpSync, symlinkSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join, dirname } from "node:path";
import { fileURLToPath } from "node:url";
import { spawnSync } from "node:child_process";
const HERE = dirname(fileURLToPath(import.meta.url));
const REPO_ROOT = join(HERE, "..", "..");
test("config-generator/opencode.ts imports cleanly with no tsconfig.json in scope (repro #7682)", () => {
const stage = mkdtempSync(join(tmpdir(), "omniroute-pkg-stage-7682-"));
try {
for (const rel of ["bin", "src/lib", "src/shared"]) {
cpSync(join(REPO_ROOT, rel), join(stage, rel), { recursive: true });
}
cpSync(join(REPO_ROOT, "package.json"), join(stage, "package.json"));
symlinkSync(join(REPO_ROOT, "node_modules"), join(stage, "node_modules"), "dir");
const probeScript = join(stage, "probe-import.mjs");
writeFileSync(
probeScript,
`await import("tsx/esm");
await import("./src/lib/cli-helper/config-generator/opencode.ts");
console.log("IMPORT_OK");
`
);
const result = spawnSync(process.execPath, [probeScript], { cwd: stage, encoding: "utf8" });
assert.equal(
result.stdout.includes("IMPORT_OK"),
true,
`expected config-generator/opencode.ts to import cleanly from a tsconfig-less ` +
`directory (as it will inside a real global npm install), but it failed:\n` +
`stdout: ${result.stdout}\nstderr: ${result.stderr}`
);
} finally {
rmSync(stage, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
}
});