Skip to content

Commit dbd232a

Browse files
make test name resemble original call
1 parent 32b9e85 commit dbd232a

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

test/buildkitetestjson.jl

+22-5
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,24 @@ function get_status(result)
112112
end
113113
end
114114

115+
# An attempt to reconstruct the test call.
116+
# Note we can't know if broken or skip was via the broken/skip macros or kwargs.
117+
function get_test_call(result)
118+
tt = result.test_type
119+
if tt in (:test, :test_nonbool, :test_error, :test_interrupted)
120+
"@test $(result.orig_expr)"
121+
elseif tt === :test_unbroken
122+
"@test_broken $(result.orig_expr)"
123+
elseif tt === :skipped
124+
"@test_skip $(result.orig_expr)"
125+
elseif tt === (:test_throws, :test_throws_wrong, :test_throws_nothing)
126+
expected = t.data
127+
"@test_throws $expected $(result.orig_expr)"
128+
elseif tt === :nontest_error
129+
"Non-test error"
130+
end
131+
end
132+
115133
function result_dict(result::Test.Result)
116134
file, line = if !hasproperty(result, :source) || isnothing(result.source)
117135
"unknown", 0
@@ -121,19 +139,18 @@ function result_dict(result::Test.Result)
121139
file = generalize_file_paths(string(file))
122140

123141
status = get_status(result)
124-
125-
result_show = sprint(show, result; context=:color => false)
126-
firstline = split(result_show, '\n')[1]
127-
primary_reason = split(firstline, " at ")[1]
142+
test_call = get_test_macro(result)
128143

129144
data = Dict{String,Any}(
130-
"name" => "$(primary_reason). Expression: $(result.orig_expr)",
145+
"name" => test_call,
131146
"location" => string(file, ':', line),
132147
"file_name" => file,
133148
"result" => status)
134149

135150
job_label = replace(get(ENV, "BUILDKITE_LABEL", "job label not found"), r":\w+:\s*" => "")
136151
if result isa Test.Fail || result isa Test.Error
152+
result_show = sprint(show, result; context=:color => false)
153+
firstline = split(result_show, '\n')[1]
137154
data["failure_reason"] = generalize_file_paths(firstline) * " | $job_label"
138155
err_trace = split(result_show, "\nStacktrace:\n", limit=2)
139156
if length(err_trace) == 2

0 commit comments

Comments
 (0)