aboutsummaryrefslogtreecommitdiff
path: root/spec/build_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'spec/build_spec.lua')
-rw-r--r--spec/build_spec.lua181
1 files changed, 181 insertions, 0 deletions
diff --git a/spec/build_spec.lua b/spec/build_spec.lua
new file mode 100644
index 00000000..1ce99089
--- /dev/null
+++ b/spec/build_spec.lua
@@ -0,0 +1,181 @@
1local test_env = require("test/test_environment")
2local lfs = require("lfs")
3local run = test_env.run
4local testing_paths = test_env.testing_paths
5
6test_env.unload_luarocks()
7
8local extra_rocks = {
9 "/lmathx-20120430.51-1.src.rock",
10 "/lmathx-20120430.51-1.rockspec",
11 "/lmathx-20120430.52-1.src.rock",
12 "/lmathx-20120430.52-1.rockspec",
13 "/lmathx-20150505-1.src.rock",
14 "/lmathx-20150505-1.rockspec",
15 "/lpeg-0.12-1.src.rock",
16 "/lpty-1.0.1-1.src.rock",
17 "/luadoc-3.0.1-1.src.rock",
18 "/luafilesystem-1.6.3-1.src.rock",
19 "/lualogging-1.3.0-1.src.rock",
20 "/luarepl-0.4-1.src.rock",
21 "/luasec-0.6-1.rockspec",
22 "/luasocket-3.0rc1-1.src.rock",
23 "/luasocket-3.0rc1-1.rockspec",
24 "/lxsh-0.8.6-2.src.rock",
25 "/lxsh-0.8.6-2.rockspec",
26 "/stdlib-41.0.0-1.src.rock",
27 "/validate-args-1.5.4-1.rockspec"
28}
29
30describe("LuaRocks build tests #blackbox #b_build", function()
31
32 before_each(function()
33 test_env.setup_specs(extra_rocks)
34 end)
35
36 describe("LuaRocks build - basic testing set", function()
37 it("LuaRocks build with no flags/arguments", function()
38 assert.is_false(run.luarocks_bool("build"))
39 end)
40
41 it("LuaRocks build invalid", function()
42 assert.is_false(run.luarocks_bool("build invalid"))
43 end)
44 end)
45
46 describe("LuaRocks build - building lpeg with flags", function()
47 it("LuaRocks build fail build permissions", function()
48 if test_env.TEST_TARGET_OS == "osx" or test_env.TEST_TARGET_OS == "linux" then
49 assert.is_false(run.luarocks_bool("build --tree=/usr lpeg"))
50 end
51 end)
52
53 it("LuaRocks build fail build permissions parent", function()
54 if test_env.TEST_TARGET_OS == "osx" or test_env.TEST_TARGET_OS == "linux" then
55 assert.is_false(run.luarocks_bool("build --tree=/usr/invalid lpeg"))
56 end
57 end)
58
59 it("LuaRocks build lpeg verbose", function()
60 assert.is_true(run.luarocks_bool("build --verbose lpeg"))
61 end)
62
63 it("LuaRocks build lpeg branch=master", function()
64 assert.is_true(run.luarocks_bool("build --branch=master lpeg"))
65 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg"))
66 end)
67
68 it("LuaRocks build lpeg deps-mode=123", function()
69 assert.is_false(run.luarocks_bool("build --deps-mode=123 lpeg"))
70 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg"))
71 end)
72
73 it("LuaRocks build lpeg only-sources example", function()
74 assert.is_true(run.luarocks_bool("build --only-sources=\"http://example.com\" lpeg"))
75 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg"))
76 end)
77
78 it("LuaRocks build lpeg with empty tree", function()
79 assert.is_false(run.luarocks_bool("build --tree=\"\" lpeg"))
80 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg"))
81 end)
82 end)
83
84 describe("LuaRocks build - basic builds", function()
85
86 it("LuaRocks build luadoc", function()
87 assert.is_true(run.luarocks_bool("build luadoc"))
88 end)
89
90 it("LuaRocks build luacov diff version", function()
91 assert.is_true(run.luarocks_bool("build luacov 0.11.0-1"))
92 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luacov"))
93 end)
94
95 it("LuaRocks build command stdlib", function()
96 assert.is_true(run.luarocks_bool("build stdlib"))
97 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/stdlib"))
98 end)
99
100 it("LuaRocks build install bin luarepl", function()
101 assert.is_true(run.luarocks_bool("build luarepl"))
102 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luarepl"))
103 end)
104
105 it("LuaRocks build supported platforms lpty", function()
106 assert.is_true(run.luarocks_bool("build lpty"))
107 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpty"))
108 end)
109
110 it("LuaRocks build luasec with skipping dependency checks", function()
111 assert.is_true(run.luarocks_bool("build luasec --nodeps"))
112 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasec"))
113 end)
114
115 it("LuaRocks build lmathx deps partial match", function()
116 assert.is_true(run.luarocks_bool("build lmathx"))
117 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lmathx"))
118 end)
119 end)
120
121 describe("LuaRocks build - more complex tests", function()
122
123 it("LuaRocks build luacheck show downloads test_config", function()
124 local out = run.luarocks("build luacheck", { LUAROCKS_CONFIG = testing_paths.testing_dir .. "/testing_config_show_downloads.lua"} )
125 print(out)
126 end)
127
128 it("LuaRocks build luasec only deps", function()
129 assert.is_true(run.luarocks_bool("build luasec --only-deps"))
130 assert.is_false(run.luarocks_bool("show luasec"))
131 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasec"))
132 end)
133
134 it("LuaRocks build only deps of downloaded rockspec of lxsh", function()
135 assert.is_true(run.luarocks_bool("download --rockspec lxsh 0.8.6-2"))
136 assert.is_true(run.luarocks_bool("build lxsh-0.8.6-2.rockspec --only-deps"))
137 assert.is_false(run.luarocks_bool("show lxsh"))
138 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh"))
139 assert.is_true(os.remove("lxsh-0.8.6-2.rockspec"))
140 end)
141
142 it("LuaRocks build only deps of downloaded rock of lxsh", function()
143 assert.is_true(run.luarocks_bool("download --source lxsh 0.8.6-2"))
144 assert.is_true(run.luarocks_bool("build lxsh-0.8.6-2.src.rock --only-deps"))
145 assert.is_false(run.luarocks_bool("show lxsh"))
146 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh"))
147 assert.is_true(os.remove("lxsh-0.8.6-2.src.rock"))
148 end)
149
150 it("LuaRocks build no https", function()
151 assert.is_true(run.luarocks_bool("download --rockspec validate-args 1.5.4-1"))
152 assert.is_true(run.luarocks_bool("build validate-args-1.5.4-1.rockspec"))
153
154 assert.is_true(run.luarocks_bool("show validate-args"))
155 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/validate-args"))
156
157 assert.is_true(os.remove("validate-args-1.5.4-1.rockspec"))
158 end)
159
160 it("LuaRocks build with https", function()
161 assert.is_true(run.luarocks_bool("download --rockspec validate-args 1.5.4-1"))
162 assert.is_true(run.luarocks_bool("install luasec"))
163 assert.is_true(run.luarocks_bool("build validate-args-1.5.4-1.rockspec"))
164
165 assert.is_true(run.luarocks_bool("show validate-args"))
166 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/validate-args"))
167
168 assert.is_true(os.remove("validate-args-1.5.4-1.rockspec"))
169 end)
170
171 it("LuaRocks build missing external", function()
172 assert.is_true(test_env.need_luasocket())
173 assert.is_false(run.luarocks_bool("build " .. testing_paths.testing_dir .. "/testfiles/missing_external-0.1-1.rockspec INEXISTENT_INCDIR=\"/invalid/dir\""))
174 end)
175
176 it("LuaRocks build invalid patch", function()
177 assert.is_true(test_env.need_luasocket())
178 assert.is_false(run.luarocks_bool("build " .. testing_paths.testing_dir .. "/testfiles/invalid_patch-0.1-1.rockspec"))
179 end)
180 end)
181end)