Skip to content

Commit 7a1c3fc

Browse files
authored
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.
1 parent d9b4174 commit 7a1c3fc

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "RAIRelTest"
22
uuid = "e61cca87-0504-4c6f-968f-8447d812e169"
33
authors = ["Thiago Tonelli Bartolomei <[email protected]>"]
4-
version = "0.2.0"
4+
version = "0.2.1"
55

66
[deps]
77
ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63"

src/api.jl

+11-6
Original file line numberDiff line numberDiff line change
@@ -261,22 +261,23 @@ function run_testitems(
261261

262262
package = pkg_name(package_dir)
263263
selectors = compute_test_selectors(changes)
264+
test_dir = joinpath(package_dir, "test")
264265
try
265266
if isempty(selectors)
266267
# no selectors, run all tests
267-
ReTestItems.runtests(joinpath(package_dir, "test"); name=name)
268+
ReTestItems.runtests(test_dir; name=name)
268269
else
269270
paths = Vector{String}()
270271
for selector in selectors
271272
if isempty(selector.tests)
272-
suitepath = joinpath("test/", selector.suite)
273+
suitepath = joinpath(test_dir, selector.suite)
273274
if isdir(suitepath)
274275
# if the suite resolves to a directory, run all tests in it
275276
push!(paths, suitepath)
276277
else
277278
# otherwise, look for a file with the suite name and the julia test
278279
# suite convention, using underscores and the _tests.jl suffix.
279-
suitefile = joinpath("test/", replace(selector.suite, "-" => "_")) * "_tests.jl"
280+
suitefile = joinpath(test_dir, replace(selector.suite, "-" => "_")) * "_tests.jl"
280281
if isfile(suitefile)
281282
push!(paths, suitefile)
282283
else
@@ -286,12 +287,16 @@ function run_testitems(
286287
else
287288
# only run the specific tests selected by the selector
288289
for test in selector.tests
289-
push!(paths, joinpath(joinpath("test/", selector.suite), test))
290+
push!(paths, joinpath(joinpath(test_dir, selector.suite), test))
290291
end
291292
end
292293
end
293-
progress(package, "Running tests in the following paths: $paths")
294-
ReTestItems.runtests(paths...; name=name)
294+
if isempty(paths)
295+
progress(package, "No Julia tests found for selectors: $selectors")
296+
else
297+
progress(package, "Running Julia tests in the following paths: $paths")
298+
ReTestItems.runtests(paths...; name=name)
299+
end
295300
end
296301
finally
297302
RAITest.set_clone_db!(nothing)

src/helpers.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ function compute_test_selectors(changed_paths::Union{Vector{T},Nothing}) where {
705705
# test/std/common/test-foo.rel || test/std/common/foo_test.jl
706706
if (endswith(path, ".rel") && occursin("test-", path)) || endswith(path, "_tests.jl")
707707
if !haskey(dict, key)
708-
# create entry for this suite, targetting only this test
708+
# create entry for this suite, targeting only this test
709709
dict[key] = [unix_basename(path)]
710710
elseif !isempty(dict[key])
711711
# if there are already tests in the suite, add this one

0 commit comments

Comments
 (0)