From 59954cfc42c80dda0efc0723a427605fda50817b Mon Sep 17 00:00:00 2001 From: nhz2 Date: Sun, 16 Apr 2023 21:43:14 -0400 Subject: [PATCH 1/8] testing work --- Project.toml | 3 +- test/test_writer_compat.jl | 77 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 test/test_writer_compat.jl diff --git a/Project.toml b/Project.toml index 91750a8..2ae5422 100644 --- a/Project.toml +++ b/Project.toml @@ -13,6 +13,7 @@ julia = "1.3.0" [extras] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" +p7zip_jll = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" [targets] -test = ["Test"] +test = ["Test", "p7zip_jll"] diff --git a/test/test_writer_compat.jl b/test/test_writer_compat.jl new file mode 100644 index 0000000..37d1281 --- /dev/null +++ b/test/test_writer_compat.jl @@ -0,0 +1,77 @@ +# Test that zip files written by ZipFile.jl can be read by other programs. +using Test +using ZipFile +import p7zip_jll + + +""" +Extract the zip file at zippath into the directory dirpath +Use p7zip +""" +function unzip_p7zip(zippath, dirpath) + p7zip_jll.p7zip() do exe + run(pipeline(`$(exe) x -y -o$(dirpath) $(zippath)`, devnull)) + end +end + +@testset "Writer is compatible with p7zip" begin + # write an empty zip file + mktempdir() do tmp + zippath = joinpath(tmp, "empty.zip") + dirpath = joinpath(tmp, "empty_p7zip_out") + mkpath(dirpath) + dir = ZipFile.Writer(zippath) + close(dir) + unzip_p7zip(zippath, dirpath) + @test isempty(readdir(dirpath)) + end + + # write a zip file with some basic ASCII files with ASCII file names + mktempdir() do tmp + zippath = joinpath(tmp, "hello.zip") + dirpath = joinpath(tmp, "hello_p7zip_out") + mkpath(dirpath) + zipdata = [ + ("hello.txt", "hello world!\n", ZipFile.Store), + ("info.txt", "Julia\nfor\ntechnical computing\n", ZipFile.Store), + ("julia.txt", "julia\n"^10, ZipFile.Deflate), + ("empty1.txt", "", ZipFile.Store), + ("empty2.txt", "", ZipFile.Deflate), + ] + dir = ZipFile.Writer(zippath) + for (name, data, meth) in zipdata + local f = ZipFile.addfile(dir, name; method=meth) + write(f, data) + end + close(dir) + + unzip_p7zip(zippath, dirpath) + @test length(readdir(dirpath)) == length(zipdata) + for (name, data, meth) in zipdata + @test read(joinpath(dirpath,name), String) == data + end + end + + # write a zip file with UTF8 filenames + mktempdir() do tmp + zippath = joinpath(tmp, "utf8.zip") + dirpath = joinpath(tmp, "utf8_p7zip_out") + mkpath(dirpath) + zipdata = [ + ("hello😸.txt", "hello world!\n", ZipFile.Store), + ] + dir = ZipFile.Writer(zippath) + for (name, data, meth) in zipdata + local f = ZipFile.addfile(dir, name; method=meth) + write(f, data) + end + close(dir) + + unzip_p7zip(zippath, dirpath) + @test length(readdir(dirpath)) == length(zipdata) + for (name, data, meth) in zipdata + @test_broken read(joinpath(dirpath,name), String) == data + end + end +end + From ee42d685374ff4d4b7685225836f056c29aafc89 Mon Sep 17 00:00:00 2001 From: nhz2 Date: Mon, 17 Apr 2023 13:52:06 -0400 Subject: [PATCH 2/8] test other programs --- Project.toml | 3 +- test-writer-compat/Project.toml | 5 ++ test-writer-compat/runtests.jl | 110 ++++++++++++++++++++++++++++++++ test/test_writer_compat.jl | 77 ---------------------- 4 files changed, 116 insertions(+), 79 deletions(-) create mode 100644 test-writer-compat/Project.toml create mode 100644 test-writer-compat/runtests.jl delete mode 100644 test/test_writer_compat.jl diff --git a/Project.toml b/Project.toml index 2ae5422..91750a8 100644 --- a/Project.toml +++ b/Project.toml @@ -13,7 +13,6 @@ julia = "1.3.0" [extras] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" -p7zip_jll = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" [targets] -test = ["Test", "p7zip_jll"] +test = ["Test"] diff --git a/test-writer-compat/Project.toml b/test-writer-compat/Project.toml new file mode 100644 index 0000000..f38cdc2 --- /dev/null +++ b/test-writer-compat/Project.toml @@ -0,0 +1,5 @@ +[deps] +LibArchive_jll = "1e303b3e-d4db-56ce-88c4-91e52606a1a8" +PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0" +ZipFile = "a5390f91-8eb1-5f08-bee0-b1d1ffed6cea" +p7zip_jll = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" diff --git a/test-writer-compat/runtests.jl b/test-writer-compat/runtests.jl new file mode 100644 index 0000000..7d6be10 --- /dev/null +++ b/test-writer-compat/runtests.jl @@ -0,0 +1,110 @@ +# Test that zip files written by ZipFile.jl can be read by other programs. +# This test requires julia 1.6 or greater to run. +using Test +using ZipFile +import p7zip_jll +import LibArchive_jll +import PyCall + + + +""" +Extract the zip file at zippath into the directory dirpath +Use p7zip +""" +function unzip_p7zip(zippath, dirpath) + # pipe output to devnull because p7zip is noisy + run(pipeline(`$(p7zip_jll.p7zip()) x -y -o$(dirpath) $(zippath)`, devnull)) + nothing +end + +""" +Extract the zip file at zippath into the directory dirpath +Use bsdtar from libarchive +""" +function unzip_bsdtar(zippath, dirpath) + run(`$(LibArchive_jll.bsdtar()) -x -f $(zippath) -C $(dirpath)`) + nothing +end + +""" +Extract the zip file at zippath into the directory dirpath +Use zipfile.py from python standard library +""" +function unzip_python(zippath, dirpath) + zipfile = PyCall.pyimport("zipfile") + f = zipfile.ZipFile(zippath) + isnothing(f.testzip()) || error(string(f.testzip())) + f.extractall(dirpath) + nothing +end + + +""" +Use ZipFile.Writer to write a bunch of zip files to a directory +""" +function write_example_zipfiles(dirpath::AbstractString) + # write an empty zip file + dir = ZipFile.Writer(joinpath(dirpath, "empty.zip")) + close(dir) + + # write a zip file with some basic ASCII files with ASCII file names + zipdata = [ + ("hello.txt", "hello world!\n", ZipFile.Store), + ("info.txt", "Julia\nfor\ntechnical computing\n", ZipFile.Store), + ("julia.txt", "julia\n"^10, ZipFile.Deflate), + ("empty1.txt", "", ZipFile.Store), + ("empty2.txt", "", ZipFile.Deflate), + ] + dir = ZipFile.Writer(joinpath(dirpath, "hello.zip")) + for (name, data, meth) in zipdata + local f = ZipFile.addfile(dir, name; method=meth) + write(f, data) + end + close(dir) + + # TODO fix write a zip file with UTF8 filenames + # zipdata = [ + # ("hello😸.txt", "hello world!\n", ZipFile.Store), + # ] + # dir = ZipFile.Writer(joinpath(dirpath, "utf8.zip")) + # for (name, data, meth) in zipdata + # local f = ZipFile.addfile(dir, name; method=meth) + # write(f, data) + # end + # close(dir) +end + +Debug = false + +tmp = mktempdir() +if Debug + println("temporary directory $tmp") +end + +write_example_zipfiles(tmp) + +# Functions that can unzip into a directory +unzippers = [ + unzip_p7zip, + unzip_bsdtar, + unzip_python, +] + +@testset "compat with $(unzipper)" for unzipper in unzippers + for zippath in readdir(tmp; join=true) + mktempdir() do tmpout + # Unzip into an output directory + unzipper(zippath, tmpout) + # Read zippath with ZipFile.Reader + # Check file names and data match + local dir = ZipFile.Reader(zippath) + for f in dir.files + local name = f.name + local extracted_path = joinpath(tmpout,name) + @test isfile(extracted_path) + @test read(f) == read(extracted_path) + end + end + end +end \ No newline at end of file diff --git a/test/test_writer_compat.jl b/test/test_writer_compat.jl deleted file mode 100644 index 37d1281..0000000 --- a/test/test_writer_compat.jl +++ /dev/null @@ -1,77 +0,0 @@ -# Test that zip files written by ZipFile.jl can be read by other programs. -using Test -using ZipFile -import p7zip_jll - - -""" -Extract the zip file at zippath into the directory dirpath -Use p7zip -""" -function unzip_p7zip(zippath, dirpath) - p7zip_jll.p7zip() do exe - run(pipeline(`$(exe) x -y -o$(dirpath) $(zippath)`, devnull)) - end -end - -@testset "Writer is compatible with p7zip" begin - # write an empty zip file - mktempdir() do tmp - zippath = joinpath(tmp, "empty.zip") - dirpath = joinpath(tmp, "empty_p7zip_out") - mkpath(dirpath) - dir = ZipFile.Writer(zippath) - close(dir) - unzip_p7zip(zippath, dirpath) - @test isempty(readdir(dirpath)) - end - - # write a zip file with some basic ASCII files with ASCII file names - mktempdir() do tmp - zippath = joinpath(tmp, "hello.zip") - dirpath = joinpath(tmp, "hello_p7zip_out") - mkpath(dirpath) - zipdata = [ - ("hello.txt", "hello world!\n", ZipFile.Store), - ("info.txt", "Julia\nfor\ntechnical computing\n", ZipFile.Store), - ("julia.txt", "julia\n"^10, ZipFile.Deflate), - ("empty1.txt", "", ZipFile.Store), - ("empty2.txt", "", ZipFile.Deflate), - ] - dir = ZipFile.Writer(zippath) - for (name, data, meth) in zipdata - local f = ZipFile.addfile(dir, name; method=meth) - write(f, data) - end - close(dir) - - unzip_p7zip(zippath, dirpath) - @test length(readdir(dirpath)) == length(zipdata) - for (name, data, meth) in zipdata - @test read(joinpath(dirpath,name), String) == data - end - end - - # write a zip file with UTF8 filenames - mktempdir() do tmp - zippath = joinpath(tmp, "utf8.zip") - dirpath = joinpath(tmp, "utf8_p7zip_out") - mkpath(dirpath) - zipdata = [ - ("hello😸.txt", "hello world!\n", ZipFile.Store), - ] - dir = ZipFile.Writer(zippath) - for (name, data, meth) in zipdata - local f = ZipFile.addfile(dir, name; method=meth) - write(f, data) - end - close(dir) - - unzip_p7zip(zippath, dirpath) - @test length(readdir(dirpath)) == length(zipdata) - for (name, data, meth) in zipdata - @test_broken read(joinpath(dirpath,name), String) == data - end - end -end - From 1abd341c7d46ab02bf62874a4b02385bf3d3bb1c Mon Sep 17 00:00:00 2001 From: nhz2 Date: Mon, 17 Apr 2023 13:53:22 -0400 Subject: [PATCH 3/8] ignore manifest files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index eb7c30a..6b141a5 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ doc/_build/ deps/deps.jl build.log deps/usr/* +Manifest.toml From 8778b05e8453ab9d99545451a0042cd1672ac1d7 Mon Sep 17 00:00:00 2001 From: nhz2 Date: Mon, 17 Apr 2023 13:54:47 -0400 Subject: [PATCH 4/8] update testset name --- test-writer-compat/runtests.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-writer-compat/runtests.jl b/test-writer-compat/runtests.jl index 7d6be10..62ff326 100644 --- a/test-writer-compat/runtests.jl +++ b/test-writer-compat/runtests.jl @@ -91,7 +91,7 @@ unzippers = [ unzip_python, ] -@testset "compat with $(unzipper)" for unzipper in unzippers +@testset "Writer compat with $(unzipper)" for unzipper in unzippers for zippath in readdir(tmp; join=true) mktempdir() do tmpout # Unzip into an output directory From 94d18af151da7386b337d3ac20f64e126354fe9e Mon Sep 17 00:00:00 2001 From: nhz2 Date: Tue, 18 Apr 2023 19:25:41 -0400 Subject: [PATCH 5/8] integrate tests with runtests --- Project.toml | 5 +- test-writer-compat/Project.toml | 5 -- test-writer-compat/runtests.jl | 110 -------------------------------- test/external_unzippers.jl | 84 ++++++++++++++++++++++++ test/runtests.jl | 30 +++++++++ 5 files changed, 118 insertions(+), 116 deletions(-) delete mode 100644 test-writer-compat/Project.toml delete mode 100644 test-writer-compat/runtests.jl create mode 100644 test/external_unzippers.jl diff --git a/Project.toml b/Project.toml index 91750a8..c179f45 100644 --- a/Project.toml +++ b/Project.toml @@ -12,7 +12,10 @@ Zlib_jll = "1.2.11" julia = "1.3.0" [extras] +LibArchive_jll = "1e303b3e-d4db-56ce-88c4-91e52606a1a8" +PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" +p7zip_jll = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" [targets] -test = ["Test"] +test = ["LibArchive_jll", "PyCall", "Test", "p7zip_jll"] diff --git a/test-writer-compat/Project.toml b/test-writer-compat/Project.toml deleted file mode 100644 index f38cdc2..0000000 --- a/test-writer-compat/Project.toml +++ /dev/null @@ -1,5 +0,0 @@ -[deps] -LibArchive_jll = "1e303b3e-d4db-56ce-88c4-91e52606a1a8" -PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0" -ZipFile = "a5390f91-8eb1-5f08-bee0-b1d1ffed6cea" -p7zip_jll = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" diff --git a/test-writer-compat/runtests.jl b/test-writer-compat/runtests.jl deleted file mode 100644 index 62ff326..0000000 --- a/test-writer-compat/runtests.jl +++ /dev/null @@ -1,110 +0,0 @@ -# Test that zip files written by ZipFile.jl can be read by other programs. -# This test requires julia 1.6 or greater to run. -using Test -using ZipFile -import p7zip_jll -import LibArchive_jll -import PyCall - - - -""" -Extract the zip file at zippath into the directory dirpath -Use p7zip -""" -function unzip_p7zip(zippath, dirpath) - # pipe output to devnull because p7zip is noisy - run(pipeline(`$(p7zip_jll.p7zip()) x -y -o$(dirpath) $(zippath)`, devnull)) - nothing -end - -""" -Extract the zip file at zippath into the directory dirpath -Use bsdtar from libarchive -""" -function unzip_bsdtar(zippath, dirpath) - run(`$(LibArchive_jll.bsdtar()) -x -f $(zippath) -C $(dirpath)`) - nothing -end - -""" -Extract the zip file at zippath into the directory dirpath -Use zipfile.py from python standard library -""" -function unzip_python(zippath, dirpath) - zipfile = PyCall.pyimport("zipfile") - f = zipfile.ZipFile(zippath) - isnothing(f.testzip()) || error(string(f.testzip())) - f.extractall(dirpath) - nothing -end - - -""" -Use ZipFile.Writer to write a bunch of zip files to a directory -""" -function write_example_zipfiles(dirpath::AbstractString) - # write an empty zip file - dir = ZipFile.Writer(joinpath(dirpath, "empty.zip")) - close(dir) - - # write a zip file with some basic ASCII files with ASCII file names - zipdata = [ - ("hello.txt", "hello world!\n", ZipFile.Store), - ("info.txt", "Julia\nfor\ntechnical computing\n", ZipFile.Store), - ("julia.txt", "julia\n"^10, ZipFile.Deflate), - ("empty1.txt", "", ZipFile.Store), - ("empty2.txt", "", ZipFile.Deflate), - ] - dir = ZipFile.Writer(joinpath(dirpath, "hello.zip")) - for (name, data, meth) in zipdata - local f = ZipFile.addfile(dir, name; method=meth) - write(f, data) - end - close(dir) - - # TODO fix write a zip file with UTF8 filenames - # zipdata = [ - # ("hello😸.txt", "hello world!\n", ZipFile.Store), - # ] - # dir = ZipFile.Writer(joinpath(dirpath, "utf8.zip")) - # for (name, data, meth) in zipdata - # local f = ZipFile.addfile(dir, name; method=meth) - # write(f, data) - # end - # close(dir) -end - -Debug = false - -tmp = mktempdir() -if Debug - println("temporary directory $tmp") -end - -write_example_zipfiles(tmp) - -# Functions that can unzip into a directory -unzippers = [ - unzip_p7zip, - unzip_bsdtar, - unzip_python, -] - -@testset "Writer compat with $(unzipper)" for unzipper in unzippers - for zippath in readdir(tmp; join=true) - mktempdir() do tmpout - # Unzip into an output directory - unzipper(zippath, tmpout) - # Read zippath with ZipFile.Reader - # Check file names and data match - local dir = ZipFile.Reader(zippath) - for f in dir.files - local name = f.name - local extracted_path = joinpath(tmpout,name) - @test isfile(extracted_path) - @test read(f) == read(extracted_path) - end - end - end -end \ No newline at end of file diff --git a/test/external_unzippers.jl b/test/external_unzippers.jl new file mode 100644 index 0000000..e0b5081 --- /dev/null +++ b/test/external_unzippers.jl @@ -0,0 +1,84 @@ +# Used to test that zip files written by ZipFile.jl can be read by other programs. +# This defines a vector of functions in `unzippers` +# These functions take a zipfile path and a directory path and extract the zipfile into the directory +using Test +using ZipFile +import p7zip_jll +import LibArchive_jll +import PyCall + + + +""" +Extract the zip file at zippath into the directory dirpath +Use p7zip +""" +function unzip_p7zip(zippath, dirpath) + # pipe output to devnull because p7zip is noisy + p7zip_jll.p7zip() do exe + run(pipeline(`$(exe) x -y -o$(dirpath) $(zippath)`, devnull)) + end + nothing +end + +""" +Extract the zip file at zippath into the directory dirpath +Use bsdtar from libarchive +""" +function unzip_bsdtar(zippath, dirpath) + LibArchive_jll.bsdtar() do exe + run(`$(exe) -x -f $(zippath) -C $(dirpath)`) + end + nothing +end + +""" +Extract the zip file at zippath into the directory dirpath +Use zipfile.py from python standard library +""" +function unzip_python(zippath, dirpath) + zipfile = PyCall.pyimport("zipfile") + f = zipfile.ZipFile(zippath) + isnothing(f.testzip()) || error(string(f.testzip())) + f.extractall(dirpath) + nothing +end + + +# This is modified to only check for `unzip` from +# https://github.com/samoconnor/InfoZIP.jl/blob/1247b24dd3183e00baa7890c1a2c7f6766c3d774/src/InfoZIP.jl#L6-L14 +have_infozip() = try + occursin(r"^UnZip.*by Info-ZIP", read(`unzip -h`, String)) +catch ex + if ex isa Base.IOError + return false + end + rethrow(ex) +end + +""" +Extract the zip file at zippath into the directory dirpath +Use unzip from the infamous builtin Info-ZIP +""" +function unzip_infozip(zippath, dirpath) + try + run(`unzip -qq $(zippath) -d $(dirpath)`) + catch + # unzip errors if the zip file is empty for some reason + end + nothing +end + + +unzippers = [ + unzip_p7zip, + unzip_bsdtar, + unzip_python, +] + +if have_infozip() + push!(unzippers, unzip_infozip) +else + @info "system Info-ZIP unzip not found, skipping `unzip_infozip` tests" +end + diff --git a/test/runtests.jl b/test/runtests.jl index 5ce1221..63045bd 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -177,6 +177,36 @@ r = ZipFile.Reader(filename) close(r) close(dir) +# This defines a vector of functions in `unzippers` +# These functions take a zipfile path and a directory path +# They extract the zipfile into the directory +include("external_unzippers.jl") + +@testset "Writer compat with $(unzipper)" for unzipper in unzippers + for filename in readdir(tmp) + endswith(filename, ".zip") || continue + zippath = joinpath(tmp, filename) + mktempdir() do tmpout + # Unzip into an output directory + unzipper(zippath, tmpout) + # Read zippath with ZipFile.Reader + # Check file names and data match + local dir = ZipFile.Reader(zippath) + for f in dir.files + local name = f.name + local extracted_path = joinpath(tmpout, name) + @test isfile(extracted_path) + @test read(f) == read(extracted_path) + end + # Check number of extracted files match + local total_files = sum(walkdir(tmpout)) do (root, dirs, files) + length(files) + end + @test length(dir.files) == total_files + end + end +end + if !Debug rm(tmp, recursive=true) From db13cebf760db583a4bbfc4efdbec0dea3933581 Mon Sep 17 00:00:00 2001 From: nhz2 Date: Tue, 18 Apr 2023 19:58:38 -0400 Subject: [PATCH 6/8] update to julia 1.6 --- .appveyor.yml | 2 +- .cirrus.yml | 2 +- .travis.yml | 2 +- Project.toml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 341823c..cafd74f 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,6 +1,6 @@ environment: matrix: - - julia_version: 1.3 + - julia_version: 1.6 - julia_version: nightly platform: diff --git a/.cirrus.yml b/.cirrus.yml index c005d8c..41d6f75 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -4,7 +4,7 @@ task: name: FreeBSD env: matrix: - - JULIA_VERSION: 1.3 + - JULIA_VERSION: 1.6 - JULIA_VERSION: nightly allow_failures: $JULIA_VERSION == 'nightly' install_script: diff --git a/.travis.yml b/.travis.yml index 0afcda1..16ecc27 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ os: - osx julia: - - 1.3 + - 1.6 - nightly matrix: diff --git a/Project.toml b/Project.toml index c179f45..b707069 100644 --- a/Project.toml +++ b/Project.toml @@ -9,7 +9,7 @@ Zlib_jll = "83775a58-1f1d-513f-b197-d71354ab007a" [compat] Zlib_jll = "1.2.11" -julia = "1.3.0" +julia = "1.6.0" [extras] LibArchive_jll = "1e303b3e-d4db-56ce-88c4-91e52606a1a8" From e73a11d513de4fdd83f5024104251ed7c066918a Mon Sep 17 00:00:00 2001 From: nhz2 Date: Tue, 18 Apr 2023 20:12:13 -0400 Subject: [PATCH 7/8] fix have_infozip --- test/external_unzippers.jl | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/test/external_unzippers.jl b/test/external_unzippers.jl index e0b5081..2b9fa15 100644 --- a/test/external_unzippers.jl +++ b/test/external_unzippers.jl @@ -47,13 +47,12 @@ end # This is modified to only check for `unzip` from # https://github.com/samoconnor/InfoZIP.jl/blob/1247b24dd3183e00baa7890c1a2c7f6766c3d774/src/InfoZIP.jl#L6-L14 -have_infozip() = try - occursin(r"^UnZip.*by Info-ZIP", read(`unzip -h`, String)) -catch ex - if ex isa Base.IOError +function have_infozip() + try + occursin(r"^UnZip.*by Info-ZIP", read(`unzip`, String)) + catch return false end - rethrow(ex) end """ From 83df25aff3607f656e153005f9104fc0e10ac82e Mon Sep 17 00:00:00 2001 From: nhz2 Date: Tue, 18 Apr 2023 21:53:48 -0400 Subject: [PATCH 8/8] fix tests on windows --- test/external_unzippers.jl | 7 ++++--- test/runtests.jl | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/test/external_unzippers.jl b/test/external_unzippers.jl index 2b9fa15..f95e513 100644 --- a/test/external_unzippers.jl +++ b/test/external_unzippers.jl @@ -38,9 +38,10 @@ Use zipfile.py from python standard library """ function unzip_python(zippath, dirpath) zipfile = PyCall.pyimport("zipfile") - f = zipfile.ZipFile(zippath) - isnothing(f.testzip()) || error(string(f.testzip())) - f.extractall(dirpath) + PyCall.@pywith zipfile.ZipFile(zippath) as f begin + isnothing(f.testzip()) || error(string(f.testzip())) + f.extractall(dirpath) + end nothing end diff --git a/test/runtests.jl b/test/runtests.jl index 63045bd..189b45d 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -203,6 +203,7 @@ include("external_unzippers.jl") length(files) end @test length(dir.files) == total_files + close(dir) end end end