krz/hutch

an ios client for sourcehut

clone: git clone https://gitbay.org/krz/hutch.git

main: HutchTests/BuildTaskLogSearchTests.swift · raw

 1import Testing
 2@testable import Hutch
 3
 4@MainActor
 5struct BuildTaskLogSearchTests {
 6
 7    @Test
 8    func logMatchRangesFindsCaseInsensitiveOccurrences() {
 9        let matches = logMatchRanges(in: "Error: one\nerror: two\nwarning", query: "ERROR")
10
11        #expect(matches.count == 2)
12        #expect(matches[0] == LogTextRange(location: 0, length: 5))
13        #expect(matches[1].location > matches[0].location)
14    }
15
16    @Test
17    func detectLogAnchorsFindsImportantFailureLines() {
18        let anchors = detectLogAnchors(in: """
19        compile step
20        warning: this is fine
21        error: missing header
22        traceback (most recent call last):
23        panic: build failed
24        """)
25
26        #expect(anchors.count == 2)
27        #expect(anchors[0].lineNumber == 3)
28        #expect(anchors[0].label.contains("missing header"))
29        #expect(anchors[1].lineNumber == 5)
30    }
31}