aboutsummaryrefslogtreecommitdiff
path: root/HutchTests/BuildTaskLogSearchTests.swift
blob: 4cb99845aaa1a729c0ae4c3d17bd48647936d07e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import Testing
@testable import Hutch

struct BuildTaskLogSearchTests {

    @Test
    func logMatchRangesFindsCaseInsensitiveOccurrences() {
        let matches = logMatchRanges(in: "Error: one\nerror: two\nwarning", query: "ERROR")

        #expect(matches.count == 2)
        #expect(matches[0] == LogTextRange(location: 0, length: 5))
        #expect(matches[1].location > matches[0].location)
    }

    @Test
    func detectLogAnchorsFindsImportantFailureLines() {
        let anchors = detectLogAnchors(in: """
        compile step
        warning: this is fine
        error: missing header
        traceback (most recent call last):
        panic: build failed
        """)

        #expect(anchors.count == 2)
        #expect(anchors[0].lineNumber == 3)
        #expect(anchors[0].label.contains("missing header"))
        #expect(anchors[1].lineNumber == 5)
    }
}