Skip to content

Commit

Permalink
Revert "Add kwarg succeed_on_precompilable_error" (#288)
Browse files Browse the repository at this point in the history
* Revert "Add kwarg `succeed_on_precompilable_error` (#285)"

This reverts commit 231a1d1.
  • Loading branch information
lgoettgens committed Apr 9, 2024
1 parent 468bbe8 commit 127f2be
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 62 deletions.
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## Version [v0.8.6] - 2024-04-09
## Unreleased

### Added
- Reverted [#285], which was originally released in [v0.8.6], but caused a regression. ([#287], [#288])

- `test_persistent_tasks` now accepts an optional `succeed_on_precompilable_error::Bool=true` to control the behavior on the occurrence of a `PrecompilableError`. ([#285])

## Version [v0.8.6] - 2024-04-09

### Changed

Expand Down
28 changes: 7 additions & 21 deletions src/persistent_tasks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ On Julia version 1.9 and before, this test always succeeds.
- `tmax::Real = 5`: the maximum time (in seconds) to wait after loading the
package before forcibly shutting down the precompilation process (triggering
a test failure).
- `succeed_on_precompilable_error::Bool = true`: If true, the test will pass if
the package has a precompilation error. The intended use is to keep your CI
green even if the case that a new release of a dependency introduces a
method overwrite that breaks precompilation of your package.
- `expr::Expr = quote end`: An expression to run in the precompile package.
!!! note
Expand All @@ -47,23 +43,10 @@ function test_persistent_tasks(package::Module; kwargs...)
test_persistent_tasks(PkgId(package); kwargs...)
end

function has_persistent_tasks(
package::PkgId;
expr::Expr = quote end,
succeed_on_precompilable_error::Bool = true,
tmax = 10,
)
@static if VERSION < v"1.10.0-"
return false
else
if Base.compilecache(package) isa Base.PrecompilableError
@error "Package $(package.name) has a precompilation error"
return !succeed_on_precompilable_error
end
root_project_path, found = root_project_toml(package)
found || error("Unable to locate Project.toml")
return !precompile_wrapper(root_project_path, tmax, expr)
end
function has_persistent_tasks(package::PkgId; expr::Expr = quote end, tmax = 10)
root_project_path, found = root_project_toml(package)
found || error("Unable to locate Project.toml")
return !precompile_wrapper(root_project_path, tmax, expr)
end

"""
Expand Down Expand Up @@ -92,6 +75,9 @@ function find_persistent_tasks_deps(package::Module; kwargs...)
end

function precompile_wrapper(project, tmax, expr)
@static if VERSION < v"1.10.0-"
return true
end
prev_project = Base.active_project()::String
isdefined(Pkg, :respect_sysimage_versions) && Pkg.respect_sysimage_versions(false)
try
Expand Down
2 changes: 0 additions & 2 deletions test/pkgs/PersistentTasks/PrecompilableErrorPkg/Project.toml

This file was deleted.

This file was deleted.

32 changes: 1 addition & 31 deletions test/test_persistent_tasks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ end
result = Aqua.find_persistent_tasks_deps(getid("UsesBoth"))
@test result == ["PersistentTask"]
end
filter!(str -> !occursin("PersistentTasks", str), LOAD_PATH)
end

@testset "test_persistent_tasks(expr)" begin
Expand All @@ -44,35 +45,4 @@ end
end
end

@testset "test_persistent_tasks(expr)" begin
if Base.VERSION >= v"1.10-"
@test !Aqua.has_persistent_tasks(
getid("TransientTask"),
expr = quote
fetch(Threads.@spawn nothing)
end,
)
@test Aqua.has_persistent_tasks(getid("TransientTask"), expr = quote
Threads.@spawn while true
sleep(0.5)
end
end)
end
end

@testset "test_persistent_tasks with precompilable error" begin
if Base.VERSION >= v"1.10-"
println("### Expected output START ###")
@test !Aqua.has_persistent_tasks(
getid("PrecompilableErrorPkg");
succeed_on_precompilable_error = true,
)
@test Aqua.has_persistent_tasks(
getid("PrecompilableErrorPkg");
succeed_on_precompilable_error = false,
)
println("### Expected output END ###")
end
end

end

0 comments on commit 127f2be

Please sign in to comment.