From 9f3b0b6f92703892dd6e4788452e9b1c50291827 Mon Sep 17 00:00:00 2001 From: David Varela <00.varela.david@gmail.com> Date: Fri, 13 Jul 2018 18:00:20 -0700 Subject: [PATCH 1/2] Use `mktempdir` shim (until bugfix is complete) --- test/pkg.jl | 16 ++++++++-------- test/repl.jl | 18 +++++++++--------- test/utils.jl | 22 ++++++++++++++++++++-- 3 files changed, 37 insertions(+), 19 deletions(-) diff --git a/test/pkg.jl b/test/pkg.jl index 993d5ab69f..d0ce0ce1ef 100644 --- a/test/pkg.jl +++ b/test/pkg.jl @@ -178,7 +178,7 @@ temp_pkg_dir() do project_path Pkg.add(TEST_PKG.name) old_v = Pkg.installed()[TEST_PKG.name] Pkg.rm(TEST_PKG.name) - mktempdir() do devdir + tempdir_util() do devdir withenv("JULIA_PKG_DEVDIR" => devdir) do Pkg.REPLMode.pkgstr("develop $(TEST_PKG.name)") @test isinstalled(TEST_PKG) @@ -231,7 +231,7 @@ temp_pkg_dir() do project_path end @testset "protocols" begin - mktempdir() do devdir + tempdir_util() do devdir withenv("JULIA_PKG_DEVDIR" => devdir) do try Pkg.setprotocol!("notarealprotocol") @@ -261,7 +261,7 @@ temp_pkg_dir() do project_path Pkg.rm(TEST_PKG.name) @testset "legacy CI script" begin - mktempdir() do dir + tempdir_util() do dir LibGit2.with(LibGit2.clone("https://github.com/JuliaLang/Example.jl", joinpath(dir, "Example.jl"))) do r cd(joinpath(dir, "Example.jl")) do let Pkg = Pkg @@ -280,7 +280,7 @@ temp_pkg_dir() do project_path end @testset "up in Project without manifest" begin - mktempdir() do dir + tempdir_util() do dir cp(joinpath(@__DIR__, "test_packages", "UnregisteredWithProject"), joinpath(dir, "UnregisteredWithProject")) cd(joinpath(dir, "UnregisteredWithProject")) do with_current_env() do @@ -292,7 +292,7 @@ temp_pkg_dir() do project_path end @testset "failing building a package should throw" begin - mktempdir() do path + tempdir_util() do path cd(path) do Pkg.generate("FailBuildPkg") cd("FailBuildPkg") @@ -314,7 +314,7 @@ temp_pkg_dir() do project_path end @testset "preview generate" begin - mktempdir() do tmp + tempdir_util() do tmp cd(tmp) do Pkg.generate("Foo"; preview=true) @test !isdir(joinpath(tmp, "Foo")) @@ -324,7 +324,7 @@ end temp_pkg_dir() do project_path @testset "test should instantiate" begin - mktempdir() do dir + tempdir_util() do dir cp(joinpath(@__DIR__, "test_packages", "UnregisteredWithProject"), joinpath(dir, "UnregisteredWithProject")) cd(joinpath(dir, "UnregisteredWithProject")) do with_current_env() do @@ -351,7 +351,7 @@ temp_pkg_dir() do project_path end cd(project_path) do - mktempdir() do tmp; cd(tmp) do + tempdir_util() do tmp; cd(tmp) do pkg_name = "FooBar" # create a project and grab its uuid Pkg.generate(pkg_name) diff --git a/test/repl.jl b/test/repl.jl index 099307307f..0654447a04 100644 --- a/test/repl.jl +++ b/test/repl.jl @@ -26,7 +26,7 @@ end @test_throws CommandError pkg"generate" end -mktempdir() do project_path +tempdir_util() do project_path cd(project_path) do withenv("USER" => "Test User") do pkg"generate HelloWorld" @@ -93,7 +93,7 @@ end @test repr(tokens[1][3]) == "VersionRange(\"0.5.0\")" end -temp_pkg_dir() do project_path; cd(project_path) do; mktempdir() do tmp_pkg_path +temp_pkg_dir() do project_path; cd(project_path) do; tempdir_util() do tmp_pkg_path pkg"activate ." pkg"add Example" @test isinstalled(TEST_PKG) @@ -147,7 +147,7 @@ temp_pkg_dir() do project_path; cd(project_path) do; mktempdir() do tmp_pkg_path Pkg.REPLMode.pkgstr("add $p2#$c") end - mktempdir() do tmp_dev_dir + tempdir_util() do tmp_dev_dir withenv("JULIA_PKG_DEVDIR" => tmp_dev_dir) do pkg"develop Example" @@ -161,7 +161,7 @@ temp_pkg_dir() do project_path; cd(project_path) do; mktempdir() do tmp_pkg_path empty!(DEPOT_PATH) write("Project.toml", proj) write("Manifest.toml", manifest) - mktempdir() do depot_dir + tempdir_util() do depot_dir pushfirst!(DEPOT_PATH, depot_dir) pkg"instantiate" @test Pkg.installed()[pkg2] == v"0.2.0" @@ -179,8 +179,8 @@ end # temp_pkg_dir temp_pkg_dir() do project_path; cd(project_path) do - mktempdir() do tmp - mktempdir() do depot_dir + tempdir_util() do tmp + tempdir_util() do depot_dir old_depot = copy(DEPOT_PATH) try empty!(DEPOT_PATH) @@ -214,8 +214,8 @@ temp_pkg_dir() do project_path; cd(project_path) do end # withenv end # mktempdir # nested - mktempdir() do other_dir - mktempdir() do tmp; + tempdir_util() do other_dir + tempdir_util() do tmp; cd(tmp) withenv("USER" => "Test User") do pkg"generate HelloWorld" @@ -311,7 +311,7 @@ temp_pkg_dir() do project_path; cd(project_path) do end end temp_pkg_dir() do project_path; cd(project_path) do - mktempdir() do tmp + tempdir_util() do tmp cp(joinpath(@__DIR__, "test_packages", "BigProject"), joinpath(tmp, "BigProject")) cd(joinpath(tmp, "BigProject")) with_current_env() do diff --git a/test/utils.jl b/test/utils.jl index 53ea5fc7cd..d1fc85a063 100644 --- a/test/utils.jl +++ b/test/utils.jl @@ -1,3 +1,21 @@ +# this function should temporarily be used instead of `mktempdir` +function tempdir_util(fn::Function) + tempdir = mktempdir() + try + fn(tempdir) + finally + try + rm(tempdir; recursive=true, force=true) + catch ex + if ex isa SystemError && ex.prefix == "rmdir" && ex.errnum == 13 + @warn "tempdir_util: error while cleaning up: $ex" + else + throw(ex) + end + end + end +end + function temp_pkg_dir(fn::Function) local env_dir local old_load_path @@ -13,8 +31,8 @@ function temp_pkg_dir(fn::Function) empty!(DEPOT_PATH) Base.HOME_PROJECT[] = nothing Base.ACTIVE_PROJECT[] = nothing - mktempdir() do env_dir - mktempdir() do depot_dir + tempdir_util() do env_dir + tempdir_util() do depot_dir push!(LOAD_PATH, "@", "@v#.#", "@stdlib") push!(DEPOT_PATH, depot_dir) fn(env_dir) From 14c0d0e2b271b95a429c082d17cbdb0ae0330cb2 Mon Sep 17 00:00:00 2001 From: David Varela <00.varela.david@gmail.com> Date: Sat, 14 Jul 2018 09:33:10 -0700 Subject: [PATCH 2/2] Change warning to error --- test/utils.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/utils.jl b/test/utils.jl index d1fc85a063..49b246094e 100644 --- a/test/utils.jl +++ b/test/utils.jl @@ -8,7 +8,7 @@ function tempdir_util(fn::Function) rm(tempdir; recursive=true, force=true) catch ex if ex isa SystemError && ex.prefix == "rmdir" && ex.errnum == 13 - @warn "tempdir_util: error while cleaning up: $ex" + @error "tempdir_util: error while cleaning up: $ex" else throw(ex) end