Skip to content

Commit 399f8ba

Browse files
authored
Merge pull request #39101 from JuliaLang/sf/sandbox_fixes
Fixes so that test suite can run in more tightly sandboxed environment
2 parents 3931b22 + fd671b3 commit 399f8ba

File tree

4 files changed

+27
-26
lines changed

4 files changed

+27
-26
lines changed

stdlib/Artifacts/test/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

stdlib/Artifacts/test/refresh_artifacts.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
# This file is a part of Julia. License is MIT: https://julialang.org/license
22

33
using Artifacts: with_artifacts_directory
4-
# using Pkg.Artifacts: ensure_all_artifacts_installed
54
using Pkg.Artifacts: load_artifacts_toml, ensure_artifact_installed
65
let
7-
tempdir = joinpath(@__DIR__, "artifacts")
86
toml = joinpath(@__DIR__, "Artifacts.toml")
97
unused = Base.BinaryPlatforms.Platform(string(Sys.ARCH), "linux")
10-
with_artifacts_directory(tempdir) do
8+
with_artifacts_directory(ARGS[1]) do
119
# ensure_all_artifacts_installed(toml; include_lazy=false)
1210
dict = load_artifacts_toml(toml)
1311
for (name, meta) in dict

stdlib/Artifacts/test/runtests.jl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ using Artifacts, Test, Base.BinaryPlatforms
44
using Artifacts: with_artifacts_directory, pack_platform!, unpack_platform
55

66
# prepare for the package tests by ensuring the required artifacts are downloaded now
7-
run(addenv(`$(Base.julia_cmd()) --color=no $(joinpath(@__DIR__, "refresh_artifacts.jl"))`, "TERM"=>"dumb"))
7+
artifacts_dir = mktempdir()
8+
run(addenv(`$(Base.julia_cmd()) --color=no $(joinpath(@__DIR__, "refresh_artifacts.jl")) $(artifacts_dir)`, "TERM"=>"dumb"))
89

910
@testset "Artifact Paths" begin
1011
mktempdir() do tempdir
@@ -81,8 +82,7 @@ end
8182
end
8283

8384
@testset "Artifact Slash-indexing" begin
84-
tempdir = joinpath(@__DIR__, "artifacts")
85-
with_artifacts_directory(tempdir) do
85+
with_artifacts_directory(artifacts_dir) do
8686
exeext = Sys.iswindows() ? ".exe" : ""
8787

8888
# simple lookup, gives us the directory for `c_simple` for the current architecture
@@ -112,8 +112,7 @@ end
112112
end
113113

114114
@testset "@artifact_str Platform passing" begin
115-
tempdir = joinpath(@__DIR__, "artifacts")
116-
with_artifacts_directory(tempdir) do
115+
with_artifacts_directory(artifacts_dir) do
117116
win64 = Platform("x86_64", "windows")
118117
mac64 = Platform("x86_64", "macos")
119118
@test basename(@artifact_str("c_simple", win64)) == "444cecb70ff39e8961dd33e230e151775d959f37"

stdlib/REPL/test/replcompletions.jl

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -663,11 +663,14 @@ let s, c, r
663663
@test s[r] == "tmp"
664664

665665
# This should match things that are inside the tmp directory
666-
if !isdir("/tmp/tmp")
667-
s = "/tmp/"
666+
s = tempdir()
667+
if !endswith(s, "/")
668+
s = string(s, "/")
669+
end
670+
if !isdir(joinpath(s, "tmp"))
668671
c,r = test_scomplete(s)
669672
@test !("tmp/" in c)
670-
@test r === 6:5
673+
@test r === length(s) + 1:0
671674
@test s[r] == ""
672675
end
673676

@@ -699,20 +702,22 @@ let s, c, r
699702
end
700703

701704
# 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)
705+
mktempdir() do tmphome
706+
withenv("HOME" => tmphome, "USERPROFILE" => tmphome) do
707+
path = homedir()
708+
dir = joinpath(path, "tmpfoobar")
709+
mkdir(dir)
710+
s = "\"" * path * "/tmpfoob"
711+
c,r = test_complete(s)
712+
@test "tmpfoobar/" in c
713+
l = 3 + length(path)
714+
@test r == l:l+6
715+
@test s[r] == "tmpfoob"
716+
s = "\"~"
717+
@test "tmpfoobar/" in c
718+
c,r = test_complete(s)
719+
rm(dir)
720+
end
716721
end
717722

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

0 commit comments

Comments
 (0)