Skip to content

Commit

Permalink
add tests for --project=@script
Browse files Browse the repository at this point in the history
  • Loading branch information
awadell1 committed Dec 7, 2024
1 parent 3a68b03 commit 4271c98
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/cmdlineargs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,16 @@ let exename = `$(Base.julia_cmd()) --startup-file=no --color=no`
@test expanded == readchomp(addenv(`$exename -e 'println(Base.active_project())'`, "JULIA_PROJECT" => "@foo", "HOME" => homedir()))
end

# --project=@script handling
let expanded = abspath(joinpath(@__DIR__, "project", "ScriptProject"))
script = joinpath(expanded, "bin", "script.jl")
# Check running julia with --project=@script both within and outside the script directory
@testset "--@script from $name" for (name, dir) in [("project", expanded, ("outside", pwd()))]
@test joinpath(expanded, "Project.toml") == readchomp(Cmd(`$exename --project=@script $script`; dir))
@test joinpath(expanded, "SubProject", "Project.toml") == readchomp(Cmd(`$exename --project=@script/../SubProject $script`; dir))
end
end

# handling of `@temp` in --project and JULIA_PROJECT
@test tempdir() == readchomp(`$exename --project=@temp -e 'println(Base.active_project())'`)[1:lastindex(tempdir())]
@test tempdir() == readchomp(addenv(`$exename -e 'println(Base.active_project())'`, "JULIA_PROJECT" => "@temp", "HOME" => homedir()))[1:lastindex(tempdir())]
Expand Down
2 changes: 2 additions & 0 deletions test/project/ScriptProject/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name = "ScriptProject"
uuid = "6646321a-c4de-46ad-9761-435e5bb1f223"
2 changes: 2 additions & 0 deletions test/project/ScriptProject/SubProject/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name = "SubProject"
uuid = "50d58d6a-5ae2-46f7-9677-83c51ca667d5"
1 change: 1 addition & 0 deletions test/project/ScriptProject/bin/script.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
println(Base.active_project())

0 comments on commit 4271c98

Please sign in to comment.