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

correct pointing in "@projectname --project" testing #43560

Closed
wants to merge 8 commits into from

Conversation

ngam
Copy link

@ngam ngam commented Dec 27, 2021

  • ran into this while customizing conda-forge build of julia
  • with @mkitti

Originally, the test as written would always default to home. However, if someone sets a different JULIA_DEPOT_PATH, then the test would fail. This slight edit ensures it passes.

xref: conda-forge/julia-feedstock#157

A simple test to confirm the problem:

JULIA_DEPOT_PATH="/some/path/of/choice:$JULIA_DEPOT_PATH" julia -E 'Base.runtests(["cmdlineargs"]; ncores=ceil(Int, Sys.CPU_THREADS))'

- ran into this while customizing conda-forge build of julia
- with @mkitti
@ngam ngam changed the title correct pointing in @projectname --project correct pointing in "@projectname --project" testing Dec 27, 2021
@DilumAluthge
Copy link
Member

Won't this error if the user doesn't have JULIA_DEPOT_PATH in their environment?

@ngam

This comment has been minimized.

@ngam
Copy link
Author

ngam commented Dec 27, 2021

Won't this error if the user doesn't have JULIA_DEPOT_PATH in their environment?

Ah, you're right. I thought it would populate it automatically. What would you recommend here, then? @DilumAluthge

test/cmdlineargs.jl Outdated Show resolved Hide resolved
Co-authored-by: Dilum Aluthge <[email protected]>
test/cmdlineargs.jl Outdated Show resolved Hide resolved
ngam and others added 2 commits December 26, 2021 22:37
@DilumAluthge
Copy link
Member

  1. Can you delete lines 143 and 144 from test/cmdlineargs.jl?
  2. Can you squash?

@DilumAluthge DilumAluthge added the test This change adds or pertains to unit tests label Dec 27, 2021
@ngam
Copy link
Author

ngam commented Dec 27, 2021

  • Can you delete lines 143 and 144 from test/cmdlineargs.jl?
  • Can you squash?

I delete the empty lines. Should I still squash now or is it okay to squash upon (potential) merge?

@DilumAluthge
Copy link
Member

Let's wait to squash until we're happy with the implementation.

@DilumAluthge
Copy link
Member

DilumAluthge commented Dec 27, 2021

I would recommend that you do the following:

  1. Test my latest suggestion locally to make sure it works for your use case.
  2. Accept the suggestion.
  3. Rebase and squash.
  4. Wait for CI to pass.
  5. Ping me once CI is passing, and I can merge.

@@ -139,7 +139,7 @@ let exename = `$(Base.julia_cmd()) --startup-file=no --color=no`
# handling of @projectname in --project and JULIA_PROJECT
let expanded = abspath(Base.load_path_expand("@foo"))
@test expanded == readchomp(`$exename --project='@foo' -e 'println(Base.active_project())'`)
@test expanded == readchomp(addenv(`$exename -e 'println(Base.active_project())'`, "JULIA_PROJECT" => "@foo", "HOME" => homedir()))
@test expanded == readchomp(addenv(`$exename -e 'println(Base.active_project())'`, "JULIA_PROJECT" => "@foo", "HOME" => homedir(), "JULIA_DEPOT_PATH" => "$(Base.DEPOT_PATH[1])"))
Copy link
Member

Choose a reason for hiding this comment

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

Since we are doing env = copy(ENV) and then deleting keys from env, we should use setenv instead of addenv.

Suggested change
@test expanded == readchomp(addenv(`$exename -e 'println(Base.active_project())'`, "JULIA_PROJECT" => "@foo", "HOME" => homedir(), "JULIA_DEPOT_PATH" => "$(Base.DEPOT_PATH[1])"))
env = copy(ENV)
env["JULIA_PROJECT"] = "@foo"
env["HOME"] = homedir()
delete!(env, "JULIA_DEPOT_PATH")
@test expanded == readchomp(setenv(`$exename -e 'println(Base.active_project())'`, env))

Copy link
Member

@DilumAluthge DilumAluthge Dec 27, 2021

Choose a reason for hiding this comment

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

As I mentioned in a different thread:

