Julia 无法测试用户包

Qti*_*edQ 5 julia

我有一个我在本地开发的 Julia 包,我们称之为mypack,我无法在 Juliapkg模式下自动测试它。运行pkg>test mypack给了我以下错误:

(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
Run Code Online (Sandbox Code Playgroud)

我的mypack项目具有预期的结构,其中有一个带有 a 的根目录Project.tomlManifest.toml使用]generate mypack. /test/runtests.jl只是线

using Test
Run Code Online (Sandbox Code Playgroud)

这适用于我测试过的两台机器,其中一台使用 Julia 1.1,另一台使用 Julia 1.2。错误发生在新安装的 Julia 1.3 上。

我能够测试其他软件包(例如Statistics很好,我这样做是为了确保Test工作正常)。我有一个更复杂的项目引起了我的注意,但是这个mypackMWE 也坏了。

Dav*_*ela 5

运行时Pkg.test,Pkg 会创建一个测试环境。此环境由直接依赖项和测试依赖项组成。导入的任何依赖项都test/runtests.jl需要在此测试环境中。

由于您test/runtests.jl导入了Test标准库,因此您需要将其添加为测试依赖项。您可以使用此方法添加测试依赖项:https : //julialang.github.io/Pkg.jl/v1/creating-packages/#Test-specific-dependencies-in-Julia-1.0-and-1.1-1