generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathtest_logger_tests.jl
71 lines (64 loc) · 1.57 KB
/
test_logger_tests.jl
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
include("test_logger.jl")
using Logging, Test
function simulate(text)
logger = Test.TestLogger()
output = IOBuffer()
with_logger(logger) do
stream, t = TestLogger.build_stream(output)
for line in eachline(IOBuffer(text); keep=true)
write(stream, line)
end
close(stream)
wait(t)
end
return String(take!(output)), logger.logs
end
@testset "TestLogger" begin
for input in (
"""
Test Failed at file.txt:1
1
2
3
4
5
6
Stacktrace:
Hi
""",
# Let us mess with the stacktrace line
"""
Test Failed at file.txt:1
1
2
3
4
5
6
Stacktrace: extra stuff
Hi
""")
output, logs = simulate(input)
@test output == input
log = only(logs)
@test log.message == "Test Failed\n1\n2\n3\n4\n5\n6"
@test log.file == "file.txt"
@test log.line == "1"
end
# Next, check that if we hit a Test Failed, and then hit another one before we get a stacktrace,
# we just move on to handling the new one.
input = """
Test Failed at file.txt:1
Nah
Test Failed at file.txt:1
Correct
Stacktrace:
Hi
"""
output, logs = simulate(input)
@test output == input
log = only(logs)
@test log.message == "Test Failed\nCorrect"
@test log.file == "file.txt"
@test log.line == "1"
end