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..2ede5211
--- /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.truthy(run.luarocks("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 it("LuaRocks build luadoc", function()
86 assert.is_true(run.luarocks_bool(test_env.quiet("build luadoc")))
87 end)
88
89 it("LuaRocks build luacov diff version", function()
90 assert.is_true(run.luarocks_bool("build luacov 0.11.0-1"))
91 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luacov"))
92 end)
93
94 it("LuaRocks build command stdlib", function()
95 assert.is_true(run.luarocks_bool("build stdlib"))
96 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/stdlib"))
97 end)
98
99 it("LuaRocks build install bin luarepl", function()
100 assert.is_true(run.luarocks_bool("build luarepl"))
101 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luarepl"))
102 end)
103
104 it("LuaRocks build supported platforms lpty", function()
105 assert.is_true(run.luarocks_bool(test_env.quiet("build lpty")))
106 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpty"))
107 end)
108
109 it("LuaRocks build luasec with skipping dependency checks", function()
110 assert.is_true(run.luarocks_bool(test_env.quiet("build luasec --nodeps")))
111 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasec"))
112 end)
113
114 it("LuaRocks build lmathx deps partial match", function()
115 assert.is_true(run.luarocks_bool("build lmathx"))
116 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lmathx"))
117 end)
118 end)
119
120 describe("LuaRocks build - more complex tests", function()
121 if test_env.TYPE_TEST_ENV == "full" then
122 it("LuaRocks build luacheck show downloads test_config", function()
123 local output = run.luarocks("build luacheck", { LUAROCKS_CONFIG = testing_paths.testing_dir .. "/testing_config_show_downloads.lua"} )
124 assert.is.truthy(output:match("%.%.%."))
125 end)
126 end
127
128 it("LuaRocks build luasec only deps", function()
129 assert.is_true(run.luarocks_bool(test_env.quiet("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.truthy(run.luarocks("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.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg"))
140 assert.is_true(os.remove("lxsh-0.8.6-2.rockspec"))
141 end)
142
143 it("LuaRocks build only deps of downloaded rock of lxsh", function()
144 assert.is_true(run.luarocks_bool("download --source lxsh 0.8.6-2"))
145 assert.is.truthy(run.luarocks("build lxsh-0.8.6-2.src.rock --only-deps"))
146 assert.is_false(run.luarocks_bool("show lxsh"))
147 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh"))
148 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg"))
149 assert.is_true(os.remove("lxsh-0.8.6-2.src.rock"))
150 end)
151
152 it("LuaRocks build no https", function()
153 assert.is_true(run.luarocks_bool("download --rockspec validate-args 1.5.4-1"))
154 assert.is_true(run.luarocks_bool("build validate-args-1.5.4-1.rockspec"))
155
156 assert.is.truthy(run.luarocks("show validate-args"))
157 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/validate-args"))
158
159 assert.is_true(os.remove("validate-args-1.5.4-1.rockspec"))
160 end)
161
162 it("LuaRocks build with https", function()
163 assert.is_true(run.luarocks_bool("download --rockspec validate-args 1.5.4-1"))
164 assert.is_true(run.luarocks_bool(test_env.quiet("install luasec")))
165 assert.is_true(run.luarocks_bool("build validate-args-1.5.4-1.rockspec"))
166
167 assert.is.truthy(run.luarocks("show validate-args"))
168 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/validate-args"))
169
170 assert.is_true(os.remove("validate-args-1.5.4-1.rockspec"))
171 end)
172
173 it("LuaRocks build missing external", function()
174 assert.is_false(run.luarocks_bool("build " .. testing_paths.testing_dir .. "/testfiles/missing_external-0.1-1.rockspec INEXISTENT_INCDIR=\"/invalid/dir\""))
175 end)
176
177 it("LuaRocks build invalid patch", function()
178 assert.is_false(run.luarocks_bool("build " .. testing_paths.testing_dir .. "/testfiles/invalid_patch-0.1-1.rockspec"))
179 end)
180 end)
181end)