diff --git a/Project.toml b/Project.toml index 854771d..40f25da 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "DataDeps" uuid = "124859b0-ceae-595e-8997-d05f6a7a8dfe" authors = ["Lyndon White "] -version = "0.7.7" +version = "0.7.8" [deps] BinaryProvider = "b99e7846-7c00-51b0-8f62-c81ae34c0232" diff --git a/src/post_fetch_helpers.jl b/src/post_fetch_helpers.jl index 979e9ce..c64db33 100644 --- a/src/post_fetch_helpers.jl +++ b/src/post_fetch_helpers.jl @@ -4,9 +4,9 @@ function unpack_cmd(file,directory,extension,secondary_extension) p7zip() do exe7z if secondary_extension == ".tar" || extension == ".tgz" || extension == ".tbz" # special handling for compressed tarballs - return pipeline(`$exe7z x $file -y -so`, `$exe7z x -si -y -ttar -o$directory`) + return pipeline(`$exe7z x $file -y -so`, `$exe7z x -si -y -ttar -o$directory -bso0 -bsp0`) else - return `$exe7z x $file -y -o$directory` + return `$exe7z x $file -y -o$directory -bso0 -bsp0` end end end diff --git a/test/assets/file1.txt b/test/assets/file1.txt new file mode 100644 index 0000000..a7f8d9e --- /dev/null +++ b/test/assets/file1.txt @@ -0,0 +1 @@ +bla diff --git a/test/post_fetch_helpers.jl b/test/post_fetch_helpers.jl new file mode 100644 index 0000000..1343479 --- /dev/null +++ b/test/post_fetch_helpers.jl @@ -0,0 +1,36 @@ +using Test +using DataDeps: unpack, p7zip + +# Runs `f()` and returns what would normally be printed to stdout +function capture_stdout(f) + std = stdout + r, w = redirect_stdout() + try + f() + finally + redirect_stdout(std) + close(w) + end + output = read(r, String) + return output +end + +@testset "unpack" begin + + @testset "happy case" begin + # Create dummy zip + p7zip() do exe7z + run(`$exe7z a assets/test.zip assets/file1.txt -bso0 -bsp0`) + end + + output = capture_stdout() do + unpack("assets/test.zip") + end + @test output == "" # silent + end + + @testset "sad case" begin + # depending on Julia version may be ErrorException or ProcessFailedException + @test_throws Union{ErrorException,ProcessFailedException} unpack("assets/non-existent.zip") + end +end diff --git a/test/runtests.jl b/test/runtests.jl index 649475c..f3d7942 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -9,6 +9,7 @@ using Test "main", "preupload", "fetch_helpers", + "post_fetch_helpers", ] @testset "tests" begin for filename in tests