diff options
Diffstat (limited to 'spec/make_spec.lua')
-rw-r--r-- | spec/make_spec.lua | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/spec/make_spec.lua b/spec/make_spec.lua new file mode 100644 index 00000000..e684033a --- /dev/null +++ b/spec/make_spec.lua | |||
@@ -0,0 +1,98 @@ | |||
1 | local test_env = require("test/test_environment") | ||
2 | local lfs = require("lfs") | ||
3 | local run = test_env.run | ||
4 | local testing_paths = test_env.testing_paths | ||
5 | |||
6 | test_env.unload_luarocks() | ||
7 | |||
8 | local extra_rocks = { | ||
9 | "/lpeg-0.12-1.src.rock", | ||
10 | "/luasocket-3.0rc1-1.src.rock", | ||
11 | "/luasocket-3.0rc1-1.rockspec", | ||
12 | "/lxsh-0.8.6-2.src.rock", | ||
13 | "/lxsh-0.8.6-2.rockspec" | ||
14 | } | ||
15 | |||
16 | describe("LuaRocks make tests #blackbox #b_make", function() | ||
17 | |||
18 | before_each(function() | ||
19 | test_env.setup_specs(extra_rocks) | ||
20 | end) | ||
21 | |||
22 | it("LuaRocks make with no flags/arguments", function() | ||
23 | lfs.chdir("test") | ||
24 | assert.is_false(run.luarocks_bool("make")) | ||
25 | lfs.chdir(testing_paths.luarocks_dir) | ||
26 | end) | ||
27 | |||
28 | it("LuaRocks make with rockspec", function() | ||
29 | -- make luasocket | ||
30 | assert.is_true(run.luarocks_bool("download --source luasocket 3.0rc1-1")) | ||
31 | assert.is_true(run.luarocks_bool("unpack luasocket-3.0rc1-1.src.rock")) | ||
32 | lfs.chdir("luasocket-3.0rc1-1/luasocket-3.0-rc1/") | ||
33 | assert.is_true(run.luarocks_bool(test_env.quiet("make luasocket-3.0rc1-1.rockspec"))) | ||
34 | |||
35 | -- test it | ||
36 | assert.is_true(run.luarocks_bool(test_env.quiet("show luasocket"))) | ||
37 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket")) | ||
38 | |||
39 | -- delete downloaded and unpacked files | ||
40 | lfs.chdir(testing_paths.luarocks_dir) | ||
41 | test_env.remove_dir("luasocket-3.0rc1-1") | ||
42 | assert.is_true(os.remove("luasocket-3.0rc1-1.src.rock")) | ||
43 | end) | ||
44 | |||
45 | describe("LuaRocks making rockspecs (using lxsh)", function() | ||
46 | --download lxsh and unpack it | ||
47 | before_each(function() | ||
48 | assert.is_true(run.luarocks_bool("download --source lxsh 0.8.6-2")) | ||
49 | assert.is_true(run.luarocks_bool("unpack lxsh-0.8.6-2.src.rock")) | ||
50 | assert.is_true(lfs.chdir("lxsh-0.8.6-2/lxsh-0.8.6-1/")) | ||
51 | end) | ||
52 | |||
53 | -- delete downloaded and unpacked files | ||
54 | after_each(function() | ||
55 | assert.is_true(lfs.chdir(testing_paths.luarocks_dir)) | ||
56 | test_env.remove_dir("lxsh-0.8.6-2") | ||
57 | assert.is_true(os.remove("lxsh-0.8.6-2.src.rock")) | ||
58 | end) | ||
59 | |||
60 | it("LuaRocks make default rockspec", function() | ||
61 | assert.is_true(run.luarocks_bool("new_version lxsh-0.8.6-2.rockspec")) | ||
62 | assert.is_true(run.luarocks_bool("make")) | ||
63 | |||
64 | assert.is_true(run.luarocks_bool(test_env.quiet("show lxsh"))) | ||
65 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | ||
66 | end) | ||
67 | |||
68 | it("LuaRocks make unnamed rockspec", function() | ||
69 | os.execute("cp lxsh-0.8.6-2.rockspec rockspec") --rewrite with lfs | ||
70 | assert.is_true(run.luarocks_bool("make")) | ||
71 | |||
72 | assert.is_true(run.luarocks_bool(test_env.quiet("show lxsh"))) | ||
73 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | ||
74 | end) | ||
75 | |||
76 | it("LuaRocks make ambiguous rockspec", function() | ||
77 | assert.is.truthy(os.rename("lxsh-0.8.6-2.rockspec", "lxsh2-0.8.6-2.rockspec")) | ||
78 | assert.is_false(run.luarocks_bool("make")) | ||
79 | |||
80 | assert.is_false(run.luarocks_bool("show lxsh")) | ||
81 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | ||
82 | end) | ||
83 | |||
84 | it("LuaRocks make ambiguous unnamed rockspec", function() | ||
85 | assert.is.truthy(os.rename("lxsh-0.8.6-2.rockspec", "1_rockspec")) | ||
86 | os.execute("cp 1_rockspec 2_rockspec") --rewrite with lfs | ||
87 | assert.is_false(run.luarocks_bool("make")) | ||
88 | |||
89 | assert.is_false(run.luarocks_bool("show lxsh")) | ||
90 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | ||
91 | end) | ||
92 | |||
93 | it("LuaRocks make pack binary rock", function() | ||
94 | assert.is_true(run.luarocks_bool(test_env.quiet("make --deps-mode=none --pack-binary-rock"))) | ||
95 | assert.is.truthy(lfs.attributes("lxsh-0.8.6-2.all.rock")) | ||
96 | end) | ||
97 | end) | ||
98 | end) | ||