How to check whether we are already in an testenv?
The test_env path is very cryptic. It would be great, if it could include testenv or some other explicit name, which makes it easy to check, whether we have already loaded the test environment.
Usecase: Get idempotent execution
import TestEnv
if "testenv" ∉ Base.active_project()
TestEnv.activate()
end
my current workaround is try and catch
try import TestEnv; TestEnv.activate(); catch; end
I think that would be a good idea, to include it in the path.
I think that change would be faily easy.
Just change where we mktempdir to mkdir(joinpath(mktempdir, testenv))
Perhaps it would be better to have a function TestEnv.in_test_env()::Bool that would return true either:
- if
TestEnv.activate()has been called before - or if within a
Pkg.test()execution
and false otherwise?
Yes.