Recently Written · git

scan-subread

PDF reader that follows an audiobook with the SubRead suite

git clone https://github.com/equwal/scan-subread

Log | Files | Refs


commit 58a8e12683dcd26e4856189c7e64222fb1842157
truex <truex@equwal.com>
2026-09-26 17:48:53 -0700

Give the timed tests room for a busy machine

The aligner speed test failed at 4.3 s and the page cache property at 5.4 s while other builds ran. The bounds are now 8 s and 500 ms for the aligner, which still catch the old global diff (13 s for the book and for each page), and 30 s for the property.

 test/align.test.ts       | 10 +++++++---
 test/token-cache.test.ts |  3 ++-
 2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/test/align.test.ts b/test/align.test.ts
index cc3c16a..16b3f36 100644
--- a/test/align.test.ts
+++ b/test/align.test.ts
@@ -196,8 +196,12 @@ describe('createAligner', () => {
   });
 });
 
+// The bounds leave room for a busy machine: the aligner takes about 1 s and
+// 30 ms here, and took 4.3 s once under heavy load. The old global diff took
+// 13 s for the full book, and the same again for each page, so the test still
+// catches a return to it.
 describe('createAligner speed', () => {
-  it('aligns a book of 300 000 characters in under 3 s, and one more page in under 100 ms', () => {
+  it('aligns a book of 300 000 characters in under 8 s, and one more page in under 500 ms', () => {
     const LENGTH = 300_000;
     const PAGE = 600;
     // 5% noise: 3 codes in 60 are a drop, a substitution and an insertion.
@@ -233,7 +237,7 @@ describe('createAligner speed', () => {
     const one = performance.now() - t;
 
     expect(spans.filter((s) => s.matched).length).toBeGreaterThanOrEqual(0.99 * cues.length);
-    expect(all).toBeLessThan(3000);
-    expect(one).toBeLessThan(100);
+    expect(all).toBeLessThan(8000);
+    expect(one).toBeLessThan(500);
   }, 30_000);
 });
diff --git a/test/token-cache.test.ts b/test/token-cache.test.ts
index 98f900d..ff7e0b9 100644
--- a/test/token-cache.test.ts
+++ b/test/token-cache.test.ts
@@ -172,6 +172,7 @@ describe('token cache', () => {
     expect(await cache.getPage(keys[2])).toBeUndefined();
   });
 
+  // 100 runs of IndexedDB work take about 2 s, and more than the 5 s default on a busy machine.
   it('clears each page key that starts with the book key and "|", and no other key', async () => {
     const cache = await freshCache();
     const separator = fc.constantFrom('|', '||', '}', '{', '', '￿');
@@ -188,7 +189,7 @@ describe('token cache', () => {
         }
       }),
     );
-  });
+  }, 30_000);
 
   it('works without IndexedDB, and warns once', async () => {
     const warn = vi.spyOn(console, 'warn').mockImplementation(() => undefined);