Skip to content

Commit 7a6f423

Browse files
committed
[REPL]: Don't write to the user's home directory
Instead of writing out to actual `$HOME`, create a temporary directory and set that as `$HOME`/`$USERPROFILE`.
1 parent 7dae29d commit 7a6f423

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

stdlib/REPL/test/replcompletions.jl

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -699,20 +699,22 @@ let s, c, r
699699
end
700700

701701
# Tests homedir expansion
702-
let path, s, c, r
703-
path = homedir()
704-
dir = joinpath(path, "tmpfoobar")
705-
mkdir(dir)
706-
s = "\"" * path * "/tmpfoob"
707-
c,r = test_complete(s)
708-
@test "tmpfoobar/" in c
709-
l = 3 + length(path)
710-
@test r == l:l+6
711-
@test s[r] == "tmpfoob"
712-
s = "\"~"
713-
@test "tmpfoobar/" in c
714-
c,r = test_complete(s)
715-
rm(dir)
702+
mktempdir() do tmphome
703+
withenv("HOME" => tmphome, "USERPROFILE" => tmphome) do
704+
path = homedir()
705+
dir = joinpath(path, "tmpfoobar")
706+
mkdir(dir)
707+
s = "\"" * path * "/tmpfoob"
708+
c,r = test_complete(s)
709+
@test "tmpfoobar/" in c
710+
l = 3 + length(path)
711+
@test r == l:l+6
712+
@test s[r] == "tmpfoob"
713+
s = "\"~"
714+
@test "tmpfoobar/" in c
715+
c,r = test_complete(s)
716+
rm(dir)
717+
end
716718
end
717719

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

0 commit comments

Comments
 (0)