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