diff --git a/Project.toml b/Project.toml index 4e61c3db..d13e4c03 100644 --- a/Project.toml +++ b/Project.toml @@ -31,7 +31,7 @@ TestItemRunner = "f8b46487-2199-4994-9208-9a1283c18c0a" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [compat] -TestItemDetection = "1.1" +TestItemDetection = "1.2" JuliaSyntax = "0.4, 1" PrecompileTools = "1.2" SHA = "<0.0.1, 0.7, 1" diff --git a/src/layer_testitems.jl b/src/layer_testitems.jl index 535b1bc7..c749c55e 100644 --- a/src/layer_testitems.jl +++ b/src/layer_testitems.jl @@ -57,6 +57,36 @@ Salsa.@derived function derived_testitems_selected(rt, uri) return path_selected(parse_path_filter!(discard, toml_content), relpath) end +""" + testitem_relative_path(package_uri, uri) -> String + +The path of `uri` relative to its package root, with `/` separators. This is the +first half of a test item id, so it must be stable across machines: relative so a +dev checkout and a CI runner agree, `/`-separated so Windows and Linux do. Falls +back to the full URI when there is no filesystem path to work with. +""" +function testitem_relative_path(package_uri::Union{URI,Nothing}, uri::URI) + if package_uri !== nothing + package_path = uri2filepath(package_uri) + file_path = uri2filepath(uri) + + if package_path !== nothing && file_path !== nothing + relpath = config_relative_path(package_path, file_path) + relpath === nothing || return relpath + end + end + + return string(uri) +end + +function _label_counts(labels) + counts = Dict{String,Int}() + for label in labels + counts[label] = get(counts, label, 0) + 1 + end + return counts +end + Salsa.@derived function derived_testitems(rt, uri) @debug "derived_testitems" uri=uri @@ -118,17 +148,71 @@ Salsa.@derived function derived_testitems(rt, uri) ) end + all_testerrors = TestErrorDetail[ + TestErrorDetail( + uri, + "$uri:error$i", + string(te.name), + te.message, + te.range + ) for (i,te) in enumerate(testerrors) + ] + + # Ids are `::