diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2018-07-13 23:00:07 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2018-07-18 11:24:07 -0300 |
commit | f4f1adb8f302ce986c2ed9d65934da51f41dd606 (patch) | |
tree | c1a7a2755c39acccb2816a5043a8200fb8e2ec74 /spec | |
parent | 94b25d8922a2bae1c6d5e36bf6b0cffd86d91f2a (diff) | |
download | luarocks-f4f1adb8f302ce986c2ed9d65934da51f41dd606.tar.gz luarocks-f4f1adb8f302ce986c2ed9d65934da51f41dd606.tar.bz2 luarocks-f4f1adb8f302ce986c2ed9d65934da51f41dd606.zip |
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.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/fixtures/abc.bz2 | bin | 0 -> 66 bytes | |||
-rw-r--r-- | spec/fs_spec.lua | 16 |
2 files changed, 16 insertions, 0 deletions
diff --git a/spec/fixtures/abc.bz2 b/spec/fixtures/abc.bz2 new file mode 100644 index 00000000..ee786715 --- /dev/null +++ b/spec/fixtures/abc.bz2 | |||
Binary files 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() | |||
1293 | assert.falsy(exists_file("nonexistent")) | 1293 | assert.falsy(exists_file("nonexistent")) |
1294 | end) | 1294 | end) |
1295 | end) | 1295 | end) |
1296 | |||
1297 | describe("fs.bunzip2", function() | ||
1298 | |||
1299 | it("uncompresses a .bz2 file", function() | ||
1300 | local input = testing_paths.fixtures_dir .. "/abc.bz2" | ||
1301 | local output = os.tmpname() | ||
1302 | assert.truthy(fs.bunzip2(input, output)) | ||
1303 | local fd = io.open(output, "r") | ||
1304 | local content = fd:read("*a") | ||
1305 | fd:close() | ||
1306 | assert.same(300000, #content) | ||
1307 | local abc = ("a"):rep(100000)..("b"):rep(100000)..("c"):rep(100000) | ||
1308 | assert.same(abc, content) | ||
1309 | end) | ||
1310 | |||
1311 | end) | ||
1296 | 1312 | ||
1297 | describe("fs.unzip", function() | 1313 | describe("fs.unzip", function() |
1298 | local tmpdir | 1314 | local tmpdir |