-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Added tests for load_overrides() in Artifacts.jl #51833
Added tests for load_overrides() in Artifacts.jl #51833
Conversation
Nice work. Would it be better to create a temporary folder ( |
That's a great idea! I'll be working on that. |
…o that no explicit file/directory deletion is needed after the test.
OK, I think I know why the new commit fails. Apparently, I saved a file in my Virtual Machine but forgot to delete it, so my machine was the only one where the code runs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, looks great to me, thank you for increasing test coverage in this area! I had a few style notes that I made for the test implementation.
stdlib/Artifacts/test/runtests.jl
Outdated
@test load_overrides() == expected_output | ||
|
||
# Create a temporary directory and set DEPOT_PATH to that directory | ||
temp_dir = mktempdir() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use the do
-block form of mktempdir()
to explicitly scope when the temporary directory gets deleted, otherwise it only gets deleted at Julia exit. Example:
mktempdir() do temp_dir
...
end
stdlib/Artifacts/test/runtests.jl
Outdated
|
||
# Create a temporary directory and set DEPOT_PATH to that directory | ||
temp_dir = mktempdir() | ||
old_depot_path = DEPOT_PATH[1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The old depot path can have multiple elements, so the most correct way to do this is to do:
old_depot_path = copy(DEPOT_PATH)
empty!(DEPOT_PATH)
push!(DEPOT_PATH, temp_dir)
try
...
finally
empty!(DEPOT_PATH)
append!(DEPOT_PATH, old_depot_path)
end
The try
/finally
is so that even if something goes horribly wrong, the depot path doesn't cause cascading failures for other tests within this same file that may still run.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for your idea! Yes, making sure that DEPOT_PATH will be restored to the status quo in the event of a bug is definitely the best practice.
Thanks, @u7581147! |
Fixes #48551 Continued from #51815 The `load_overrides()` method in `Artifacts.jl` has a large untested branch. This PR increases the test coverage for this method. ![image](https://github.com/JuliaLang/julia/assets/141328479/a9744e25-e79f-4664-8522-320dd29c4c50) https://app.codecov.io/gh/JuliaLang/julia/blob/master/stdlib%2FArtifacts%2Fsrc%2FArtifacts.jl#L121
Fixes #48551
Continued from #51815
The
load_overrides()
method inArtifacts.jl
has a large untested branch. This PR increases the test coverage for this method.https://app.codecov.io/gh/JuliaLang/julia/blob/master/stdlib%2FArtifacts%2Fsrc%2FArtifacts.jl#L121