From 7a1c3fce48f80c2ea8eeb46b94305fda16523bdd Mon Sep 17 00:00:00 2001 From: Thiago Tonelli Bartolomei Date: Fri, 22 Nov 2024 07:57:31 -0500 Subject: [PATCH] Lookup Julia tests on the package dir, not current dir (#22) The function to run Julia tests was resolving test files with respect to the current working directory, when it should resolve with respect to the package directory. --- Project.toml | 2 +- src/api.jl | 17 +++++++++++------ src/helpers.jl | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Project.toml b/Project.toml index 4da3f6c..b2138ce 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "RAIRelTest" uuid = "e61cca87-0504-4c6f-968f-8447d812e169" authors = ["Thiago Tonelli Bartolomei "] -version = "0.2.0" +version = "0.2.1" [deps] ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63" diff --git a/src/api.jl b/src/api.jl index d911d39..cf04f52 100644 --- a/src/api.jl +++ b/src/api.jl @@ -261,22 +261,23 @@ function run_testitems( package = pkg_name(package_dir) selectors = compute_test_selectors(changes) + test_dir = joinpath(package_dir, "test") try if isempty(selectors) # no selectors, run all tests - ReTestItems.runtests(joinpath(package_dir, "test"); name=name) + ReTestItems.runtests(test_dir; name=name) else paths = Vector{String}() for selector in selectors if isempty(selector.tests) - suitepath = joinpath("test/", selector.suite) + suitepath = joinpath(test_dir, selector.suite) if isdir(suitepath) # if the suite resolves to a directory, run all tests in it push!(paths, suitepath) else # otherwise, look for a file with the suite name and the julia test # suite convention, using underscores and the _tests.jl suffix. - suitefile = joinpath("test/", replace(selector.suite, "-" => "_")) * "_tests.jl" + suitefile = joinpath(test_dir, replace(selector.suite, "-" => "_")) * "_tests.jl" if isfile(suitefile) push!(paths, suitefile) else @@ -286,12 +287,16 @@ function run_testitems( else # only run the specific tests selected by the selector for test in selector.tests - push!(paths, joinpath(joinpath("test/", selector.suite), test)) + push!(paths, joinpath(joinpath(test_dir, selector.suite), test)) end end end - progress(package, "Running tests in the following paths: $paths") - ReTestItems.runtests(paths...; name=name) + if isempty(paths) + progress(package, "No Julia tests found for selectors: $selectors") + else + progress(package, "Running Julia tests in the following paths: $paths") + ReTestItems.runtests(paths...; name=name) + end end finally RAITest.set_clone_db!(nothing) diff --git a/src/helpers.jl b/src/helpers.jl index 08503b1..f96ab19 100644 --- a/src/helpers.jl +++ b/src/helpers.jl @@ -705,7 +705,7 @@ function compute_test_selectors(changed_paths::Union{Vector{T},Nothing}) where { # test/std/common/test-foo.rel || test/std/common/foo_test.jl if (endswith(path, ".rel") && occursin("test-", path)) || endswith(path, "_tests.jl") if !haskey(dict, key) - # create entry for this suite, targetting only this test + # create entry for this suite, targeting only this test dict[key] = [unix_basename(path)] elseif !isempty(dict[key]) # if there are already tests in the suite, add this one