Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 3 additions & 14 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
version:
- '1.8'
- '1.10'
- '1.11'
- '~1.12.0-rc1'
os:
- ubuntu-latest
- macOS-latest
Expand All @@ -35,25 +35,14 @@ jobs:
- os: windows-latest
arch: x64
- os: windows-latest
version: 1.8
- os: windows-latest
version: 1.11
version: '1.8'
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v4
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- uses: julia-actions/cache@v2
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/julia-processcoverage@v1
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "ReTestItems"
uuid = "817f1d60-ba6b-4fd5-9520-3cf149f6a823"
version = "1.33.1"
version = "1.33.2"

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Expand Down
10 changes: 3 additions & 7 deletions src/ReTestItems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,7 @@ end

# for each directory, kick off a recursive test-finding task
# Returns (testitems::TestItems, setups::Dict{Symbol,TestSetup})
# Assumes `isdir(project_root)`, which is guaranteed by `_runtests`.
function include_testfiles!(project_name, projectfile, paths, ti_filter::TestItemFilter, verbose_results::Bool, report::Bool)
project_root = dirname(projectfile)
subproject_root = nothing # don't recurse into directories with their own Project.toml.
Expand Down Expand Up @@ -991,13 +992,8 @@ function should_skip(ti::TestItem)
skip_body = deepcopy(ti.skip::Expr)
softscope_all!(skip_body)
# Run in a new module to not pollute `Main`.
# Need to store the result of the `skip` expression so we can check it.
mod_name = gensym(Symbol(:skip_, ti.name))
skip_var = gensym(:skip)
skip_mod_expr = :(module $mod_name; $skip_var = $skip_body; end)
skip_mod = Core.eval(Main, skip_mod_expr)
# Check what the expression evaluated to.
skip = getfield(skip_mod, skip_var)
mod = Module(Symbol(:skip_, ti.name))
skip = Core.eval(mod, skip_body)
!isa(skip, Bool) && _throw_not_bool(ti, skip)
return skip::Bool
end
Expand Down
15 changes: 10 additions & 5 deletions test/integrationtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,12 @@ end
@test_throws ReTestItems.NoTestException runtests(ti -> :b_tag in ti.tags, pkg; name="b", tags=[:nope])

# can only filter on `ti.name` and `ti.tags` (at least for now)
@test_throws "no field file" runtests(ti -> contains(ti.file, "bar_"), pkg)
expected = if VERSION < v"1.12.0-DEV"
"no field file"
else
"no field `file`"
end
@test_throws expected runtests(ti -> contains(ti.file, "bar_"), pkg)
end

@testset "`@testitem` scoping rules" begin
Expand Down Expand Up @@ -942,7 +947,7 @@ end
@testset "non-zero timeout_profile_wait means we collect a CPU profile" begin
capture_timeout_profile(5) do logs
@test occursin("Information request received. A stacktrace will print followed by a $(default_peektime) second profile", logs)
@test count(r"pthread_cond_wait|__psych_cvwait", logs) > 0 # the stacktrace was printed (will fail on Windows)
@test count(r"pthread_cond_wait|__psynch_cvwait", logs) > 0 # the stacktrace was printed (will fail on Windows)
@test occursin("Profile collected.", logs)
end
end
Expand All @@ -951,7 +956,7 @@ end
@testset "`set_peek_duration` is respected in `worker_init_expr`" begin
capture_timeout_profile(5, worker_init_expr=:(using Profile; Profile.set_peek_duration($default_peektime + 1.0))) do logs
@test occursin("Information request received. A stacktrace will print followed by a $(default_peektime + 1.0) second profile", logs)
@test count(r"pthread_cond_wait|__psych_cvwait", logs) > 0 # the stacktrace was printed (will fail on Windows)
@test count(r"pthread_cond_wait|__psynch_cvwait", logs) > 0 # the stacktrace was printed (will fail on Windows)
@test occursin("Profile collected.", logs)
end
end
Expand All @@ -962,7 +967,7 @@ end
withenv("RETESTITEMS_TIMEOUT_PROFILE_WAIT" => "5") do
capture_timeout_profile(nothing) do logs
@test occursin("Information request received", logs)
@test count(r"pthread_cond_wait|__psych_cvwait", logs) > 0 # the stacktrace was printed (will fail on Windows)
@test count(r"pthread_cond_wait|__psynch_cvwait", logs) > 0 # the stacktrace was printed (will fail on Windows)
@test occursin("Profile collected.", logs)
end
end
Expand All @@ -972,7 +977,7 @@ end
@testset "CPU profile with $(repr(log_capture))" for log_capture in (:eager, :batched)
capture_timeout_profile(5, nworker_threads=VERSION >= v"1.9" ? "3,2" : "3", logs=log_capture) do logs
@test occursin("Information request received", logs)
@test count(r"pthread_cond_wait|__psych_cvwait", logs) > 0 # the stacktrace was printed (will fail on Windows)
@test count(r"pthread_cond_wait|__psynch_cvwait", logs) > 0 # the stacktrace was printed (will fail on Windows)
@test occursin("Profile collected.", logs)
end
end
Expand Down
9 changes: 5 additions & 4 deletions test/internals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,18 @@ end
shouldrun = TestItemFilter(Returns(true), nothing, nothing)
verbose_results = false
report = false
project = touch(joinpath(mktempdir(), "Project.toml"))

