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