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