Pkg.jl: Load all of my package's dependencies into the test environment

Created on 14 Nov 2019  Â·  9Comments  Â·  Source: JuliaLang/Pkg.jl

Would be fixed by #1233

—-

Suppose that you have a package Foo. And suppose that the contents of Foo.jl/Project.toml are:

name = "Foo"
uuid = "..."
version = "1.0.0"

[deps]
PkgA = "..."
PkgB = "..."
PkgC = "..."

[compat]
PkgA = "1"
PkgB = "2"
PkgC = "3"
julia = "1"

And suppose that the contents of Foo.jl/test/Project.toml are:

[deps]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

On Julia 1.2 and higher, when I do Pkg.test("Foo"), the dependencies PkgA, PkgB, and PkgC are not available in the test environment. I think that this is good behavior by default.

But sometimes, I need to override the default behavior and use the dependencies inside the test environment.

Obviously I can manually add all PkgA, PkgB, and PkgC to Foo.jl/test/Project.toml. But this can get quite inconvenient when I have a lot of dependencies.

Is there an easy way that I can load all of the dependencies of Foo into the test environment with a single command?

Most helpful comment

You mean as a replacement for test/Project.toml?

1233 also uses test/Project.toml, only changes how it interacts with the parent env.

Well we can't get rid of test/Project.toml, right? The functionality to use test/Project.toml to list test-only dependencies exists in Julia 1.2. To remove it would be breaking.

We added a note about it that it is pretty beta and might be subject to change: https://julialang.github.io/Pkg.jl/v1/creating-packages/#Test-specific-dependencies-in-Julia-1.2-and-above-1

All 9 comments

cc: @00vareladavid

This seems like something reasonable to want. We could add a flag for this

IMO we should just have #1233

You mean as a replacement for test/Project.toml?

Well we can't get rid of test/Project.toml, right? The functionality to use test/Project.toml to list test-only dependencies exists in Julia 1.2. To remove it would be breaking.

You mean as a replacement for test/Project.toml?

1233 also uses test/Project.toml, only changes how it interacts with the parent env.

Well we can't get rid of test/Project.toml, right? The functionality to use test/Project.toml to list test-only dependencies exists in Julia 1.2. To remove it would be breaking.

We added a note about it that it is pretty beta and might be subject to change: https://julialang.github.io/Pkg.jl/v1/creating-packages/#Test-specific-dependencies-in-Julia-1.2-and-above-1

In #1233, do the “sub projects” include all of the packages from the “parent project”?

If so, then yes #1233 would solve my issue!

Yea, test/Project.toml would just be a layer on top of Project.toml.

I’m convinced that #1233 would solve this issue.

Closing as duplicate of #1233

Was this page helpful?
0 / 5 - 0 ratings