Skip to content

Commit 4c7f4dd

Browse files
committed
add tests for --project=@script
Tests for #55606 and #55069
1 parent f6a38e0 commit 4c7f4dd

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

test/cmdlineargs.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,16 @@ let exename = `$(Base.julia_cmd()) --startup-file=no --color=no`
257257
@test expanded == readchomp(addenv(`$exename -e 'println(Base.active_project())'`, "JULIA_PROJECT" => "@foo", "HOME" => homedir()))
258258
end
259259

260+
# --project=@script handling
261+
let expanded = abspath(joinpath(@__DIR__, "project", "ScriptProject"))
262+
script = joinpath(expanded, "bin", "script.jl")
263+
# Check running julia with --project=@script both within and outside the script directory
264+
@testset "--@script from $name" for (name, dir) in [("project", expanded, ("outside", pwd()))]
265+
@test joinpath(expanded, "Project.toml") == readchomp(Cmd(`$exename --project=@script $script`; dir))
266+
@test joinpath(expanded, "SubProject", "Project.toml") == readchomp(Cmd(`$exename --project=@script/../SubProject $script`; dir))
267+
end
268+
end
269+
260270
# handling of `@temp` in --project and JULIA_PROJECT
261271
@test tempdir() == readchomp(`$exename --project=@temp -e 'println(Base.active_project())'`)[1:lastindex(tempdir())]
262272
@test tempdir() == readchomp(addenv(`$exename -e 'println(Base.active_project())'`, "JULIA_PROJECT" => "@temp", "HOME" => homedir()))[1:lastindex(tempdir())]
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
name = "ScriptProject"
2+
uuid = "6646321a-c4de-46ad-9761-435e5bb1f223"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
name = "SubProject"
2+
uuid = "50d58d6a-5ae2-46f7-9677-83c51ca667d5"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
println(Base.active_project())

0 commit comments

Comments
 (0)