aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2012-11-05 01:17:56 -0200
committerHisham Muhammad <hisham@gobolinux.org>2012-11-05 01:17:56 -0200
commit2b17bfc45c6e82dd42e23c79dc1cef9513f5c0cf (patch)
tree32c50fc7015c7952f63d5a018fe431a1eec6e937
parentb11037885b303cc361f32758328ee24bf0d5d765 (diff)
downloadluarocks-2.0.12.tar.gz
luarocks-2.0.12.tar.bz2
luarocks-2.0.12.zip
First commit of still-crappy version of the new test suite.v2.0.12
Consider this a prototype. I'm only checking for success or failure of most commands, and not the actual output they produce. I'm also not using a proper test suite tool, it contains hardcoded paths to my environment and the whole thing is taking 30 minutes to run on my computer. But it's better than nothing!
-rwxr-xr-xtest/testing.sh269
1 files changed, 269 insertions, 0 deletions
diff --git a/test/testing.sh b/test/testing.sh
new file mode 100755
index 00000000..c06bd278
--- /dev/null
+++ b/test/testing.sh
@@ -0,0 +1,269 @@
1#!/bin/sh -e
2
3# Setup #########################################
4
5[ -e ../configure ] || {
6 echo "Please run this from the test/ directory."
7 exit 1
8}
9
10testing_dir="$PWD"
11
12testing_tree="$testing_dir/testing"
13testing_sys_tree="$testing_dir/testing_sys"
14testing_tree_copy="$testing_dir/testing_copy"
15testing_sys_tree_copy="$testing_dir/testing_sys_copy"
16testing_cache="$testing_dir/testing_cache"
17
18[ "$1" ] || rm -f luacov.stats.out
19rm -f luacov.report.out
20rm -rf /tmp/luarocks_testing
21mkdir /tmp/luarocks_testing
22rm -rf "$testing_tree"
23rm -rf "$testing_sys_tree"
24rm -rf "$testing_tree_copy"
25rm -rf "$testing_sys_tree_copy"
26rm -rf "$testing_cache"
27
28cat <<EOF > $testing_dir/testing_config.lua
29rocks_trees = {
30 "$testing_tree",
31 "$testing_sys_tree",
32}
33local_cache = "$testing_cache"
34upload_server = "testing"
35upload_user = "hisham"
36upload_servers = {
37 testing = {
38 rsync = "localhost/tmp/luarocks_testing",
39 },
40}
41EOF
42cat <<EOF > $testing_dir/testing_config_sftp.lua
43rocks_trees = {
44 "$testing_tree",
45 "$testing_sys_tree",
46}
47local_cache = "$testing_cache"
48upload_server = "testing"
49upload_user = "hisham"
50upload_servers = {
51 testing = {
52 sftp = "localhost/tmp/luarocks_testing",
53 },
54}
55EOF
56cat <<EOF > $testing_dir/luacov.config
57return {
58 ["configfile"] = ".luacov",
59 ["statsfile"] = "$testing_dir/luacov.stats.out",
60 ["reportfile"] = "$testing_dir/luacov.report.out",
61 runreport = false,
62 deletestats = false,
63 ["include"] = {},
64 ["exclude"] = {
65 "luacov$",
66 "luacov%.reporter$",
67 "luacov%.defaults$",
68 "luacov%.runner$",
69 "luacov%.stats$",
70 "luacov%.tick$",
71 },
72}
73EOF
74
75export LUAROCKS_CONFIG="$testing_dir/testing_config.lua"
76export LUA_PATH=
77export LUA_CPATH=
78
79luadir="/Programs/Lua/Current"
80lua="$luadir/bin/lua"
81
82cd ..
83./configure --with-lua="$luadir"
84make clean
85make src/luarocks/site_config.lua
86make dev
87cd src
88
89echo $LUA_PATH
90
91luarocks_nocov="$lua $PWD/bin/luarocks"
92luarocks="$lua -erequire('luacov.runner')('$testing_dir/luacov.config') $PWD/bin/luarocks"
93luarocks_admin="$lua -erequire('luacov.runner')('$testing_dir/luacov.config') $PWD/bin/luarocks-admin"
94
95$luarocks_nocov download luacov
96
97build_environment() {
98 rm -rf "$testing_tree"
99 rm -rf "$testing_sys_tree"
100 rm -rf "$testing_tree_copy"
101 rm -rf "$testing_sys_tree_copy"
102 mkdir -p "$testing_tree"
103 mkdir -p "$testing_sys_tree"
104 for package in "$@"
105 do
106 $luarocks_nocov build --tree="$testing_sys_tree" $package
107 done
108 eval `$luarocks_nocov path --bin`
109 cp -a "$testing_tree" "$testing_tree_copy"
110 cp -a "$testing_sys_tree" "$testing_sys_tree_copy"
111}
112
113reset_environment() {
114 rm -rf "$testing_tree"
115 rm -rf "$testing_sys_tree"
116 cp -a "$testing_tree_copy" "$testing_tree"
117 cp -a "$testing_sys_tree_copy" "$testing_sys_tree"
118}
119
120# Tests #########################################
121
122test_version() { $luarocks --version; }
123
124fail_arg_server() { $luarocks --server; }
125fail_arg_only_server() { $luarocks --only-server; }
126fail_unknown_command() { $luarocks unknown_command; }
127
128test_empty_list() { $luarocks list; }
129
130fail_build_noarg() { $luarocks build; }
131fail_download_noarg() { $luarocks download; }
132fail_install_noarg() { $luarocks install; }
133fail_lint_noarg() { $luarocks lint; }
134fail_search_noarg() { $luarocks search; }
135fail_show_noarg() { $luarocks show; }
136fail_unpack_noarg() { $luarocks unpack; }
137fail_new_version_noarg() { $luarocks new_version; }
138
139fail_build_invalid() { $luarocks build invalid; }
140fail_download_invalid() { $luarocks download invalid; }
141fail_install_invalid() { $luarocks install invalid; }
142fail_lint_invalid() { $luarocks lint invalid; }
143fail_show_invalid() { $luarocks show invalid; }
144fail_new_version_invalid() { $luarocks new_version invalid; }
145
146fail_make_norockspec() { $luarocks make; }
147
148fail_build_blank_arg() { $luarocks build --tree="" lpeg; }
149test_build_withpatch() { $luarocks build luadoc; }
150test_build_diffversion() { $luarocks build luacov 0.1; }
151test_build_command() { $luarocks build stdlib; }
152test_build_install_bin() { $luarocks build luarepl; }
153fail_build_nohttps() { $luarocks install luasocket && $luarocks download --rockspec validate-args 1.5.4 && $luarocks build ./validate-args-1.5.4-1.rockspec && rm ./validate-args-1.5.4-1.rockspec; }
154test_build_https() { $luarocks download --rockspec validate-args 1.5.4 && $luarocks install luasec && $luarocks build ./validate-args-1.5.4-1.rockspec && rm ./validate-args-1.5.4-1.rockspec; }
155test_build_supported_platforms() { $luarocks build xctrl; }
156
157test_download_all() { $luarocks download --all validate-args && rm validate-args-*; }
158test_download_rockspecversion() { $luarocks download --rockspec validate-args 1.5.4 && rm validate-args-*; }
159
160test_help() { $luarocks help; }
161
162test_install_binaryrock() { $luarocks build luasocket && $luarocks pack luasocket && $luarocks install ./luasocket-2.0.2-5.linux-x86.rock && rm ./luasocket-2.0.2-5.linux-x86.rock; }
163test_install_with_bin() { $luarocks install wsapi; }
164
165test_lint_ok() { $luarocks download --rockspec validate-args 1.5.4 && $luarocks lint ./validate-args-1.5.4-1.rockspec && rm ./validate-args-1.5.4-1.rockspec; }
166
167test_list() { $luarocks list; }
168test_list_porcelain() { $luarocks list --porcelain; }
169
170test_make() { rm -rf ./luasocket-2.0.2-5 && $luarocks download --src luasocket && $luarocks unpack ./luasocket-2.0.2-5.src.rock && cd luasocket-2.0.2-5/luasocket-2.0.2 && $luarocks make && cd ../.. && rm -rf ./luasocket-2.0.2-5; }
171test_make_pack_binary_rock() { rm -rf ./lxsh-0.8.6-1 && $luarocks download --src lxsh 0.8.6-1 && $luarocks unpack ./lxsh-0.8.6-1.src.rock && cd lxsh-0.8.6-1/lxsh-0.8.6-1 && $luarocks make --deps-mode=none --pack-binary-rock && [ -e ./lxsh-0.8.6-1.all.rock ] && cd ../.. && rm -rf ./lxsh-0.8.6-1; }
172
173test_new_version() { $luarocks download --rockspec luacov 0.1 && $luarocks new_version ./luacov-0.1-1.rockspec 0.2 && rm ./luacov-0.*; }
174
175test_pack() { $luarocks list && $luarocks pack luacov && rm ./luacov-*.rock; }
176test_pack_src() { $luarocks download --rockspec luasocket && $luarocks pack ./luasocket-2.0.2-5.rockspec && rm ./luasocket-2.0.2-*.rock; }
177
178test_path() { $luarocks path --bin; }
179
180fail_purge_missing_tree() { $luarocks purge --tree="$testing_tree"; }
181test_purge() { $luarocks purge --tree="$testing_sys_tree"; }
182
183test_remove() { $luarocks build luacov 0.1 && $luarocks remove luacov 0.1; }
184#fail_remove_deps() { $luarocks build luadoc && $luarocks remove luasocket; }
185
186test_search_found() { $luarocks search zlib; }
187test_search_missing() { $luarocks search missing_rock; }
188
189test_show() { $luarocks show luacov; }
190test_show_modules() { $luarocks show --modules luacov; }
191test_show_depends() { $luarocks install luasec && $luarocks show luasec; }
192test_show_oldversion() { $luarocks install luacov 0.1 && $luarocks show luacov 0.1; }
193
194test_unpack_download() { rm -rf ./luasocket-2.0.2-5 && $luarocks unpack luasocket && rm -rf ./luasocket-2.0.2-5; }
195test_unpack_src() { rm -rf ./luasocket-2.0.2-5 && $luarocks download --src luasocket && $luarocks unpack ./luasocket-2.0.2-5.src.rock && rm -rf ./luasocket-2.0.2-5; }
196test_unpack_rockspec() { rm -rf ./luasocket-2.0.2-5 && $luarocks download --rockspec luasocket && $luarocks unpack ./luasocket-2.0.2-5.rockspec && rm -rf ./luasocket-2.0.2-5; }
197test_unpack_binary() { rm -rf ./luasocket-2.0.2-5 && $luarocks build luasocket && $luarocks pack luasocket && $luarocks unpack ./luasocket-2.0.2-5.linux-x86.rock && rm -rf ./luasocket-2.0.2-5; }
198
199test_admin_help() { $luarocks_admin help; }
200
201test_admin_make_manifest() { $luarocks_admin make_manifest; }
202test_admin_add_rsync() { $luarocks_admin --server=testing add ./luasocket-2.0.2-5.src.rock; }
203test_admin_add_sftp() { export LUAROCKS_CONFIG="$testing_dir/testing_config_sftp.lua" && $luarocks_admin --server=testing add ./luasocket-2.0.2-5.src.rock; export LUAROCKS_CONFIG="$testing_dir/testing_config.lua"; }
204fail_admin_add_missing() { $luarocks_admin --server=testing add; }
205fail_admin_invalidserver() { $luarocks_admin --server=invalid add ./luasocket-2.0.2-5.src.rock; }
206fail_admin_invalidrock() { $luarocks_admin --server=testing add invalid; }
207test_admin_refresh_cache() { $luarocks_admin --server=testing refresh_cache; }
208test_admin_remove() { $luarocks_admin --server=testing remove luasocket; }
209fail_admin_remove_missing() { $luarocks_admin --server=testing remove; }
210
211fail_deps_mode_invalid_arg() { $luarocks remove luacov --deps-mode; }
212test_deps_mode_one() { $luarocks build --tree="$testing_sys_tree" lpeg && $luarocks list && $luarocks build --deps-mode=one --tree="$testing_tree" lxsh && [ `$luarocks list --tree="$testing_tree" --porcelain lpeg | wc -l` = 1 ]; }
213test_deps_mode_order() { $luarocks build --tree="$testing_sys_tree" lpeg && $luarocks build --deps-mode=order --tree="$testing_tree" lxsh && [ `$luarocks list --tree="$testing_tree" --porcelain lpeg | wc -l` = 0 ]; }
214test_deps_mode_order_sys() { $luarocks build --tree="$testing_tree" lpeg && $luarocks build --deps-mode=order --tree="$testing_sys_tree" lxsh && [ `$luarocks list --tree="$testing_sys_tree" --porcelain lpeg | wc -l` = 1 ]; }
215test_deps_mode_all_sys() { $luarocks build --tree="$testing_tree" lpeg && $luarocks build --deps-mode=all --tree="$testing_sys_tree" lxsh && [ `$luarocks list --tree="$testing_sys_tree" --porcelain lpeg | wc -l` = 0 ]; }
216test_deps_mode_none() { $luarocks build --tree="$testing_tree" --deps-mode=none lxsh; [ `$luarocks list --tree="$testing_tree" --porcelain lpeg | wc -l` = 0 ]; }
217test_deps_mode_nodeps_alias() { $luarocks build --tree="$testing_tree" --nodeps lxsh; [ `$luarocks list --tree="$testing_tree" --porcelain lpeg | wc -l` = 0 ]; }
218test_deps_mode_make_order() { $luarocks build --tree="$testing_sys_tree" lpeg && rm -rf ./lxsh-0.8.6-1 && $luarocks download --src lxsh 0.8.6-1 && $luarocks unpack ./lxsh-0.8.6-1.src.rock && cd lxsh-0.8.6-1/lxsh-0.8.6-1 && $luarocks make --tree="$testing_tree" --deps-mode=order && cd ../.. && [ `$luarocks list --tree="$testing_tree" --porcelain lpeg | wc -l` = 0 ] && rm -rf ./lxsh-0.8.6-1; }
219test_deps_mode_make_order_sys() { $luarocks build --tree="$testing_tree" lpeg && rm -rf ./lxsh-0.8.6-1 && $luarocks download --src lxsh 0.8.6-1 && $luarocks unpack ./lxsh-0.8.6-1.src.rock && cd lxsh-0.8.6-1/lxsh-0.8.6-1 && $luarocks make --tree="$testing_sys_tree" --deps-mode=order && cd ../.. && [ `$luarocks list --tree="$testing_tree" --porcelain lpeg | wc -l` = 1 ] && rm -rf ./lxsh-0.8.6-1; }
220
221# Driver #########################################
222
223run_tests() {
224 grep "^test_$1.*(" < $testing_dir/testing.sh | cut -d'(' -f1 | while read test
225 do
226 echo "-------------------------------------------"
227 echo "$test"
228 echo "-------------------------------------------"
229 reset_environment
230 if $test
231 then echo "OK: Expected success."
232 else echo "FAIL: Unexpected failure."; exit 1
233 fi
234 done
235
236 grep "^fail_$1.*(" < $testing_dir/testing.sh | cut -d'(' -f1 | while read test
237 do
238 echo "-------------------------------------------"
239 echo "$test"
240 echo "-------------------------------------------"
241 reset_environment
242 if $test
243 then echo "FAIL: Unexpected success."; exit 1
244 else echo "OK: Expected failure."
245 fi
246 done
247}
248
249run_with_minimal_environment() {
250 build_environment luacov
251 run_tests $1
252}
253
254run_with_full_environment() {
255 build_environment luacov luafilesystem luasocket luabitop luaposix md5 lzlib
256 run_tests $1
257}
258
259run_all_tests() {
260 run_with_minimal_environment $1
261 run_with_full_environment $1
262}
263
264run_all_tests $1
265#run_with_minimal_environment $1
266
267$testing_sys_tree/bin/luacov -c $testing_dir/luacov.config src/luarocks src/bin
268
269cat $testing_dir/luacov.report.out