diff options
Diffstat (limited to 'spec/unpack_spec.lua')
-rw-r--r-- | spec/unpack_spec.lua | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/spec/unpack_spec.lua b/spec/unpack_spec.lua new file mode 100644 index 00000000..495c514e --- /dev/null +++ b/spec/unpack_spec.lua | |||
@@ -0,0 +1,67 @@ | |||
1 | local test_env = require("test/test_environment") | ||
2 | local run = test_env.run | ||
3 | local testing_paths = test_env.testing_paths | ||
4 | local lfs = require("lfs") | ||
5 | |||
6 | test_env.unload_luarocks() | ||
7 | |||
8 | local extra_rocks = { | ||
9 | "/cprint-0.1-2.src.rock", | ||
10 | "/cprint-0.1-2.rockspec", | ||
11 | "/luazip-1.2.4-1.rockspec" | ||
12 | } | ||
13 | |||
14 | describe("LuaRocks unpack tests #blackbox #b_unpack", function() | ||
15 | |||
16 | before_each(function() | ||
17 | test_env.setup_specs(extra_rocks) | ||
18 | end) | ||
19 | |||
20 | describe("LuaRocks unpack basic fail tests", function() | ||
21 | it("LuaRocks unpack with no flags/arguments", function() | ||
22 | assert.is_false(run.luarocks_bool("unpack")) | ||
23 | end) | ||
24 | it("LuaRocks unpack with invalid rockspec", function() | ||
25 | assert.is_false(run.luarocks_bool("unpack invalid.rockspec")) | ||
26 | end) | ||
27 | it("LuaRocks unpack with invalid patch", function() | ||
28 | assert.is_false(run.luarocks_bool("unpack " .. testing_paths.testing_dir .. "/testfiles/invalid_patch-0.1-1.rockspec")) | ||
29 | end) | ||
30 | end) | ||
31 | |||
32 | describe("LuaRocks unpack more complex tests", function() | ||
33 | it("LuaRocks unpack download", function() | ||
34 | assert.is_true(run.luarocks_bool("unpack cprint")) | ||
35 | test_env.remove_dir("cprint-0.1-2") | ||
36 | end) | ||
37 | it("LuaRocks unpack src", function() | ||
38 | assert.is_true(run.luarocks_bool("download --source cprint")) | ||
39 | assert.is_true(run.luarocks_bool("unpack cprint-0.1-2.src.rock")) | ||
40 | os.remove("cprint-0.1-2.src.rock") | ||
41 | test_env.remove_dir("cprint-0.1-2") | ||
42 | end) | ||
43 | it("LuaRocks unpack rockspec", function() | ||
44 | assert.is_true(run.luarocks_bool("download --rockspec cprint")) | ||
45 | assert.is_true(run.luarocks_bool("unpack cprint-0.1-2.rockspec")) | ||
46 | os.remove("cprint-0.1-2.rockspec") | ||
47 | os.remove("lua-cprint") | ||
48 | test_env.remove_dir("cprint-0.1-2") | ||
49 | end) | ||
50 | -- #595 luarocks unpack of a git:// rockspec fails to copy the rockspec | ||
51 | it("LuaRocks unpack git:// rockspec", function() | ||
52 | assert.is_true(run.luarocks_bool("download --rockspec cprint")) | ||
53 | assert.is_true(run.luarocks_bool("unpack luazip-1.2.4-1.rockspec")) | ||
54 | assert.is_truthy(lfs.attributes("luazip-1.2.4-1/luazip/luazip-1.2.4-1.rockspec")) | ||
55 | test_env.remove_dir("luazip-1.2.4-1") | ||
56 | end) | ||
57 | it("LuaRocks unpack binary", function() | ||
58 | assert.is_true(run.luarocks_bool("build cprint")) | ||
59 | assert.is_true(run.luarocks_bool("pack cprint")) | ||
60 | assert.is_true(run.luarocks_bool("unpack cprint-0.1-2." .. test_env.platform .. ".rock")) | ||
61 | test_env.remove_dir("cprint-0.1-2") | ||
62 | os.remove("cprint-0.1-2." .. test_env.platform .. ".rock") | ||
63 | end) | ||
64 | end) | ||
65 | end) | ||
66 | |||
67 | |||