From f4f1adb8f302ce986c2ed9d65934da51f41dd606 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Fri, 13 Jul 2018 23:00:07 -0300 Subject: fs: make unpack_archive platform-agnostic using specific fs functions Use luarocks.tools.tar for handling tar files, and add platform-specific functions fs.zip, fs.unzip, fs.bunzip2, fs.gunzip, giving them native implementations using Lua modules or alternative implementations using third-party tools. --- spec/fixtures/abc.bz2 | Bin 0 -> 66 bytes spec/fs_spec.lua | 16 ++++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 spec/fixtures/abc.bz2 (limited to 'spec') diff --git a/spec/fixtures/abc.bz2 b/spec/fixtures/abc.bz2 new file mode 100644 index 00000000..ee786715 Binary files /dev/null and b/spec/fixtures/abc.bz2 differ diff --git a/spec/fs_spec.lua b/spec/fs_spec.lua index 66453404..5bec6168 100644 --- a/spec/fs_spec.lua +++ b/spec/fs_spec.lua @@ -1293,6 +1293,22 @@ describe("Luarocks fs test #unit", function() assert.falsy(exists_file("nonexistent")) end) end) + + describe("fs.bunzip2", function() + + it("uncompresses a .bz2 file", function() + local input = testing_paths.fixtures_dir .. "/abc.bz2" + local output = os.tmpname() + assert.truthy(fs.bunzip2(input, output)) + local fd = io.open(output, "r") + local content = fd:read("*a") + fd:close() + assert.same(300000, #content) + local abc = ("a"):rep(100000)..("b"):rep(100000)..("c"):rep(100000) + assert.same(abc, content) + end) + + end) describe("fs.unzip", function() local tmpdir -- cgit v1.2.3-55-g6feb