Skip to content
Open
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ Pkg v1.13 Release Notes

- Project.toml environments now support a `readonly` field to mark environments as read-only, preventing modifications.
([#4284])
- `Pkg.test` now supports a `quiet` keyword argument and `--quiet` flag to suppress the dependency listing output before
running tests.
([#3405])
- `Pkg.build` now supports an `allow_reresolve` keyword argument to control whether the build process can re-resolve
package versions, similar to the existing option for `Pkg.test`. ([#3329])
- Packages are now automatically added to `[sources]` when they are added by url or devved. ([#4225])
Expand Down
2 changes: 2 additions & 0 deletions src/API.jl
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,7 @@ function test(
force_latest_compatible_version::Bool = false,
allow_earlier_backwards_compatible_versions::Bool = true,
allow_reresolve::Bool = true,
quiet::Bool = false,
kwargs...
)
julia_args = Cmd(julia_args)
Expand All @@ -555,6 +556,7 @@ function test(
force_latest_compatible_version,
allow_earlier_backwards_compatible_versions,
allow_reresolve,
quiet,
)
return
end
Expand Down
11 changes: 8 additions & 3 deletions src/Operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2617,7 +2617,8 @@ function test(
test_fn = nothing,
force_latest_compatible_version::Bool = false,
allow_earlier_backwards_compatible_versions::Bool = true,
allow_reresolve::Bool = true
allow_reresolve::Bool = true,
quiet::Bool = false
)
Pkg.instantiate(ctx; allow_autoprecomp = false) # do precomp later within sandbox

Expand Down Expand Up @@ -2663,7 +2664,9 @@ function test(
env = EnvCache(proj)
# Instantiate test env
Pkg.instantiate(Context(env = env); allow_autoprecomp = false)
status(env, ctx.registries; mode = PKGMODE_COMBINED, io = ctx.io, ignore_indent = false, show_usagetips = false)
if !quiet
status(env, ctx.registries; mode = PKGMODE_COMBINED, io = ctx.io, ignore_indent = false, show_usagetips = false)
end
flags = gen_subprocess_flags(source_path; coverage, julia_args)

if should_autoprecompile()
Expand Down Expand Up @@ -2708,7 +2711,9 @@ function test(
sandbox(ctx, pkg, testdir(source_path), test_project_override; preferences = test_project_preferences, force_latest_compatible_version, allow_earlier_backwards_compatible_versions, allow_reresolve) do
test_fn !== nothing && test_fn()
sandbox_ctx = Context(; io = ctx.io)
status(sandbox_ctx.env, sandbox_ctx.registries; mode = PKGMODE_COMBINED, io = sandbox_ctx.io, ignore_indent = false, show_usagetips = false)
if !quiet
status(sandbox_ctx.env, sandbox_ctx.registries; mode = PKGMODE_COMBINED, io = sandbox_ctx.io, ignore_indent = false, show_usagetips = false)
end
flags = gen_subprocess_flags(source_path; coverage, julia_args)

if should_autoprecompile()
Expand Down
4 changes: 4 additions & 0 deletions src/Pkg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -364,13 +364,17 @@ const update = API.up
- `allow_reresolve::Bool=true`: allow Pkg to reresolve the package versions in the test environment
- `julia_args::Union{Cmd, Vector{String}}`: options to be passed the test process.
- `test_args::Union{Cmd, Vector{String}}`: test arguments (`ARGS`) available in the test process.
- `quiet::Bool=false`: suppress the dependency listing output before running tests.

!!! compat "Julia 1.9"
`allow_reresolve` requires at least Julia 1.9.

!!! compat "Julia 1.9"
Passing a string to `coverage` requires at least Julia 1.9.

!!! compat "Julia 1.13"
`quiet` requires at least Julia 1.13.

Run the tests for the given package(s), or for the current project if no positional argument is given to `Pkg.test`
(the current project would need to be a package). The package is tested by running its `test/runtests.jl` file.

Expand Down
6 changes: 4 additions & 2 deletions src/REPLMode/command_declarations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@ compound_declarations = [
:arg_parser => parse_package,
:option_spec => [
PSA[:name => "coverage", :api => :coverage => true],
PSA[:name => "quiet", :api => :quiet => true],
],
:completions => :complete_installed_packages,
:description => "run tests for packages",
:help => md"""
test [--coverage] [pkg[=uuid]] ...
test [--coverage] [--quiet] [pkg[=uuid]] ...

Run the tests for package `pkg`, or for the current project (which thus needs to be
a package) if `pkg` is omitted. This is done by running the file `test/runtests.jl`
in the package directory. The option `--coverage` can be used to run the tests with
coverage enabled. The `startup.jl` file is disabled during testing unless
coverage enabled. The option `--quiet` can be used to suppress the dependency listing
output before running tests. The `startup.jl` file is disabled during testing unless
julia is started with `--startup-file=yes`.
""",
],
Expand Down