比較提交

..
1 次程式碼提交
作者 SHA1 備註 日期
sneak 8c7bef0719 Fix two intermittently failing library tests (closes #90)
check / check (push) Successful in 26s
Library.close() now returns a promise that resolves once the work it
started has finished: an in-flight refresh with its cache write, the ML
data fetch, and running precache sweeps. The interval test could see a
refresh's new state, close, and remove the directory while the write was
still running. Every library test and CLI command now awaits close(), and
tests hold each of the three writes open to prove close() waits for it.

The precache test waited for its stub source to be called, but the cache
records a file only after checking it on disk, so status() could lag. It
now waits for both fills to report "done".

Model: opus-5-5
2026-09-23 02:08:14 +00:00
共有 2 個檔案被更改,包括 22 行新增32 行删除
+12 -17
查看文件
@@ -478,24 +478,19 @@ describe("Library ML-data fetch on refresh", () => {
cacheDirectory, cacheDirectory,
refreshIntervalSeconds: 3600, refreshIntervalSeconds: 3600,
}); });
try { await started;
await started;
let closed = false; let closed = false;
const closing = lib.close().then(() => { const closing = lib.close().then(() => {
closed = true; closed = true;
}); });
await new Promise((r) => setTimeout(r, 20)); await new Promise((r) => setTimeout(r, 20));
expect(closed).toBe(false); expect(closed).toBe(false);
release(); release();
await closing; await closing;
expect( expect(existsSync(join(cacheDirectory, "mldata", "1001.json"))).toBe(
existsSync(join(cacheDirectory, "mldata", "1001.json")), true,
).toBe(true); );
} finally {
release();
await lib.close();
}
}); });
}); });
+10 -15
查看文件
@@ -471,22 +471,17 @@ describe("Precache through Library.open", () => {
refreshIntervalSeconds: 3600, refreshIntervalSeconds: 3600,
precacheOriginals: false, precacheOriginals: false,
}); });
try { const destination = await started;
const destination = await started;
let closed = false; let closed = false;
const closing = lib.close().then(() => { const closing = lib.close().then(() => {
closed = true; closed = true;
}); });
await new Promise((r) => setTimeout(r, 20)); await new Promise((r) => setTimeout(r, 20));
expect(closed).toBe(false); expect(closed).toBe(false);
release(); release();
await closing; await closing;
expect(existsSync(destination)).toBe(true); expect(existsSync(destination)).toBe(true);
} finally {
release();
await lib.close();
}
}); });
}); });