Skip to content

Commit

Permalink
[REPL]: Don't write to the user's home directory
Browse files Browse the repository at this point in the history
Instead of writing out to actual `$HOME`, create a temporary directory
and set that as `$HOME`/`$USERPROFILE`.
  • Loading branch information
staticfloat committed Jan 5, 2021
1 parent 7dae29d commit 7a6f423
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions stdlib/REPL/test/replcompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -699,20 +699,22 @@ let s, c, r
end

# Tests homedir expansion
let path, s, c, r
path = homedir()
dir = joinpath(path, "tmpfoobar")
mkdir(dir)
s = "\"" * path * "/tmpfoob"
c,r = test_complete(s)
@test "tmpfoobar/" in c
l = 3 + length(path)
@test r == l:l+6
@test s[r] == "tmpfoob"
s = "\"~"
@test "tmpfoobar/" in c
c,r = test_complete(s)
rm(dir)
mktempdir() do tmphome
withenv("HOME" => tmphome, "USERPROFILE" => tmphome) do
path = homedir()
dir = joinpath(path, "tmpfoobar")
mkdir(dir)
s = "\"" * path * "/tmpfoob"
c,r = test_complete(s)
@test "tmpfoobar/" in c
l = 3 + length(path)
@test r == l:l+6
@test s[r] == "tmpfoob"
s = "\"~"
@test "tmpfoobar/" in c
c,r = test_complete(s)
rm(dir)
end
end

# Tests detecting of files in the env path (in shell mode)
Expand Down

0 comments on commit 7a6f423

Please sign in to comment.