Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to check whether we are already in an testenv? #51

Open
schlichtanders opened this issue Nov 6, 2022 · 4 comments
Open

How to check whether we are already in an testenv? #51

schlichtanders opened this issue Nov 6, 2022 · 4 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@schlichtanders
Copy link

schlichtanders commented Nov 6, 2022

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
@schlichtanders
Copy link
Author

my current workaround is try and catch

try import TestEnv; TestEnv.activate(); catch; end

@oxinabox
Copy link
Member

oxinabox commented Nov 7, 2022

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))

@oxinabox oxinabox added enhancement New feature or request good first issue Good for newcomers labels Nov 7, 2022
@nrontsis
Copy link

nrontsis commented Feb 13, 2023

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?

@oxinabox
Copy link
Member

oxinabox commented Mar 8, 2023

Yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants