diff options
Diffstat (limited to '')
-rwxr-xr-x | test/testing.sh | 651 |
1 files changed, 0 insertions, 651 deletions
diff --git a/test/testing.sh b/test/testing.sh deleted file mode 100755 index cb10441c..00000000 --- a/test/testing.sh +++ /dev/null | |||
@@ -1,651 +0,0 @@ | |||
1 | #!/bin/bash -e | ||
2 | |||
3 | # Setup ######################################### | ||
4 | |||
5 | [ -e ../configure ] || { | ||
6 | echo "Please run this from the test/ directory." | ||
7 | exit 1 | ||
8 | } | ||
9 | |||
10 | if [ -z "$*" ] | ||
11 | then | ||
12 | ps aux | grep -q '[s]shd' || { | ||
13 | echo "Run sudo /bin/sshd in order to perform all tests." | ||
14 | exit 1 | ||
15 | } | ||
16 | fi | ||
17 | |||
18 | if [ "$1" == "--travis" ] | ||
19 | then | ||
20 | travis=true | ||
21 | shift | ||
22 | fi | ||
23 | |||
24 | luaversion=5.1.5 | ||
25 | |||
26 | if [ "$1" == "--lua" ] | ||
27 | then | ||
28 | shift | ||
29 | luaversion=$1 | ||
30 | shift | ||
31 | fi | ||
32 | |||
33 | luashortversion=`echo $luaversion | cut -d. -f 1-2` | ||
34 | |||
35 | testing_dir="$PWD" | ||
36 | |||
37 | testing_lrprefix="$testing_dir/testing_lrprefix-$luaversion" | ||
38 | testing_tree="$testing_dir/testing-$luaversion" | ||
39 | testing_sys_tree="$testing_dir/testing_sys-$luaversion" | ||
40 | testing_tree_copy="$testing_dir/testing_copy-$luaversion" | ||
41 | testing_sys_tree_copy="$testing_dir/testing_sys_copy-$luaversion" | ||
42 | testing_cache="$testing_dir/testing_cache-$luaversion" | ||
43 | testing_server="$testing_dir/testing_server-$luaversion" | ||
44 | |||
45 | if [ "$1" == "--clean" ] | ||
46 | then | ||
47 | shift | ||
48 | rm -rf "$testing_cache" | ||
49 | rm -rf "$testing_server" | ||
50 | fi | ||
51 | |||
52 | [ "$1" ] || rm -f luacov.stats.out | ||
53 | rm -f luacov.report.out | ||
54 | rm -rf /tmp/luarocks_testing | ||
55 | mkdir /tmp/luarocks_testing | ||
56 | rm -rf "$testing_lrprefix" | ||
57 | rm -rf "$testing_tree" | ||
58 | rm -rf "$testing_sys_tree" | ||
59 | rm -rf "$testing_tree_copy" | ||
60 | rm -rf "$testing_sys_tree_copy" | ||
61 | rm -rf "$testing_dir/testing_config.lua" | ||
62 | rm -rf "$testing_dir/testing_config_show_downloads.lua" | ||
63 | rm -rf "$testing_dir/testing_config_sftp.lua" | ||
64 | rm -rf "$testing_dir/luacov.config" | ||
65 | |||
66 | mkdir -p "$testing_cache" | ||
67 | |||
68 | [ "$1" = "clean" ] && { | ||
69 | rm -f luacov.stats.out | ||
70 | exit 0 | ||
71 | } | ||
72 | |||
73 | cat <<EOF > $testing_dir/testing_config.lua | ||
74 | rocks_trees = { | ||
75 | "$testing_tree", | ||
76 | { name = "system", root = "$testing_sys_tree" }, | ||
77 | } | ||
78 | rocks_servers = { | ||
79 | "$testing_server" | ||
80 | } | ||
81 | local_cache = "$testing_cache" | ||
82 | upload_server = "testing" | ||
83 | upload_user = "$USER" | ||
84 | upload_servers = { | ||
85 | testing = { | ||
86 | rsync = "localhost/tmp/luarocks_testing", | ||
87 | }, | ||
88 | } | ||
89 | external_deps_dirs = { | ||
90 | "/usr/local", | ||
91 | "/usr", | ||
92 | -- These are used for a test that fails, so it | ||
93 | -- can point to invalid paths: | ||
94 | { | ||
95 | prefix = "/opt", | ||
96 | bin = "bin", | ||
97 | include = "include", | ||
98 | lib = { "lib", "lib64" }, | ||
99 | } | ||
100 | } | ||
101 | EOF | ||
102 | ( | ||
103 | cat $testing_dir/testing_config.lua | ||
104 | echo "show_downloads = true" | ||
105 | ) > $testing_dir/testing_config_show_downloads.lua | ||
106 | cat <<EOF > $testing_dir/testing_config_sftp.lua | ||
107 | rocks_trees = { | ||
108 | "$testing_tree", | ||
109 | "$testing_sys_tree", | ||
110 | } | ||
111 | local_cache = "$testing_cache" | ||
112 | upload_server = "testing" | ||
113 | upload_user = "$USER" | ||
114 | upload_servers = { | ||
115 | testing = { | ||
116 | sftp = "localhost/tmp/luarocks_testing", | ||
117 | }, | ||
118 | } | ||
119 | EOF | ||
120 | cat <<EOF > $testing_dir/luacov.config | ||
121 | return { | ||
122 | statsfile = "$testing_dir/luacov.stats.out", | ||
123 | reportfile = "$testing_dir/luacov.report.out", | ||
124 | modules = { | ||
125 | ["luarocks"] = "src/bin/luarocks", | ||
126 | ["luarocks-admin"] = "src/bin/luarocks-admin", | ||
127 | ["luarocks.*"] = "src", | ||
128 | ["luarocks.*.*"] = "src", | ||
129 | ["luarocks.*.*.*"] = "src" | ||
130 | } | ||
131 | } | ||
132 | EOF | ||
133 | |||
134 | export LUAROCKS_CONFIG="$testing_dir/testing_config.lua" | ||
135 | export LUA_PATH= | ||
136 | export LUA_CPATH= | ||
137 | |||
138 | if [ "$travis" ] | ||
139 | then | ||
140 | luadir=/tmp/lua-$luaversion | ||
141 | pushd /tmp | ||
142 | if [ ! -e "$luadir/bin/lua" ] | ||
143 | then | ||
144 | mkdir -p lua | ||
145 | echo "Downloading lua $luaversion..." | ||
146 | wget "http://www.lua.org/ftp/lua-$luaversion.tar.gz" &> /dev/null | ||
147 | tar zxpf "lua-$luaversion.tar.gz" | ||
148 | cd "lua-$luaversion" | ||
149 | echo "Building lua $luaversion..." | ||
150 | make linux INSTALL_TOP="$luadir" &> /dev/null | ||
151 | make install INSTALL_TOP="$luadir" &> /dev/null | ||
152 | fi | ||
153 | popd | ||
154 | [ -e ~/.ssh/id_rsa.pub ] || ssh-keygen -t rsa -P "" -f ~/.ssh/id_rsa | ||
155 | cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys | ||
156 | chmod og-wx ~/.ssh/authorized_keys | ||
157 | ssh-keyscan localhost >> ~/.ssh/known_hosts | ||
158 | else | ||
159 | luadir="/Programs/Lua/Current" | ||
160 | if [ ! -e "$luadir" ] | ||
161 | then | ||
162 | luadir="/usr/local" | ||
163 | fi | ||
164 | fi | ||
165 | |||
166 | if [ `uname -m` = i686 ] | ||
167 | then | ||
168 | platform="linux-x86" | ||
169 | else | ||
170 | platform="linux-x86_64" | ||
171 | fi | ||
172 | |||
173 | lua="$luadir/bin/lua" | ||
174 | |||
175 | version_luasocket=3.0rc1 | ||
176 | verrev_luasocket=${version_luasocket}-1 | ||
177 | srcdir_luasocket=luasocket-3.0-rc1 | ||
178 | |||
179 | version_cprint=0.1 | ||
180 | verrev_cprint=0.1-2 | ||
181 | |||
182 | new_version_say=1.2-1 | ||
183 | old_version_say=1.0-1 | ||
184 | |||
185 | version_luacov=0.11.0 | ||
186 | verrev_luacov=${version_luacov}-1 | ||
187 | version_lxsh=0.8.6 | ||
188 | version_validate_args=1.5.4 | ||
189 | verrev_validate_args=1.5.4-1 | ||
190 | verrev_lxsh=${version_lxsh}-2 | ||
191 | version_abelhas=1.0 | ||
192 | verrev_abelhas=${version_abelhas}-1 | ||
193 | |||
194 | luasec=luasec | ||
195 | |||
196 | cd .. | ||
197 | ./configure --with-lua="$luadir" --prefix="$testing_lrprefix" | ||
198 | make clean | ||
199 | make src/luarocks/site_config.lua | ||
200 | make dev | ||
201 | cd src | ||
202 | basedir=$PWD | ||
203 | run_lua() { | ||
204 | if [ "$1" = "--noecho" ]; then shift; noecho=1; else noecho=0; fi | ||
205 | if [ "$1" = "--nocov" ]; then shift; nocov=1; else nocov=0; fi | ||
206 | if [ "$noecho" = 0 ] | ||
207 | then | ||
208 | echo $* | ||
209 | fi | ||
210 | cmd=$1 | ||
211 | shift | ||
212 | if [ "$nocov" = 0 ] | ||
213 | then | ||
214 | "$lua" -e"require('luacov.runner')('$testing_dir/luacov.config')" "$basedir/bin/$cmd" "$@" | ||
215 | else | ||
216 | "$lua" "$basedir/bin/$cmd" "$@" | ||
217 | fi | ||
218 | } | ||
219 | luarocks="run_lua luarocks" | ||
220 | luarocks_nocov="run_lua --nocov luarocks" | ||
221 | luarocks_noecho="run_lua --noecho luarocks" | ||
222 | luarocks_noecho_nocov="run_lua --noecho --nocov luarocks" | ||
223 | luarocks_admin="run_lua luarocks-admin" | ||
224 | luarocks_admin_nocov="run_lua --nocov luarocks-admin" | ||
225 | |||
226 | ################################################### | ||
227 | |||
228 | mkdir -p "$testing_server" | ||
229 | ( | ||
230 | cd "$testing_server" | ||
231 | luarocks_repo="https://luarocks.org" | ||
232 | get() { [ -e `basename "$1"` ] || wget -c "$1"; } | ||
233 | get "$luarocks_repo/luacov-${verrev_luacov}.src.rock" | ||
234 | get "$luarocks_repo/luacov-${verrev_luacov}.rockspec" | ||
235 | get "$luarocks_repo/luadoc-3.0.1-1.src.rock" | ||
236 | get "$luarocks_repo/lualogging-1.3.0-1.src.rock" | ||
237 | get "$luarocks_repo/luasocket-${verrev_luasocket}.src.rock" | ||
238 | get "$luarocks_repo/luasocket-${verrev_luasocket}.rockspec" | ||
239 | get "$luarocks_repo/luafilesystem-1.6.3-1.src.rock" | ||
240 | get "$luarocks_repo/stdlib-41.0.0-1.src.rock" | ||
241 | get "$luarocks_repo/luarepl-0.4-1.src.rock" | ||
242 | get "$luarocks_repo/validate-args-1.5.4-1.rockspec" | ||
243 | get "$luarocks_repo/luasec-0.6-1.rockspec" | ||
244 | get "$luarocks_repo/luabitop-1.0.2-1.rockspec" | ||
245 | get "$luarocks_repo/luabitop-1.0.2-1.src.rock" | ||
246 | get "$luarocks_repo/lpty-1.0.1-1.src.rock" | ||
247 | get "$luarocks_repo/cprint-${verrev_cprint}.src.rock" | ||
248 | get "$luarocks_repo/cprint-${verrev_cprint}.rockspec" | ||
249 | get "$luarocks_repo/wsapi-1.6-1.src.rock" | ||
250 | get "$luarocks_repo/lxsh-${verrev_lxsh}.src.rock" | ||
251 | get "$luarocks_repo/lxsh-${verrev_lxsh}.rockspec" | ||
252 | get "$luarocks_repo/abelhas-${verrev_abelhas}.rockspec" | ||
253 | get "$luarocks_repo/lzlib-0.4.1.53-1.src.rock" | ||
254 | get "$luarocks_repo/lpeg-0.12-1.src.rock" | ||
255 | get "$luarocks_repo/luaposix-33.2.1-1.src.rock" | ||
256 | get "$luarocks_repo/md5-1.2-1.src.rock" | ||
257 | get "$luarocks_repo/lmathx-20120430.51-1.src.rock" | ||
258 | get "$luarocks_repo/lmathx-20120430.51-1.rockspec" | ||
259 | get "$luarocks_repo/lmathx-20120430.52-1.src.rock" | ||
260 | get "$luarocks_repo/lmathx-20120430.52-1.rockspec" | ||
261 | get "$luarocks_repo/lmathx-20150505-1.src.rock" | ||
262 | get "$luarocks_repo/lmathx-20150505-1.rockspec" | ||
263 | get "$luarocks_repo/lua-path-0.2.3-1.src.rock" | ||
264 | get "$luarocks_repo/lua-cjson-2.1.0-1.src.rock" | ||
265 | get "$luarocks_repo/luacov-coveralls-0.1.1-1.src.rock" | ||
266 | get "$luarocks_repo/say-1.2-1.src.rock" | ||
267 | get "$luarocks_repo/say-1.0-1.src.rock" | ||
268 | get "$luarocks_repo/luassert-1.7.0-1.src.rock" | ||
269 | ) | ||
270 | $luarocks_admin_nocov make_manifest "$testing_server" | ||
271 | |||
272 | ################################################### | ||
273 | |||
274 | checksum_path() { | ||
275 | ( cd "$1"; find . -printf "%s %p\n" | md5sum ) | ||
276 | } | ||
277 | |||
278 | build_environment() { | ||
279 | rm -rf "$testing_tree" | ||
280 | rm -rf "$testing_sys_tree" | ||
281 | rm -rf "$testing_tree_copy" | ||
282 | rm -rf "$testing_sys_tree_copy" | ||
283 | mkdir -p "$testing_tree" | ||
284 | mkdir -p "$testing_sys_tree" | ||
285 | $luarocks_admin_nocov make_manifest "$testing_cache" | ||
286 | for package in "$@" | ||
287 | do | ||
288 | $luarocks_nocov install --only-server="$testing_cache" --tree="$testing_sys_tree" $package || { | ||
289 | $luarocks_nocov build --tree="$testing_sys_tree" $package | ||
290 | $luarocks_nocov pack --tree="$testing_sys_tree" $package; mv $package-*.rock "$testing_cache" | ||
291 | } | ||
292 | done | ||
293 | export LUA_PATH= | ||
294 | export LUA_CPATH= | ||
295 | eval `$luarocks_noecho_nocov path --bin` | ||
296 | cp -a "$testing_tree" "$testing_tree_copy" | ||
297 | cp -a "$testing_sys_tree" "$testing_sys_tree_copy" | ||
298 | testing_tree_copy_md5=`checksum_path "$testing_tree_copy"` | ||
299 | testing_sys_tree_copy_md5=`checksum_path "$testing_sys_tree_copy"` | ||
300 | } | ||
301 | |||
302 | reset_environment() { | ||
303 | testing_tree_md5=`checksum_path "$testing_tree"` | ||
304 | testing_sys_tree_md5=`checksum_path "$testing_sys_tree"` | ||
305 | if [ "$testing_tree_md5" != "$testing_tree_copy_md5" ] | ||
306 | then | ||
307 | rm -rf "$testing_tree" | ||
308 | cp -a "$testing_tree_copy" "$testing_tree" | ||
309 | fi | ||
310 | if [ "$testing_sys_tree_md5" != "$testing_sys_tree_copy_md5" ] | ||
311 | then | ||
312 | rm -rf "$testing_sys_tree" | ||
313 | cp -a "$testing_sys_tree_copy" "$testing_sys_tree" | ||
314 | fi | ||
315 | } | ||
316 | |||
317 | need() { | ||
318 | echo "Obtaining $1 $2..." | ||
319 | if $luarocks show $1 &> /dev/null | ||
320 | then | ||
321 | echo "Already available" | ||
322 | return | ||
323 | fi | ||
324 | platrock="$1-$2.$platform.rock" | ||
325 | if [ ! -e "$testing_cache/$platrock" ] | ||
326 | then | ||
327 | echo "Building $1 $2..." | ||
328 | $luarocks_nocov build --pack-binary-rock $1 $2 | ||
329 | mv "$platrock" "$testing_cache" | ||
330 | fi | ||
331 | echo "Installing $1 $2..." | ||
332 | $luarocks_nocov install "$testing_cache/$platrock" | ||
333 | return | ||
334 | } | ||
335 | need_luasocket() { need luasocket $verrev_luasocket; } | ||
336 | |||
337 | # Tests ######################################### | ||
338 | test_version() { $luarocks --version; } | ||
339 | |||
340 | fail_unknown_command() { $luarocks unknown_command; } | ||
341 | |||
342 | fail_arg_boolean_parameter() { $luarocks --porcelain=invalid; } | ||
343 | fail_arg_boolean_unknown() { $luarocks --invalid-flag; } | ||
344 | fail_arg_string_no_parameter() { $luarocks --server; } | ||
345 | fail_arg_string_followed_by_flag() { $luarocks --server --porcelain; } | ||
346 | fail_arg_string_unknown() { $luarocks --invalid-flag=abc; } | ||
347 | |||
348 | fail_invalid_assignment() { $luarocks invalid=5; } | ||
349 | |||
350 | test_empty_list() { $luarocks list; } | ||
351 | test_list_outdated() { $luarocks list --outdated; } | ||
352 | |||
353 | fail_sysconfig_err() { local err=0; local scdir="$testing_lrprefix/etc/luarocks/"; mkdir -p "$scdir"; local sysconfig="$scdir/config.lua"; echo "aoeui" > "$sysconfig"; echo $sysconfig; $luarocks list; err=$?; rm "$sysconfig"; return "$err"; } | ||
354 | fail_sysconfig_default_err() { local err=0; local scdir="$testing_lrprefix/etc/luarocks/"; mkdir -p "$scdir"; local sysconfig="$scdir/config-$luashortversion.lua"; echo "aoeui" > "$sysconfig"; echo $sysconfig; $luarocks list; err=$?; rm "$sysconfig"; return "$err"; } | ||
355 | |||
356 | fail_build_noarg() { $luarocks build; } | ||
357 | fail_download_noarg() { $luarocks download; } | ||
358 | fail_install_noarg() { $luarocks install; } | ||
359 | fail_lint_noarg() { $luarocks lint; } | ||
360 | fail_search_noarg() { $luarocks search; } | ||
361 | fail_show_noarg() { $luarocks show; } | ||
362 | fail_unpack_noarg() { $luarocks unpack; } | ||
363 | fail_upload_noarg() { $luarocks upload; } | ||
364 | fail_remove_noarg() { $luarocks remove; } | ||
365 | fail_doc_noarg() { $luarocks doc; } | ||
366 | |||
367 | fail_build_invalid() { $luarocks build invalid; } | ||
368 | fail_download_invalid() { $luarocks download invalid; } | ||
369 | fail_install_invalid() { $luarocks install invalid; } | ||
370 | fail_lint_invalid() { $luarocks lint invalid; } | ||
371 | fail_show_invalid() { $luarocks show invalid; } | ||
372 | fail_new_version_invalid() { $luarocks new_version invalid; } | ||
373 | |||
374 | test_list_invalidtree() { $luarocks --tree=/some/invalid/tree list; } | ||
375 | |||
376 | fail_inexistent_dir() { mkdir idontexist; cd idontexist; rmdir ../idontexist; $luarocks; err=$?; cd ..; return $err; } | ||
377 | |||
378 | fail_make_norockspec() { $luarocks make; } | ||
379 | |||
380 | fail_build_permissions() { $luarocks build --tree=/usr lpeg; } | ||
381 | fail_build_permissions_parent() { $luarocks build --tree=/usr/invalid lpeg; } | ||
382 | |||
383 | test_build_verbose() { $luarocks build --verbose lpeg; } | ||
384 | test_build_timeout() { $luarocks --timeout=10; } | ||
385 | fail_build_timeout_invalid() { $luarocks --timeout=abc; } | ||
386 | test_build_branch() { $luarocks build --branch=master lpeg; } | ||
387 | fail_build_invalid_entry_deps_mode() { $luarocks build --deps-mode=123 lpeg; } | ||
388 | test_build_only_server() { $luarocks --only-server=testing; } | ||
389 | test_build_only_sources() { $luarocks build --only-sources="http://example.com" lpeg; } | ||
390 | fail_build_blank_arg() { $luarocks build --tree="" lpeg; } | ||
391 | test_build_withpatch() { need_luasocket; $luarocks build luadoc; } | ||
392 | test_build_diffversion() { $luarocks build luacov ${version_luacov}; } | ||
393 | test_build_command() { $luarocks build stdlib; } | ||
394 | test_build_install_bin() { $luarocks build luarepl; } | ||
395 | test_build_nohttps() { need_luasocket; $luarocks download --rockspec validate-args ${verrev_validate_args} && $luarocks build ./validate-args-${version_validate_args}-1.rockspec && rm ./validate-args-${version_validate_args}-1.rockspec; } | ||
396 | test_build_https() { need_luasocket; $luarocks download --rockspec validate-args ${verrev_validate_args} && $luarocks install $luasec && $luarocks build ./validate-args-${verrev_validate_args}.rockspec && rm ./validate-args-${verrev_validate_args}.rockspec; } | ||
397 | test_build_supported_platforms() { $luarocks build lpty; } | ||
398 | test_build_only_deps_rockspec() { $luarocks download --rockspec lxsh ${verrev_lxsh} && $luarocks build ./lxsh-${verrev_lxsh}.rockspec --only-deps && { $luarocks show lxsh; [ $? -ne 0 ]; }; } | ||
399 | test_build_only_deps_src_rock() { $luarocks download --source lxsh ${verrev_lxsh} && $luarocks build ./lxsh-${verrev_lxsh}.src.rock --only-deps && { $luarocks show lxsh; [ $? -ne 0 ]; }; } | ||
400 | test_build_only_deps() { $luarocks build luasec --only-deps && { $luarocks show luasec; [ $? -ne 0 ]; }; } | ||
401 | test_install_only_deps() { $luarocks install lxsh ${verrev_lxsh} --only-deps && { $luarocks show lxsh; [ $? -ne 0 ]; }; } | ||
402 | test_build_no_deps() { $luarocks build luasec --nodeps; } | ||
403 | test_install_no_deps() { $luarocks install luasec --nodeps; } | ||
404 | fail_build_missing_external() { $luarocks build "$testing_dir/testfiles/missing_external-0.1-1.rockspec" INEXISTENT_INCDIR="/invalid/dir"; } | ||
405 | fail_build_invalidpatch() { need_luasocket; $luarocks build "$testing_dir/testfiles/invalid_patch-0.1-1.rockspec"; } | ||
406 | |||
407 | test_build_deps_partial_match() { $luarocks build lmathx; } | ||
408 | test_build_show_downloads() { export LUAROCKS_CONFIG="$testing_dir/testing_config_show_downloads.lua" && $luarocks build alien; export LUAROCKS_CONFIG="$testing_dir/testing_config.lua"; } | ||
409 | |||
410 | test_download_all() { $luarocks download --all validate-args && rm validate-args-*; } | ||
411 | test_download_rockspecversion() { $luarocks download --rockspec validate-args ${verrev_validate_args} && rm validate-args-*; } | ||
412 | |||
413 | test_help() { $luarocks help; } | ||
414 | fail_help_invalid() { $luarocks help invalid; } | ||
415 | |||
416 | test_install_only_deps() { $luarocks install --only-deps "$testing_cache/luasocket-$verrev_luasocket.$platform.rock"; } | ||
417 | test_install_binaryrock() { $luarocks build --pack-binary-rock cprint && $luarocks install ./cprint-${verrev_cprint}.${platform}.rock && rm ./cprint-${verrev_cprint}.${platform}.rock; } | ||
418 | test_install_with_bin() { $luarocks install wsapi; } | ||
419 | fail_install_notazipfile() { $luarocks install "$testing_dir/testfiles/not_a_zipfile-1.0-1.src.rock"; } | ||
420 | fail_install_invalidpatch() { need_luasocket; $luarocks install "$testing_dir/testfiles/invalid_patch-0.1-1.rockspec"; } | ||
421 | fail_install_invalid_filename() { $luarocks install "invalid.rock"; } | ||
422 | fail_install_invalid_arch() { $luarocks install "foo-1.0-1.impossible-x86.rock"; } | ||
423 | test_install_reinstall() { $luarocks install "$testing_cache/luasocket-$verrev_luasocket.$platform.rock"; $luarocks install --deps-mode=none "$testing_cache/luasocket-$verrev_luasocket.$platform.rock"; } | ||
424 | |||
425 | fail_local_root() { USER=root $luarocks install --local luasocket; } | ||
426 | |||
427 | test_site_config() { mv ../src/luarocks/site_config.lua ../src/luarocks/site_config.lua.tmp; $luarocks; mv ../src/luarocks/site_config.lua.tmp ../src/luarocks/site_config.lua; } | ||
428 | |||
429 | test_lint_ok() { $luarocks download --rockspec validate-args ${verrev_validate_args} && $luarocks lint ./validate-args-${verrev_validate_args}.rockspec && rm ./validate-args-${verrev_validate_args}.rockspec; } | ||
430 | fail_lint_type_mismatch_string() { $luarocks lint "$testing_dir/testfiles/type_mismatch_string-1.0-1.rockspec"; } | ||
431 | fail_lint_type_mismatch_version() { $luarocks lint "$testing_dir/testfiles/type_mismatch_version-1.0-1.rockspec"; } | ||
432 | fail_lint_type_mismatch_table() { $luarocks lint "$testing_dir/testfiles/type_mismatch_table-1.0-1.rockspec"; } | ||
433 | fail_lint_no_build_table() { $luarocks lint "$testing_dir/testfiles/no_build_table-0.1-1.rockspec"; } | ||
434 | |||
435 | test_list() { $luarocks list; } | ||
436 | test_list_porcelain() { $luarocks list --porcelain; } | ||
437 | |||
438 | test_make_with_rockspec() { rm -rf ./luasocket-${verrev_luasocket} && $luarocks download --source luasocket && $luarocks unpack ./luasocket-${verrev_luasocket}.src.rock && cd luasocket-${verrev_luasocket}/${srcdir_luasocket} && $luarocks make luasocket-${verrev_luasocket}.rockspec && cd ../.. && rm -rf ./luasocket-${verrev_luasocket}; } | ||
439 | test_make_default_rockspec() { rm -rf ./lxsh-${verrev_lxsh} && $luarocks download --source lxsh ${verrev_lxsh} && $luarocks unpack ./lxsh-${verrev_lxsh}.src.rock && cd lxsh-${verrev_lxsh}/lxsh-${version_lxsh}-1 && $luarocks new_version lxsh-${verrev_lxsh}.rockspec && $luarocks make && cd ../.. && rm -rf ./lxsh-${verrev_lxsh}; } | ||
440 | test_make_unnamed_rockspec() { rm -rf ./lxsh-${verrev_lxsh} && $luarocks download --source lxsh ${verrev_lxsh} && $luarocks unpack ./lxsh-${verrev_lxsh}.src.rock && cd lxsh-${verrev_lxsh}/lxsh-${version_lxsh}-1 && cp lxsh-${verrev_lxsh}.rockspec rockspec && $luarocks make && cd ../.. && rm -rf ./lxsh-${verrev_lxsh}; } | ||
441 | fail_make_ambiguous_rockspec() { rm -rf ./lxsh-${verrev_lxsh} && $luarocks download --source lxsh ${verrev_lxsh} && $luarocks unpack ./lxsh-${verrev_lxsh}.src.rock && cd lxsh-${verrev_lxsh}/lxsh-${version_lxsh}-1 && cp lxsh-${verrev_lxsh}.rockspec lxsh2-${verrev_lxsh}.rockspec && $luarocks make && cd ../.. && rm -rf ./lxsh-${verrev_lxsh}; } | ||
442 | fail_make_ambiguous_unnamed_rockspec() { rm -rf ./lxsh-${verrev_lxsh} && $luarocks download --source lxsh ${verrev_lxsh} && $luarocks unpack ./lxsh-${verrev_lxsh}.src.rock && cd lxsh-${verrev_lxsh}/lxsh-${version_lxsh}-1 && mv lxsh-${verrev_lxsh}.rockspec 1_rockspec && cp 1_rockspec 2_rockspec && $luarocks make && cd ../.. && rm -rf ./lxsh-${verrev_lxsh}; } | ||
443 | test_make_pack_binary_rock() { rm -rf ./lxsh-${verrev_lxsh} && $luarocks download --source lxsh ${verrev_lxsh} && $luarocks unpack ./lxsh-${verrev_lxsh}.src.rock && cd lxsh-${verrev_lxsh}/lxsh-${version_lxsh}-1 && $luarocks make --deps-mode=none --pack-binary-rock && [ -e ./lxsh-${verrev_lxsh}.all.rock ] && cd ../.. && rm -rf ./lxsh-${verrev_lxsh}; } | ||
444 | |||
445 | test_new_version() { $luarocks download --rockspec luacov ${version_luacov} && $luarocks new_version ./luacov-${version_luacov}-1.rockspec 0.2 && rm ./luacov-0.*; } | ||
446 | test_new_version_url() { $luarocks download --rockspec abelhas 1.0 && $luarocks new_version ./abelhas-1.0-1.rockspec 1.1 https://github.com/downloads/ittner/abelhas/abelhas-1.1.tar.gz && rm ./abelhas-*; } | ||
447 | test_new_version_tag() { $luarocks download --rockspec luacov ${version_luacov} && $luarocks new_version ./luacov-${version_luacov}-1.rockspec --tag v0.3 && rm ./luacov-0.3-1.rockspec; } | ||
448 | test_new_version_tag_without_arg() { rm -rf ./*rockspec && $luarocks download --rockspec luacov ${version_luacov} && $luarocks new_version --tag v0.3 && rm ./luacov-0.3-1.rockspec; } | ||
449 | |||
450 | test_pack() { $luarocks list && $luarocks pack luacov && rm ./luacov-*.rock; } | ||
451 | test_pack_src() { $luarocks install $luasec && $luarocks download --rockspec luasocket && $luarocks pack ./luasocket-${verrev_luasocket}.rockspec && rm ./luasocket-${version_luasocket}-*.rock; } | ||
452 | |||
453 | test_path() { $luarocks path --bin; } | ||
454 | test_path_lr_path() { $luarocks path --lr-path; } | ||
455 | test_path_lr_cpath() { $luarocks path --lr-cpath; } | ||
456 | test_path_lr_bin() { $luarocks path --lr-bin; } | ||
457 | test_path_with_tree() { $luarocks path --tree=lua_modules; } | ||
458 | |||
459 | fail_purge_missing_tree() { $luarocks purge --tree="$testing_tree"; } | ||
460 | fail_purge_tree_notstring() { $luarocks purge --tree=1; } | ||
461 | test_purge() { $luarocks purge --tree="$testing_sys_tree"; } | ||
462 | test_purge_oldversions() { $luarocks purge --old-versions --tree="$testing_sys_tree"; } | ||
463 | |||
464 | test_remove() { $luarocks build abelhas ${version_abelhas} && $luarocks remove abelhas ${version_abelhas}; } | ||
465 | test_remove_force() { need_luasocket; $luarocks build lualogging && $luarocks remove --force luasocket; } | ||
466 | test_remove_force_fast() { need_luasocket; $luarocks build lualogging && $luarocks remove --force-fast luasocket; } | ||
467 | fail_remove_deps() { need_luasocket; $luarocks build lualogging && $luarocks remove luasocket; } | ||
468 | fail_remove_missing() { $luarocks remove missing_rock; } | ||
469 | fail_remove_invalid_name() { $luarocks remove invalid.rock; } | ||
470 | |||
471 | test_search_found() { $luarocks search zlib; } | ||
472 | test_search_missing() { $luarocks search missing_rock; } | ||
473 | test_search_version() { $luarocks search zlib 1.1; } | ||
474 | test_search_all() { $luarocks search --all; } | ||
475 | fail_search_nostring() { $var=123; $luarocks search $var; } | ||
476 | |||
477 | test_show() { $luarocks show luacov; } | ||
478 | test_show_modules() { $luarocks show --modules luacov; } | ||
479 | test_show_home() { $luarocks show --home luacov; } | ||
480 | test_show_deps() { $luarocks show --deps luacov; } | ||
481 | test_show_rockspec() { $luarocks show --rockspec luacov; } | ||
482 | test_show_mversion() { $luarocks show --mversion luacov; } | ||
483 | test_show_rocktree() { $luarocks show --rock-tree luacov; } | ||
484 | test_show_rockdir() { $luarocks show --rock-dir luacov; } | ||
485 | test_show_depends() { need_luasocket; $luarocks install $luasec && $luarocks show luasec; } | ||
486 | test_show_oldversion() { $luarocks install luacov ${version_luacov} && $luarocks show luacov ${version_luacov}; } | ||
487 | |||
488 | test_unpack_download() { rm -rf ./cprint-${verrev_cprint} && $luarocks unpack cprint && rm -rf ./cprint-${verrev_cprint}; } | ||
489 | test_unpack_src() { rm -rf ./cprint-${verrev_cprint} && $luarocks download --source cprint && $luarocks unpack ./cprint-${verrev_cprint}.src.rock && rm -rf ./cprint-${verrev_cprint}; } | ||
490 | test_unpack_rockspec() { rm -rf ./cprint-${verrev_cprint} && $luarocks download --rockspec cprint && $luarocks unpack ./cprint-${verrev_cprint}.rockspec && rm -rf ./cprint-${verrev_cprint}; } | ||
491 | test_unpack_binary() { rm -rf ./cprint-${verrev_cprint} && $luarocks build cprint && $luarocks pack cprint && $luarocks unpack ./cprint-${verrev_cprint}.${platform}.rock && rm -rf ./cprint-${verrev_cprint}; } | ||
492 | fail_unpack_invalidpatch() { need_luasocket; $luarocks unpack "$testing_dir/testfiles/invalid_patch-0.1-1.rockspec"; } | ||
493 | fail_unpack_invalidrockspec() { need_luasocket; $luarocks unpack "invalid.rockspec"; } | ||
494 | |||
495 | fail_upload_invalidrockspec() { $luarocks upload "invalid.rockspec"; } | ||
496 | fail_upload_invalidkey() { $luarocks upload --api-key="invalid" "invalid.rockspec"; } | ||
497 | fail_upload_skippack() { $luarocks upload --api-key="invalid" --skip-pack "luacov-${verrev_luacov}.rockspec"; } | ||
498 | fail_upload_force() { $luarocks install lua-cjson && $luarocks upload --api-key="invalid" --force "luacov-${verrev_luacov}.rockspec" && $luarocks remove lua-cjson; } | ||
499 | |||
500 | |||
501 | test_admin_help() { $luarocks_admin help; } | ||
502 | |||
503 | test_admin_make_manifest() { $luarocks_admin make_manifest; } | ||
504 | test_admin_add_rsync() { $luarocks_admin --server=testing add "$testing_server/luasocket-${verrev_luasocket}.src.rock"; } | ||
505 | test_admin_add_sftp() { export LUAROCKS_CONFIG="$testing_dir/testing_config_sftp.lua" && $luarocks_admin --server=testing add ./luasocket-${verrev_luasocket}.src.rock; export LUAROCKS_CONFIG="$testing_dir/testing_config.lua"; } | ||
506 | fail_admin_add_missing() { $luarocks_admin --server=testing add; } | ||
507 | fail_admin_invalidserver() { $luarocks_admin --server=invalid add "$testing_server/luasocket-${verrev_luasocket}.src.rock"; } | ||
508 | fail_admin_invalidrock() { $luarocks_admin --server=testing add invalid; } | ||
509 | test_admin_refresh_cache() { $luarocks_admin --server=testing refresh_cache; } | ||
510 | test_admin_remove() { $luarocks_admin --server=testing remove luasocket-${verrev_luasocket}.src.rock; } | ||
511 | fail_admin_remove_missing() { $luarocks_admin --server=testing remove; } | ||
512 | fail_admin_split_server_url() { $luarocks_admin --server="localhost@/tmp/luarocks_testing" add "$testing_server/luasocket-${verrev_luasocket}.src.rock"; } | ||
513 | |||
514 | fail_deps_mode_invalid_arg() { $luarocks remove luacov --deps-mode; } | ||
515 | test_deps_mode_one() { $luarocks build --tree="system" lpeg && $luarocks list && $luarocks build --deps-mode=one --tree="$testing_tree" lxsh && [ `$luarocks_noecho list --tree="$testing_tree" --porcelain lpeg | wc -l` = 1 ]; } | ||
516 | test_deps_mode_order() { $luarocks build --tree="system" lpeg && $luarocks build --deps-mode=order --tree="$testing_tree" lxsh && $luarocks_noecho list --tree="$testing_tree" --porcelain lpeg && [ `$luarocks_noecho list --tree="$testing_tree" --porcelain lpeg | wc -l` = 0 ]; } | ||
517 | test_deps_mode_order_sys() { $luarocks build --tree="$testing_tree" lpeg && $luarocks build --deps-mode=order --tree="$testing_sys_tree" lxsh && [ `$luarocks_noecho list --tree="$testing_sys_tree" --porcelain lpeg | wc -l` = 1 ]; } | ||
518 | test_deps_mode_all_sys() { $luarocks build --tree="$testing_tree" lpeg && $luarocks build --deps-mode=all --tree="$testing_sys_tree" lxsh && [ `$luarocks_noecho list --tree="$testing_sys_tree" --porcelain lpeg | wc -l` = 0 ]; } | ||
519 | test_deps_mode_none() { $luarocks build --tree="$testing_tree" --deps-mode=none lxsh; [ `$luarocks_noecho list --tree="$testing_tree" --porcelain lpeg | wc -l` = 0 ]; } | ||
520 | test_deps_mode_nodeps_alias() { $luarocks build --tree="$testing_tree" --nodeps lxsh; [ `$luarocks_noecho list --tree="$testing_tree" --porcelain lpeg | wc -l` = 0 ]; } | ||
521 | test_deps_mode_make_order() { $luarocks build --tree="$testing_sys_tree" lpeg && rm -rf ./lxsh-${verrev_lxsh} && $luarocks download --source lxsh ${verrev_lxsh} && $luarocks unpack ./lxsh-${verrev_lxsh}.src.rock && cd lxsh-${verrev_lxsh}/lxsh-${version_lxsh}-1 && $luarocks make --tree="$testing_tree" --deps-mode=order && cd ../.. && [ `$luarocks_noecho list --tree="$testing_tree" --porcelain lpeg | wc -l` = 0 ] && rm -rf ./lxsh-${verrev_lxsh}; } | ||
522 | test_deps_mode_make_order_sys() { $luarocks build --tree="$testing_tree" lpeg && rm -rf ./lxsh-${verrev_lxsh} && $luarocks download --source lxsh ${verrev_lxsh} && $luarocks unpack ./lxsh-${verrev_lxsh}.src.rock && cd lxsh-${verrev_lxsh}/lxsh-${version_lxsh}-1 && $luarocks make --tree="$testing_sys_tree" --deps-mode=order && cd ../.. && [ `$luarocks_noecho list --tree="$testing_tree" --porcelain lpeg | wc -l` = 1 ] && rm -rf ./lxsh-${verrev_lxsh}; } | ||
523 | |||
524 | test_write_rockspec() { $luarocks write_rockspec git://github.com/keplerproject/luarocks; } | ||
525 | test_write_rockspec_name() { $luarocks write_rockspec luarocks git://github.com/keplerproject/luarocks; } | ||
526 | test_write_rockspec_name_version() { $luarocks write_rockspec luarocks 7.8.9 git://github.com/keplerproject/luarocks; } | ||
527 | test_write_rockspec_current_dir() { $luarocks write_rockspec; } | ||
528 | test_write_rockspec_tag() { $luarocks write_rockspec git://github.com/keplerproject/luarocks --tag=v2.3.0; } | ||
529 | test_write_rockspec_lib() { $luarocks write_rockspec git://github.com/mbalmer/luafcgi --lib=fcgi --license="3-clause BSD" --lua-version=5.1,5.2; } | ||
530 | test_write_rockspec_format() { $luarocks write_rockspec git://github.com/keplerproject/luarocks --rockspec-format=1.1 --lua-version=5.1,5.2; } | ||
531 | test_write_rockspec_fullargs() { $luarocks write_rockspec git://github.com/keplerproject/luarocks --lua-version=5.1,5.2 --license="MIT/X11" --homepage="http://www.luarocks.org" --summary="A package manager for Lua modules"; } | ||
532 | fail_write_rockspec_args() { $luarocks write_rockspec invalid; } | ||
533 | fail_write_rockspec_args_url() { $luarocks write_rockspec http://example.com/invalid.zip; } | ||
534 | test_write_rockspec_http() { $luarocks write_rockspec http://luarocks.org/releases/luarocks-2.1.0.tar.gz --lua-version=5.1; } | ||
535 | test_write_rockspec_basedir() { $luarocks write_rockspec https://github.com/downloads/Olivine-Labs/luassert/luassert-1.2.tar.gz --lua-version=5.1; } | ||
536 | |||
537 | fail_config_noflags() { $luarocks config; } | ||
538 | test_config_lua_incdir() { $luarocks config --lua-incdir; } | ||
539 | test_config_lua_libdir() { $luarocks config --lua-libdir; } | ||
540 | test_config_lua_ver() { $luarocks config --lua-ver; } | ||
541 | fail_config_system_config() { rm -f "$testing_lrprefix/etc/luarocks/config.lua"; $luarocks config --system-config; } | ||
542 | test_config_system_config() { mkdir -p "$testing_lrprefix/etc/luarocks"; touch "$testing_lrprefix/etc/luarocks/config.lua"; $luarocks config --system-config; err=$?; rm -f "$testing_lrprefix/etc/luarocks/config.lua"; return $err; } | ||
543 | fail_config_system_config_invalid() { mkdir -p "$testing_lrprefix/etc/luarocks"; echo "if if if" > "$testing_lrprefix/etc/luarocks/config.lua"; $luarocks config --system-config; err=$?; rm -f "$testing_lrprefix/etc/luarocks/config.lua"; return $err; } | ||
544 | test_config_user_config() { $luarocks config --user-config; } | ||
545 | fail_config_user_config() { LUAROCKS_CONFIG="/missing_file.lua" $luarocks config --user-config; } | ||
546 | test_config_rock_trees() { $luarocks config --rock-trees; } | ||
547 | test_config_help() { $luarocks help config; } | ||
548 | |||
549 | # Tests for https://github.com/keplerproject/luarocks/issues/375 | ||
550 | test_fetch_base_dir() { $lua <<EOF | ||
551 | local fetch = require "luarocks.fetch" | ||
552 | |||
553 | assert("v0.3" == fetch.url_to_base_dir("https://github.com/hishamhm/lua-compat-5.2/archive/v0.3.zip")) | ||
554 | assert("lua-compat-5.2" == fetch.url_to_base_dir("https://github.com/hishamhm/lua-compat-5.2.zip")) | ||
555 | assert("lua-compat-5.2" == fetch.url_to_base_dir("https://github.com/hishamhm/lua-compat-5.2.tar.gz")) | ||
556 | assert("lua-compat-5.2" == fetch.url_to_base_dir("https://github.com/hishamhm/lua-compat-5.2.tar.bz2")) | ||
557 | assert("parser.moon" == fetch.url_to_base_dir("git://github.com/Cirru/parser.moon")) | ||
558 | assert("v0.3" == fetch.url_to_base_dir("https://github.com/hishamhm/lua-compat-5.2/archive/v0.3")) | ||
559 | EOF | ||
560 | } | ||
561 | |||
562 | test_doc() { $luarocks install luarepl; $luarocks doc luarepl; } | ||
563 | test_doc_home() { $luarocks install luacov; $luarocks doc luacov --home; } | ||
564 | fail_doc_invalid() { $luarocks doc invalid; } | ||
565 | test_doc_list() { $luarocks install luacov; $luarocks doc luacov --list; } | ||
566 | test_doc_local() { $luarocks install luacov; $luarocks doc luacov --local; } | ||
567 | test_doc_porcelain() { $luarocks install luacov; $luarocks doc luacov --porcelain; } | ||
568 | |||
569 | # Tests for https://github.com/keplerproject/luarocks/pull/552 | ||
570 | test_install_break_dependencies_warning() { need_luasocket; $luarocks install say ${new_version_say} && $luarocks install luassert && $luarocks install say ${old_version_say}; } | ||
571 | test_install_break_dependencies_force() { need_luasocket; $luarocks install say ${new_version_say} && $luarocks install luassert && $luarocks install --force say ${old_version_say}; } | ||
572 | test_install_break_dependencies_forcefast() { need_luasocket; $luarocks install say ${new_version_say} && $luarocks install luassert && $luarocks install --force-fast say ${old_version_say}; } | ||
573 | |||
574 | # Driver ######################################### | ||
575 | run_tests() { | ||
576 | grep "^test_$1.*(" < $testing_dir/testing.sh | cut -d'(' -f1 | while read test | ||
577 | do | ||
578 | echo "-------------------------------------------" | ||
579 | echo "$test" | ||
580 | echo "-------------------------------------------" | ||
581 | reset_environment | ||
582 | if $test | ||
583 | then | ||
584 | echo "OK: Expected success." | ||
585 | else | ||
586 | if [ $? = 99 ] | ||
587 | then echo "FAIL: Unexpected crash!"; exit 99 | ||
588 | fi | ||
589 | echo "FAIL: Unexpected failure."; exit 1 | ||
590 | fi | ||
591 | done | ||
592 | grep "^fail_$1.*(" < $testing_dir/testing.sh | cut -d'(' -f1 | while read test | ||
593 | do | ||
594 | echo "-------------------------------------------" | ||
595 | echo "$test" | ||
596 | echo "-------------------------------------------" | ||
597 | reset_environment | ||
598 | if $test | ||
599 | then echo "FAIL: Unexpected success."; exit 1 | ||
600 | else | ||
601 | if [ $? = 99 ] | ||
602 | then echo "FAIL: Unexpected crash!"; exit 99 | ||
603 | fi | ||
604 | echo "OK: Expected failure." | ||
605 | fi | ||
606 | done | ||
607 | } | ||
608 | |||
609 | run_with_minimal_environment() { | ||
610 | echo "===========================================" | ||
611 | echo "Running with minimal environment" | ||
612 | echo "===========================================" | ||
613 | build_environment luacov | ||
614 | run_tests $1 | ||
615 | } | ||
616 | |||
617 | run_with_full_environment() { | ||
618 | echo "===========================================" | ||
619 | echo "Running with full environment" | ||
620 | echo "===========================================" | ||
621 | |||
622 | local bitop= | ||
623 | [ "$luaversion" = "5.1.5" ] && bitop=luabitop | ||
624 | |||
625 | build_environment luacov luafilesystem luasocket $bitop luaposix md5 lzlib | ||
626 | run_tests $1 | ||
627 | } | ||
628 | |||
629 | run_all_tests() { | ||
630 | run_with_minimal_environment $1 | ||
631 | run_with_full_environment $1 | ||
632 | } | ||
633 | |||
634 | run_all_tests $1 | ||
635 | #run_with_minimal_environment $1 | ||
636 | |||
637 | cd "$testing_dir/.." | ||
638 | |||
639 | if [ "$travis" ] | ||
640 | then | ||
641 | if [ "$TRAVIS" ] | ||
642 | then | ||
643 | build_environment luacov luafilesystem luacov-coveralls | ||
644 | $testing_sys_tree/bin/luacov-coveralls -c "$testing_dir/luacov.config" || echo "ok" | ||
645 | fi | ||
646 | $testing_sys_tree/bin/luacov -c "$testing_dir/luacov.config" | ||
647 | grep "Summary" -B1 -A1000 "$testing_dir/luacov.report.out" | ||
648 | else | ||
649 | $testing_sys_tree/bin/luacov -c "$testing_dir/luacov.config" | ||
650 | cat "$testing_dir/luacov.report.out" | ||
651 | fi | ||