Commit ace1a9a099

ace1a9a099c5ca37033f51a20c0706249399c386

parent: d14a973265

Verified · cmc

cmc <hello@cleberg.net> · 2026-11-22 20:15 UTC

Call the throwing backlinks from the workspace gates

Ref #193

Layout: unified · split

Tests/OrgEditorAppKitTests/WorkspaceGateTests.swift +6 −6
@@ -51,12 +51,12 @@ extension GateTests {
51 } 51 }
52 52
53 /// One pass of the backlinks pane: the file's backlinks and the heading's. 53 /// One pass of the backlinks pane: the file's backlinks and the heading's.
54 static func backlinks(_ model: WorkspaceModel) -> (found: Int, time: Duration) { 54 static func backlinks(_ model: WorkspaceModel) throws -> (found: Int, time: Duration) {
55 let path = model.files.first { $0.name == "note-0.org" }!.path 55 let path = model.files.first { $0.name == "note-0.org" }!.path
56 var found = 0 56 var found = 0
57 let time = ContinuousClock().measure { 57 let time = try ContinuousClock().measure {
58 found += model.backlinks(to: Backlinks.Target(path: path)).count 58 found += try model.backlinks(to: Backlinks.Target(path: path)).count
59 found += model.backlinks(to: Backlinks.Target(path: path, title: "Heading 0.1", id: "0-1")).count 59 found += try model.backlinks(to: Backlinks.Target(path: path, title: "Heading 0.1", id: "0-1")).count
60 } 60 }
61 return (found, time) 61 return (found, time)
62 } 62 }
@@ -78,7 +78,7 @@ extension GateTests {
78 let items = agenda.days.reduce(0) { $0 + $1.items.count } 78 let items = agenda.days.reduce(0) { $0 + $1.items.count }
79 #expect(items > 0) 79 #expect(items > 0)
80 80
81 let (found, backlinks) = Self.backlinks(model) 81 let (found, backlinks) = try Self.backlinks(model)
82 #expect(found > 0) 82 #expect(found > 0)
83 print("GATE 10,000 notes: index build \(build), agenda refresh cold \(cold) / warm \(warm) (\(items) items), backlinks over 49,400 links \(backlinks)") 83 print("GATE 10,000 notes: index build \(build), agenda refresh cold \(cold) / warm \(warm) (\(items) items), backlinks over 49,400 links \(backlinks)")
84 #expect(build < .seconds(15), "index build") 84 #expect(build < .seconds(15), "index build")
@@ -92,7 +92,7 @@ extension GateTests {
92 let scratch = try Self.scratch() 92 let scratch = try Self.scratch()
93 defer { try? FileManager.default.removeItem(at: scratch) } 93 defer { try? FileManager.default.removeItem(at: scratch) }
94 let (model, _) = try await Self.workspace(1_000, fiveLinks: 1_000, in: scratch) 94 let (model, _) = try await Self.workspace(1_000, fiveLinks: 1_000, in: scratch)
95 let (found, time) = Self.backlinks(model) 95 let (found, time) = try Self.backlinks(model)
96 #expect(found > 0) 96 #expect(found > 0)
97 print("GATE 1,000 notes: backlinks over 5,000 links \(time)") 97 print("GATE 1,000 notes: backlinks over 5,000 links \(time)")
98 #expect(time < .milliseconds(150), "backlinks, 5,000 links") 98 #expect(time < .milliseconds(150), "backlinks, 5,000 links")