Skip to content

Commit

Permalink
Lookup Julia tests on the package dir, not current dir (#22)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ttonelli authored Nov 22, 2024
1 parent d9b4174 commit 7a1c3fc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "RAIRelTest"
uuid = "e61cca87-0504-4c6f-968f-8447d812e169"
authors = ["Thiago Tonelli Bartolomei <[email protected]>"]
version = "0.2.0"
version = "0.2.1"

[deps]
ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63"
Expand Down
17 changes: 11 additions & 6 deletions src/api.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/helpers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7a1c3fc

Please sign in to comment.