mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-06 07:12:12 +03:00
test(cli): deflake cli-setup-opencode.test.ts — silence console (#5959-class landmine) (#6033)
The command under test prints CLI progress with multi-byte glyphs (printSuccess "✔" in the happy paths, printError "✖" in the dist-missing path that test 4 exercises) via console.log. Under the node:test runner those child-stdout writes interleave with the V8-serialized report frames and can corrupt the stream — the exact #5959 mechanism proven for setup-claude.test.ts; this file's ✖ line was already visible entangled in red CI runs. No test here asserts on stdout, so silence console.log/info/ warn for the file (same pattern as #6019/#6021, restored in after()). Validation: pre-fix the ✖/✔ lines reach stdout every run (grep-able); post-fix stdout is clean, 4/4 tests green, 0/20 failures across 20 runs.
This commit is contained in:
committed by
GitHub
parent
3b512f4b47
commit
31e80a9328
@@ -14,6 +14,7 @@
|
||||
### 🔧 Bug Fixes
|
||||
|
||||
- **tests(cli):** stabilize `setup-claude.test.ts` (#5959) — the dry-run path printed a multi-byte "──" heading to the test child's stdout, corrupting the node:test runner's V8-serialized event stream in ~50% of runs ("Unable to deserialize cloned data due to invalid or unsupported version") and randomly failing the PR→release queue. `syncClaudeProfilesFromModels` now accepts an injectable `log` sink (CLI default unchanged: `console.log`); the test injects a collector and gains assertions on the dry-run report. Validated 0/30 failures post-fix vs 5/10 on the pristine base.
|
||||
- **tests(cli):** deflake `cli-setup-opencode.test.ts` preemptively — same #5959 class: the command under test prints multi-byte "✔"/"✖" CLI glyphs to the test child's stdout, which can corrupt the node:test V8 report stream. Console silenced for the file (pattern of #6019/#6021); no test asserts on stdout. 0/20 failures, stdout clean.
|
||||
- **tests(ci):** collect the orphaned `tests/unit/executors/` directory (created by #5800 outside every runner glob — its 2 test files never ran anywhere). Added `executors` to the unit-runner brace globs (package.json, ci.yml shards, quality.yml TIA, test-impact map, test-discovery gate); both files pass (10/10).
|
||||
|
||||
### 📝 Maintenance
|
||||
|
||||
@@ -40,12 +40,27 @@ function readConfig() {
|
||||
return JSON.parse(fs.readFileSync(path.join(CONFIG_DIR, "opencode.json"), "utf8"));
|
||||
}
|
||||
|
||||
// #5959-class deflake: the command under test prints CLI progress with multi-byte
|
||||
// glyphs (printInfo/printSuccess "✔"/printError "✖" via console.log). Under the
|
||||
// node:test runner those stdout writes interleave with the child's V8-serialized
|
||||
// report frames and can corrupt the stream ("Unable to deserialize cloned data
|
||||
// due to invalid or unsupported version"). No test here asserts on stdout, so
|
||||
// silence the stdout-writing console methods for the duration of this file
|
||||
// (same pattern as tests/unit/cli/setup-claude.test.ts, #6019/#6021).
|
||||
const _console = { log: console.log, info: console.info, warn: console.warn };
|
||||
|
||||
describe("omniroute setup opencode", () => {
|
||||
before(() => {
|
||||
console.log = () => {};
|
||||
console.info = () => {};
|
||||
console.warn = () => {};
|
||||
makeFakePluginDist();
|
||||
});
|
||||
|
||||
after(() => {
|
||||
console.log = _console.log;
|
||||
console.info = _console.info;
|
||||
console.warn = _console.warn;
|
||||
try {
|
||||
fs.rmSync(FIXTURE_ROOT, { recursive: true, force: true });
|
||||
} catch {
|
||||
@@ -72,7 +87,11 @@ describe("omniroute setup opencode", () => {
|
||||
const [modulePath, options] = cfg.plugin[0];
|
||||
assert.equal(modulePath, "./plugins/omniroute/dist/index.js");
|
||||
assert.equal(options.providerId, "omniroute");
|
||||
assert.equal(options.baseURL, "http://10.0.0.5:20128", "--base-url flag must reach the registered entry");
|
||||
assert.equal(
|
||||
options.baseURL,
|
||||
"http://10.0.0.5:20128",
|
||||
"--base-url flag must reach the registered entry"
|
||||
);
|
||||
});
|
||||
|
||||
it("is idempotent: re-running updates the entry in place instead of duplicating it", async () => {
|
||||
@@ -85,10 +104,15 @@ describe("omniroute setup opencode", () => {
|
||||
|
||||
const cfg = readConfig();
|
||||
const omniEntries = cfg.plugin.filter(
|
||||
(p: unknown) => Array.isArray(p) && (p[1] as { providerId?: string })?.providerId === "omniroute"
|
||||
(p: unknown) =>
|
||||
Array.isArray(p) && (p[1] as { providerId?: string })?.providerId === "omniroute"
|
||||
);
|
||||
assert.equal(omniEntries.length, 1, "re-run must not duplicate the entry");
|
||||
assert.equal(omniEntries[0][1].baseURL, "http://10.0.0.9:20128", "re-run updates baseURL in place");
|
||||
assert.equal(
|
||||
omniEntries[0][1].baseURL,
|
||||
"http://10.0.0.9:20128",
|
||||
"re-run updates baseURL in place"
|
||||
);
|
||||
});
|
||||
|
||||
it("removes the legacy opencode-omniroute-auth entry (#3711) and preserves unrelated plugins", async () => {
|
||||
|
||||
Reference in New Issue
Block a user