Skip to content
This repository was archived by the owner on Mar 26, 2021. It is now read-only.

Commit 21a3649

Browse files
Refactor some test utilities (#53)
Co-authored-by: Mosè Giordano <[email protected]> Co-authored-by: Mosè Giordano <[email protected]>
1 parent 005e89d commit 21a3649

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

test/runtests.jl

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,33 @@ const orig_execpath = deepcopy(get_env("GIT_EXEC_PATH"))
99
const orig_cainfo = deepcopy(get_env("GIT_SSL_CAINFO"))
1010
const orig_templatedir = deepcopy(get_env("GIT_TEMPLATE_DIR"))
1111

12-
include("test-utils.jl")
12+
function withtempdir(f::Function)
13+
mktempdir() do tmp_dir
14+
cd(tmp_dir) do
15+
f(tmp_dir)
16+
end
17+
end
18+
return nothing
19+
end
1320

1421
@testset "GitCommand.jl" begin
15-
with_temp_dir() do tmp_dir
22+
withtempdir() do tmp_dir
1623
@test !isdir("GitCommand.jl")
1724
@test !isfile(joinpath("GitCommand.jl", "Project.toml"))
1825
run(`$(git()) clone https://github.com/JuliaVersionControl/GitCommand.jl`)
1926
@test isdir("GitCommand.jl")
2027
@test isfile(joinpath("GitCommand.jl", "Project.toml"))
2128
end
2229

23-
with_temp_dir() do tmp_dir
24-
@test !isdir("GitCommand.jl")
25-
@test !isfile(joinpath("GitCommand.jl", "Project.toml"))
30+
withtempdir() do tmp_dir
2631
@test !isdir("GitCommand.jl")
2732
@test !isfile(joinpath("GitCommand.jl", "Project.toml"))
2833
run(`$(git()) clone https://github.com/JuliaVersionControl/GitCommand.jl`)
2934
@test isdir("GitCommand.jl")
3035
@test isfile(joinpath("GitCommand.jl", "Project.toml"))
3136
end
3237

33-
with_temp_dir() do tmp_dir
38+
withtempdir() do tmp_dir
3439
@test !isdir("GitCommand.jl")
3540
@test !isfile(joinpath("GitCommand.jl", "Project.toml"))
3641
cmd = GitCommand.git`clone https://github.com/JuliaVersionControl/GitCommand.jl`
@@ -41,6 +46,7 @@ include("test-utils.jl")
4146
@test isdir("GitCommand.jl")
4247
@test isfile(joinpath("GitCommand.jl", "Project.toml"))
4348
end
49+
4450
end
4551

4652
@testset "Safety" begin

test/test-utils.jl

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)