Commit 62244b4dc2

62244b4dc27f53084c2e5de0d5db97816217c77d

parent: 0d88e898d3

Verified · cmc

cmc <hello@cleberg.net> · 2026-11-25 22:43 UTC

Give the JavaScript cancel test room on a busy machine

The two runs had to finish in 2 s against a 3 s spin. Ref #204

Layout: unified · split

Tests/OrgAppTests/JavaScriptBlocksTests.swift +4 −2 · view
@@ -255,14 +255,16 @@ struct JavaScriptBlocksTests {
255255 @Test func cancelAndTimeoutEndTheRun() async throws {
256256 let folder = FileManager.default.temporaryDirectory
257257 // Spins for seconds, as an endless loop would, but ends so the test leaves no thread busy.
258 let spin = try Self.plan("#+begin_src js\nconst end = Date.now() + 3000; while (Date.now() < end) {}\n#+end_src\n")
258 // Run to its end the two runs take 16 s of wall time whatever the load, so a limit well
259 // under that tells stopping from finishing on a busy machine too.
260 let spin = try Self.plan("#+begin_src js\nconst end = Date.now() + 8000; while (Date.now() < end) {}\n#+end_src\n")
259261 let start = ContinuousClock.now
260262 let task = Task { try await JavaScriptBlocks.run(spin, directory: folder) }
261263 try await Task.sleep(for: .milliseconds(100))
262264 task.cancel()
263265 await #expect(throws: CancellationError.self) { try await task.value }
264266 await #expect(throws: JavaScriptBlocks.Stopped.self) { try await JavaScriptBlocks.run(spin, directory: folder, timeout: .milliseconds(100)) }
265 #expect(ContinuousClock.now - start < .seconds(2))
267 #expect(ContinuousClock.now - start < .seconds(6))
266268 let interval = try Self.plan("#+begin_src js :results output\nsetInterval(() => {}, 10)\n#+end_src\n")
267269 await #expect(throws: JavaScriptBlocks.Stopped.self) { try await JavaScriptBlocks.run(interval, directory: folder, timeout: .milliseconds(100)) }
268270 }
Keyboard shortcuts

Global

⌘K
Command palette & jump
/
Focus search
?
Show this help
g d
Dashboard
g e
Explore repositories
g n
Notifications

Repository & editor

t
Find file in repository
y
Copy immutable SHA permalink
g c
Code tab
g i
Issues tab
g m
Merge requests tab
g b
Builds tab
⌘↵
Submit active form