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

Commit

Permalink
Refactor some test utilities (#53)
Browse files Browse the repository at this point in the history
Co-authored-by: Mosè Giordano <giordano@users.noreply.github.com>

Co-authored-by: Mosè Giordano <giordano@users.noreply.github.com>
  • Loading branch information
DilumAluthge and giordano authored Mar 22, 2021
1 parent 005e89d commit 21a3649
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
18 changes: 12 additions & 6 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,33 @@ const orig_execpath = deepcopy(get_env("GIT_EXEC_PATH"))
const orig_cainfo = deepcopy(get_env("GIT_SSL_CAINFO"))
const orig_templatedir = deepcopy(get_env("GIT_TEMPLATE_DIR"))

include("test-utils.jl")
function withtempdir(f::Function)
mktempdir() do tmp_dir
cd(tmp_dir) do
f(tmp_dir)
end
end
return nothing
end

@testset "GitCommand.jl" begin
with_temp_dir() do tmp_dir
withtempdir() do tmp_dir
@test !isdir("GitCommand.jl")
@test !isfile(joinpath("GitCommand.jl", "Project.toml"))
run(`$(git()) clone https://github.com/JuliaVersionControl/GitCommand.jl`)
@test isdir("GitCommand.jl")
@test isfile(joinpath("GitCommand.jl", "Project.toml"))
end

with_temp_dir() do tmp_dir
@test !isdir("GitCommand.jl")
@test !isfile(joinpath("GitCommand.jl", "Project.toml"))
withtempdir() do tmp_dir
@test !isdir("GitCommand.jl")
@test !isfile(joinpath("GitCommand.jl", "Project.toml"))
run(`$(git()) clone https://github.com/JuliaVersionControl/GitCommand.jl`)
@test isdir("GitCommand.jl")
@test isfile(joinpath("GitCommand.jl", "Project.toml"))
end

with_temp_dir() do tmp_dir
withtempdir() do tmp_dir
@test !isdir("GitCommand.jl")
@test !isfile(joinpath("GitCommand.jl", "Project.toml"))
cmd = GitCommand.git`clone https://github.com/JuliaVersionControl/GitCommand.jl`
Expand All @@ -41,6 +46,7 @@ include("test-utils.jl")
@test isdir("GitCommand.jl")
@test isfile(joinpath("GitCommand.jl", "Project.toml"))
end

end

@testset "Safety" begin
Expand Down
10 changes: 0 additions & 10 deletions test/test-utils.jl

This file was deleted.

0 comments on commit 21a3649

Please sign in to comment.