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

tests: adjust the project and load path to add test dependencies in test_module #3357

Merged
merged 1 commit into from
Feb 13, 2024

Conversation

benlorenz
Copy link
Member

To have test dependencies (e.g. Documenter or Aqua) available when running tests via test_module.
Achieved by creating a temporary project using the test/Project.toml file and stacking this with the currently active project.
An alternative would be to try to hook into some of the internals of Pkg.jl and reuse that but it seemed rather fragile.

Seems to work fine in local tests, both with new=false and new=true, even for the Aqua.jl tests which use several temporary environments itself. Tested with the parallel test jobs as well.

This feature is always active unless one specifies tempproject=false, which is used in the main runtests.jl to avoid creating new projects for every testfile.

fixes #3354

to have documenter available for some test files

except when running from the main runtests.jl
Copy link

codecov bot commented Feb 12, 2024

Codecov Report

Merging #3357 (d3a0de7) into master (4b20afe) will decrease coverage by 0.04%.
Report is 3 commits behind head on master.
The diff coverage is 43.47%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3357      +/-   ##
==========================================
- Coverage   81.84%   81.81%   -0.04%     
==========================================
  Files         556      556              
  Lines       74361    74399      +38     
==========================================
+ Hits        60864    60870       +6     
- Misses      13497    13529      +32     
Files Coverage Δ
src/utils/tests.jl 61.53% <43.47%> (-6.24%) ⬇️

... and 7 files with indirect coverage changes

Copy link
Collaborator

@thofma thofma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested it with Groups and some other failing examples in the experimental folder. Seems to work, thanks!

Pkg.resolve()
end

try
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, why add the try here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the finally block that restores the load path and active project (when exiting the block with an exception).

@thofma thofma merged commit 03c0eae into master Feb 13, 2024
24 checks passed
@thofma thofma deleted the bl/testproj branch February 13, 2024 08:32
ooinaruhugh pushed a commit to ooinaruhugh/Oscar.jl that referenced this pull request Feb 15, 2024
to have documenter available for some test files

except when running from the main runtests.jl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

test_module not working for some files/directories
2 participants