Skip to content

Commit d8110f1

Browse files
add tests
1 parent f782dde commit d8110f1

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

stdlib/REPL/test/repl.jl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1836,3 +1836,25 @@ end
18361836
@test_broken isempty(undoc)
18371837
@test undoc == [:AbstractREPL, :BasicREPL, :LineEditREPL, :StreamREPL]
18381838
end
1839+
1840+
@testset "Dummy Pkg prompt" begin
1841+
# do this in an empty depot to test default for new users
1842+
withenv("JULIA_DEPOT_PATH" => mktempdir(), "JULIA_LOAD_PATH" => nothing) do
1843+
prompt = readchomp(`$(Base.julia_cmd()[1]) --startup-file=no -e "using REPL; print(REPL.Pkg_promptf())"`)
1844+
@test prompt == "(@v$(VERSION.major).$(VERSION.minor)) pkg> "
1845+
end
1846+
1847+
get_prompt(proj::String) = readchomp(`$(Base.julia_cmd()[1]) --startup-file=no $(proj) -e "using REPL; print(REPL.Pkg_promptf())"`)
1848+
1849+
@test get_prompt("--project=$(pkgdir(REPL))") == "(REPL) pkg> "
1850+
1851+
tdir = mkpath(joinpath(mktempdir(), "foo"))
1852+
@test get_prompt("--project=$tdir") == "(foo) pkg> "
1853+
1854+
proj_file = joinpath(tdir, "Project.toml")
1855+
touch(proj_file) # make a bad Project.toml
1856+
@test get_prompt("--project=$proj_file") == "(foo) pkg> "
1857+
1858+
write(proj_file, "name = \"Bar\"\n")
1859+
@test get_prompt("--project=$proj_file") == "(Bar) pkg> "
1860+
end

0 commit comments

Comments
 (0)