# Requesting only non-existent files/dirs should result in no files being included
ti, setups = include_testfiles!("proj", "/this/file/", ("/this/file/is/not/a/t-e-s-tfile.jl",), shouldrun, verbose_results, report)
ti, setups = include_testfiles!("proj", project, ("/this/file/is/not/a/t-e-s-tfile.jl",), shouldrun, verbose_results, report)
@test isempty(ti.testitems)
@test isempty(setups)

ti, setups = include_testfiles!("proj", "/this/file/", ("/this/file/does/not/exist/imaginary_tests.jl",), shouldrun, verbose_results, report)
ti, setups = include_testfiles!("proj", project, ("/this/file/does/not/exist/imaginary_tests.jl",), shouldrun, verbose_results, report)
@test isempty(ti.testitems)
@test isempty(setups)

ti, setups = include_testfiles!("proj", "/this/dir/", ("/this/dir/does/not/exist/", "/this/dir/also/not/exist/"), shouldrun, verbose_results, report)
ti, setups = include_testfiles!("proj", project, ("/this/dir/does/not/exist/", "/this/dir/also/not/exist/"), shouldrun, verbose_results, report)
@test isempty(ti.testitems)
@test isempty(setups)

Expand Down Expand Up @@ -300,7 +301,7 @@ end
end

@testset "should_skip" begin
should_skip = ReTestItems.should_skip
using ReTestItems: should_skip

ti = @testitem("x", skip=true, _run=false, begin end)
@test should_skip(ti)
Expand Down
19 changes: 12 additions & 7 deletions test/workers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,20 @@ using Test
return read(path, String)
end

@test occursin(r"Thread 1 Task 0x\w+ Total snapshots: \d+. Utilization: \d+%", logs)
@test occursin(r"Thread 2 Task 0x\w+ Total snapshots: \d+. Utilization: \d+%", logs)
@test occursin(r"Thread 3 Task 0x\w+ Total snapshots: \d+. Utilization: \d+%", logs)
# In Julia v1.12+ looks it prints the threadpool, like:
# Thread 1 (interactive) Task 0x00007f03563fc010 Total snapshots: 597. Utilization: 0%
# Thread 5 (default) Task 0x00007f03563fe2c0 Total snapshots: 597. Utilization: 20%
re_thread(i::Int) = Regex("Thread $i( \\((default|interactive)\\))? Task 0x")
@test occursin(re_thread(1), logs)
@test occursin(re_thread(2), logs)
@test occursin(re_thread(3), logs)

if VERSION >= v"1.9"
@test occursin(r"Thread 4 Task 0x\w+ Total snapshots: \d+. Utilization: \d+%", logs)
@test occursin(r"Thread 5 Task 0x\w+ Total snapshots: \d+. Utilization: \d+%", logs)
@test !occursin(r"Thread 6 Task 0x\w+ Total snapshots: \d+. Utilization: \d+%", logs)
@test occursin(re_thread(4), logs)
@test occursin(re_thread(5), logs)
@test !occursin(re_thread(6), logs)
else
@test !occursin(r"Thread 4 Task 0x\w+ Total snapshots: \d+. Utilization: \d+%", logs)
@test !occursin(re_thread(4), logs)
end
end
end
Expand Down
Loading