Hi everyone,
I ran into a strange behaviour recently related to Julia environments. Let’s say I develop a package MyPackage
with the common structure:
├── Manifest.toml
├── Project.toml
├── src
└── test
├── runtests.jl
└── some_tests_included_in_runtests.jl
with the Project.toml
having [deps]
, [extras]
& [targets]
. When I activate this package by typing Pkg.activate(".")
in that folder and I run runtests.jl
all unit tests in some_tests_included_in_runtests.jl
work just fine as expected. However, when I test the package by using the package manager via ] test MyPackage
from any environment I’ll get a different result and the tests error. This must be some version-clashing. So I read a bit and found out that ] test MyPackage
sets up a “clean” environment, activating this, instantiating the package and runs the tests. So I am trying to reproduce these outcomes somehow and I am not able to do it.
In order to also mimic a “clean” environment I tried a few things:
- I removed
[extras]
&[targets]
from theProject.toml
and put it in anotherProject.toml
IN my/test
-folder (together with aManifest.toml
):
├── Manifest.toml
├── Project.toml
├── src
└── test
├── runtests.jl
├── Manifest.toml
├── Project.toml
└── some_tests_included_in_runtests.jl
Then I activated the /test
-folder, instantiated and also dev path/to/MyPackage
. Then I ran the runtests.jl
, but the tests pass and I can not reproduce the failing tests.
- To make sure it is really using only the deps I want I also included
empty!(LOAD_PATH)
followed bypush!(LOAD_PATH,"Project.toml")
at the beginning of theruntests.jl
(this will use the./test/Project.toml
). Still, the tests do pass.
What am I missing here? I’d like to know an easy way of setting up a clean environment and populate it with MyPackage
-dependencies, in order to write robust tests and being able to exactly reproduce what ] test MyPackage
is doing. No need to mention that when the different ways of running the tests already fail on my own machine, that they indeed fail on a GitHub-runner on different OS’ as well. This never happened to me before while developing other packages and the tests results were always identical on my local machine no matter which way I executed runtests.jl
.
Any help is appreciated,
Best
Hauke