Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth committed Jun 14, 2024
1 parent f782dde commit d8110f1
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions stdlib/REPL/test/repl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1836,3 +1836,25 @@ end
@test_broken isempty(undoc)
@test undoc == [:AbstractREPL, :BasicREPL, :LineEditREPL, :StreamREPL]
end

@testset "Dummy Pkg prompt" begin
# do this in an empty depot to test default for new users
withenv("JULIA_DEPOT_PATH" => mktempdir(), "JULIA_LOAD_PATH" => nothing) do
prompt = readchomp(`$(Base.julia_cmd()[1]) --startup-file=no -e "using REPL; print(REPL.Pkg_promptf())"`)
@test prompt == "(@v$(VERSION.major).$(VERSION.minor)) pkg> "
end

get_prompt(proj::String) = readchomp(`$(Base.julia_cmd()[1]) --startup-file=no $(proj) -e "using REPL; print(REPL.Pkg_promptf())"`)

@test get_prompt("--project=$(pkgdir(REPL))") == "(REPL) pkg> "

tdir = mkpath(joinpath(mktempdir(), "foo"))
@test get_prompt("--project=$tdir") == "(foo) pkg> "

proj_file = joinpath(tdir, "Project.toml")
touch(proj_file) # make a bad Project.toml
@test get_prompt("--project=$proj_file") == "(foo) pkg> "

write(proj_file, "name = \"Bar\"\n")
@test get_prompt("--project=$proj_file") == "(Bar) pkg> "
end

0 comments on commit d8110f1

Please sign in to comment.