I think that explicitly deleting the JULIA_DEPOT_PATH environment variable (by doing delete!(env, "JULIA_DEPOT_PATH")) is the most correct solution here, because it makes explicit what we are trying to accomplish.

@mkitti
Copy link
Contributor

mkitti commented Dec 27, 2021

Abort this pull request. Do not merge.

@ngam The patch is not needed. As I mentioned in conda-forge/julia-feedstock#157 (comment), I thought this might have already been fixed upstream. It has. It already have been fixed by @DilumAluthge in #42358 .

@KristofferC could we backport #42358 to 1.7 branch?

@DilumAluthge DilumAluthge marked this pull request as draft December 27, 2021 08:03
@mkitti
Copy link
Contributor

mkitti commented Dec 27, 2021

The originating error on 1.7.1 is as follows:

Test Failed at $PREFIX/share/julia/test/cmdlineargs.jl:122
  Expression: expanded == readchomp(setenv(`$exename -e 'println(Base.active_project())'`, "JULIA_PROJECT" => "@foo", "HOME" => homedir()))
   Evaluated: "$PREFIX/share/julia/site/environments/foo/Project.toml" == "/home/conda/.julia/environments/foo/Project.toml"

This error occurs when testing 1.7.1 since that still uses setenv.

In #42358 (which is merged on Julia master slated for Julia 1.8), this was changed to addenv, which allows JULIA_DEPOT_PATH to be inherited by the new process. Therefore, we do not need to explicitly set JULIA_DEPOT_PATH due to the use of addenv. Additionally, that PR explicitly tested the use of JULIA_DEPOT_PATH.

The problem that we are trying to address here does not exist on Julia master.

@ngam
Copy link
Author

ngam commented Dec 27, 2021

The originating error on 1.7.1 is as follows:

Test Failed at $PREFIX/share/julia/test/cmdlineargs.jl:122
  Expression: expanded == readchomp(setenv(`$exename -e 'println(Base.active_project())'`, "JULIA_PROJECT" => "@foo", "HOME" => homedir()))
   Evaluated: "$PREFIX/share/julia/site/environments/foo/Project.toml" == "/home/conda/.julia/environments/foo/Project.toml"

This error occurs when testing 1.7.1 since that still uses setenv.

In #42358 (which is merged on Julia master slated for Julia 1.8), this was changed to addenv, which allows JULIA_DEPOT_PATH to be inherited by the new process. Therefore, we do not need to explicitly set JULIA_DEPOT_PATH due to the use of addenv. Additionally, that PR explicitly tested the use of JULIA_DEPOT_PATH.

The problem that we are trying to address here does not exist on Julia master.

It seems to me that PR #42358 only addresses this insofar as Base.runtests(["all"]) is called. @DilumAluthge, thoughts?

@DilumAluthge
Copy link
Member

Oh I'd totally forgotten about #42358.

Yeah #42358 solved this problem.

@DilumAluthge
Copy link
Member

It seems to me that PR #42358 only addresses this insofar as Base.runtests(["all"]) is called.

Hmmm. #42358 should solve this for any invocation of Base.runtests, regardless of the arguments passed to Base.runtests.

@DilumAluthge
Copy link
Member

I think the issue here is that #42358 has not yet been backported to 1.6 and 1.7.

@ngam
Copy link
Author

ngam commented Dec 27, 2021

It seems to me that PR #42358 only addresses this insofar as Base.runtests(["all"]) is called.

Hmmm. #42358 should solve this for any invocation of Base.runtests, regardless of the arguments passed to Base.runtests.

Sorry, I misread that. Thanks!

@ngam ngam deleted the patch-1 branch December 27, 2021 14:03
@ngam
Copy link
Author

ngam commented Dec 27, 2021

Btw @DilumAluthge --- I did my undergrad degree at Brown, in BME. Small world.

@ngam
Copy link
Author

ngam commented Dec 29, 2021

Btw @DilumAluthge --- I did my undergrad degree at Brown, in BME. Small world.

@DilumAluthge okay... now... I think I remember you. I believe we took APMA classes together! I graduated in 2015. Anyway, good coincidence, thanks for the great work here and on the other PRs!

@DilumAluthge DilumAluthge removed the DO NOT MERGE Do not merge this PR! label Jan 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test This change adds or pertains to unit tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants