Skip to content

Commit 86829c5

Browse files
speed up serialize_testset_result_file
1 parent a43c8a6 commit 86829c5

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

test/buildkitetestjson.jl

+13-4
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,16 @@ function generalize_file_paths(path::AbstractString)
104104
end
105105
end
106106

107+
# raw_file_path,line => file,location
108+
location_cache = Dict{Tuple{Symbol,Int},Tuple{String,String}}()
109+
function get_location(file::Symbol, line::Int)
110+
return get!(location_cache, (file, line)) do
111+
_file = generalize_file_paths(string(file))
112+
_location = string(_file, ":", line)
113+
return _file, _location
114+
end
115+
end
116+
107117
# passed, failed, skipped, or unknown
108118
function get_status(result)
109119
if result isa Test.Pass && result.test_type === :skipped
@@ -142,12 +152,11 @@ get_rid(rdata) = (rdata["location"], rdata["result"], haskey(rdata, "failure_exp
142152

143153
function result_dict(result::Test.Result, result_counts::Dict{Tuple{String,String,UInt64},Int})
144154
file, line = if !hasproperty(result, :source) || isnothing(result.source)
145-
"unknown", 0
155+
:unknown, 0
146156
else
147-
something(result.source.file, "unknown"), result.source.line
157+
something(result.source.file, :unknown), result.source.line
148158
end
149-
file = generalize_file_paths(string(file))
150-
location = string(file, ':', line)
159+
file, location = get_location(file, line)
151160
status = get_status(result)
152161

153162
# Early exit for passed tests before more expensive operations

0 commit comments

Comments
 (0)