Often when debugging a failing test I want run a snipped of code in the REPL from my tests.
But often that snippet uses something (like
ChainRulesTestUtil) which is not a main dependency of my package, just a test dependency.
If using the 1.2 feature that adds seperate test/Project.toml you can hack around with your LOAD_PATH to kinda get this to work, but that doesn’t work if you use the
[extras] section of the main Project.toml (which I kinda prefer), and it doesn’t work on 1.0 etc.
And using the separate test/Project.toml requires you to drop 1.0 support.
Wouldn’t be nicer if I could just do
and have that work on all julia versions and both ways of setting up your test dependencies ?
Mal Miller and I have created a package: TestEnv.jl which allows you to do just that.
Full credit to the Pkg developers for doing the actual hard work to write code for having test environments, that we hacked up to make it possible to activate them.
We basically cut the sandbox in half, so that it is created but not cleaned up.
This works with all julia versions.
Though because it accesses internals of Pkg it is very fragile to changes in Pkg – almost ever single minor release of julia breaks this.
So we have not yet tagged a release off the (currently working)
My own plan is to add this to my global environment and probably to my startup.jl