Reputation: 310
I have a Julia package I developed locally, let's call it mypack
, and I can't automatically test it with Julia in pkg
mode. Running pkg>test mypack
gives me the following error:
(v1.3) pkg> test mypack
Updating registry at `~/.julia/environments/v1.3/registries/General`
Updating git-repo `https://github.com/JuliaRegistries/General.git`
Testing mypack
Resolving package versions...
[ Info: No changes
Status `/tmp/jl_m6URie/Manifest.toml`
[4e168b6d] mypack v0.1.0 [`~/Documents/mypack`]
ERROR: LoadError: ArgumentError: Package Test not found in current path:
- Run `import Pkg; Pkg.add("Test")` to install the Test package.
Stacktrace:
[1] require(::Module, ::Symbol) at ./loading.jl:887
[2] include at ./boot.jl:328 [inlined]
[3] include_relative(::Module, ::String) at ./loading.jl:1105
[4] include(::Module, ::String) at ./Base.jl:31
[5] include(::String) at ./client.jl:424
[6] top-level scope at none:6
in expression starting at /home/myname/Documents/mypack/test/runtests.jl:1
ERROR: Package mypack errored during testing
My mypack
project has the expected structure where there's a root directory with a Project.toml
and Manifest.toml
generated using ]generate mypack
. /test/runtests.jl
is just the line
using Test
This works on two machines that I've tested it on, one of which was using Julia 1.1 and one which was using Julia 1.2. The errors are happening on a new install of Julia 1.3.
I am able to test other packages (such as Statistics
just fine, which I did to make sure Test
was working). I have a more complicated project which brought this to my attention, but this mypack
MWE is also broken.
Upvotes: 5
Views: 1571
Reputation: 6956
When you run Pkg.test
, Pkg creates a test environment. This environment consists of direct dependencies and test dependencies. Any dependency which is imported by test/runtests.jl
needs to be in this test environment.
Because your test/runtests.jl
imports the Test
standard library, you need to add it as a test dependency. You can add test dependencies using this method: https://julialang.github.io/Pkg.jl/v1/creating-packages/#Test-specific-dependencies-in-Julia-1.0-and-1.1-1.
Upvotes: 5