diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2012-11-05 01:17:56 -0200 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2012-11-05 01:17:56 -0200 |
commit | 2b17bfc45c6e82dd42e23c79dc1cef9513f5c0cf (patch) | |
tree | 32c50fc7015c7952f63d5a018fe431a1eec6e937 | |
parent | b11037885b303cc361f32758328ee24bf0d5d765 (diff) | |
download | luarocks-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-x | test/testing.sh | 269 |
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 | |||
10 | testing_dir="$PWD" | ||
11 | |||
12 | testing_tree="$testing_dir/testing" | ||
13 | testing_sys_tree="$testing_dir/testing_sys" | ||
14 | testing_tree_copy="$testing_dir/testing_copy" | ||
15 | testing_sys_tree_copy="$testing_dir/testing_sys_copy" | ||
16 | testing_cache="$testing_dir/testing_cache" | ||
17 | |||
18 | [ "$1" ] || rm -f luacov.stats.out | ||
19 | rm -f luacov.report.out | ||
20 | rm -rf /tmp/luarocks_testing | ||
21 | mkdir /tmp/luarocks_testing | ||
22 | rm -rf "$testing_tree" | ||
23 | rm -rf "$testing_sys_tree" | ||
24 | rm -rf "$testing_tree_copy" | ||
25 | rm -rf "$testing_sys_tree_copy" | ||
26 | rm -rf "$testing_cache" | ||
27 | |||
28 | cat <<EOF > $testing_dir/testing_config.lua | ||
29 | rocks_trees = { | ||
30 | "$testing_tree", | ||
31 | "$testing_sys_tree", | ||
32 | } | ||
33 | local_cache = "$testing_cache" | ||
34 | upload_server = "testing" | ||
35 | upload_user = "hisham" | ||
36 | upload_servers = { | ||
37 | testing = { | ||
38 | rsync = "localhost/tmp/luarocks_testing", | ||
39 | }, | ||
40 | } | ||
41 | EOF | ||
42 | cat <<EOF > $testing_dir/testing_config_sftp.lua | ||
43 | rocks_trees = { | ||
44 | "$testing_tree", | ||
45 | "$testing_sys_tree", | ||
46 | } | ||
47 | local_cache = "$testing_cache" | ||
48 | upload_server = "testing" | ||
49 | upload_user = "hisham" | ||
50 | upload_servers = { | ||
51 | testing = { | ||
52 | sftp = "localhost/tmp/luarocks_testing", | ||
53 | }, | ||
54 | } | ||
55 | EOF | ||
56 | cat <<EOF > $testing_dir/luacov.config | ||
57 | return { | ||
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 | } | ||
73 | EOF | ||
74 | |||
75 | export LUAROCKS_CONFIG="$testing_dir/testing_config.lua" | ||
76 | export LUA_PATH= | ||
77 | export LUA_CPATH= | ||
78 | |||
79 | luadir="/Programs/Lua/Current" | ||
80 | lua="$luadir/bin/lua" | ||
81 | |||
82 | cd .. | ||
83 | ./configure --with-lua="$luadir" | ||
84 | make clean | ||
85 | make src/luarocks/site_config.lua | ||
86 | make dev | ||
87 | cd src | ||
88 | |||
89 | echo $LUA_PATH | ||
90 | |||
91 | luarocks_nocov="$lua $PWD/bin/luarocks" | ||
92 | luarocks="$lua -erequire('luacov.runner')('$testing_dir/luacov.config') $PWD/bin/luarocks" | ||
93 | luarocks_admin="$lua -erequire('luacov.runner')('$testing_dir/luacov.config') $PWD/bin/luarocks-admin" | ||
94 | |||
95 | $luarocks_nocov download luacov | ||
96 | |||
97 | build_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 | |||
113 | reset_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 | |||
122 | test_version() { $luarocks --version; } | ||
123 | |||
124 | fail_arg_server() { $luarocks --server; } | ||
125 | fail_arg_only_server() { $luarocks --only-server; } | ||
126 | fail_unknown_command() { $luarocks unknown_command; } | ||
127 | |||
128 | test_empty_list() { $luarocks list; } | ||
129 | |||
130 | fail_build_noarg() { $luarocks build; } | ||
131 | fail_download_noarg() { $luarocks download; } | ||
132 | fail_install_noarg() { $luarocks install; } | ||
133 | fail_lint_noarg() { $luarocks lint; } | ||
134 | fail_search_noarg() { $luarocks search; } | ||
135 | fail_show_noarg() { $luarocks show; } | ||
136 | fail_unpack_noarg() { $luarocks unpack; } | ||
137 | fail_new_version_noarg() { $luarocks new_version; } | ||
138 | |||
139 | fail_build_invalid() { $luarocks build invalid; } | ||
140 | fail_download_invalid() { $luarocks download invalid; } | ||
141 | fail_install_invalid() { $luarocks install invalid; } | ||
142 | fail_lint_invalid() { $luarocks lint invalid; } | ||
143 | fail_show_invalid() { $luarocks show invalid; } | ||
144 | fail_new_version_invalid() { $luarocks new_version invalid; } | ||
145 | |||
146 | fail_make_norockspec() { $luarocks make; } | ||
147 | |||
148 | fail_build_blank_arg() { $luarocks build --tree="" lpeg; } | ||
149 | test_build_withpatch() { $luarocks build luadoc; } | ||
150 | test_build_diffversion() { $luarocks build luacov 0.1; } | ||
151 | test_build_command() { $luarocks build stdlib; } | ||
152 | test_build_install_bin() { $luarocks build luarepl; } | ||
153 | fail_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; } | ||
154 | test_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; } | ||
155 | test_build_supported_platforms() { $luarocks build xctrl; } | ||
156 | |||
157 | test_download_all() { $luarocks download --all validate-args && rm validate-args-*; } | ||
158 | test_download_rockspecversion() { $luarocks download --rockspec validate-args 1.5.4 && rm validate-args-*; } | ||
159 | |||
160 | test_help() { $luarocks help; } | ||
161 | |||
162 | test_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; } | ||
163 | test_install_with_bin() { $luarocks install wsapi; } | ||
164 | |||
165 | test_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 | |||
167 | test_list() { $luarocks list; } | ||
168 | test_list_porcelain() { $luarocks list --porcelain; } | ||
169 | |||
170 | test_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; } | ||
171 | test_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 | |||
173 | test_new_version() { $luarocks download --rockspec luacov 0.1 && $luarocks new_version ./luacov-0.1-1.rockspec 0.2 && rm ./luacov-0.*; } | ||
174 | |||
175 | test_pack() { $luarocks list && $luarocks pack luacov && rm ./luacov-*.rock; } | ||
176 | test_pack_src() { $luarocks download --rockspec luasocket && $luarocks pack ./luasocket-2.0.2-5.rockspec && rm ./luasocket-2.0.2-*.rock; } | ||
177 | |||
178 | test_path() { $luarocks path --bin; } | ||
179 | |||
180 | fail_purge_missing_tree() { $luarocks purge --tree="$testing_tree"; } | ||
181 | test_purge() { $luarocks purge --tree="$testing_sys_tree"; } | ||
182 | |||
183 | test_remove() { $luarocks build luacov 0.1 && $luarocks remove luacov 0.1; } | ||
184 | #fail_remove_deps() { $luarocks build luadoc && $luarocks remove luasocket; } | ||
185 | |||
186 | test_search_found() { $luarocks search zlib; } | ||
187 | test_search_missing() { $luarocks search missing_rock; } | ||
188 | |||
189 | test_show() { $luarocks show luacov; } | ||
190 | test_show_modules() { $luarocks show --modules luacov; } | ||
191 | test_show_depends() { $luarocks install luasec && $luarocks show luasec; } | ||
192 | test_show_oldversion() { $luarocks install luacov 0.1 && $luarocks show luacov 0.1; } | ||
193 | |||
194 | test_unpack_download() { rm -rf ./luasocket-2.0.2-5 && $luarocks unpack luasocket && rm -rf ./luasocket-2.0.2-5; } | ||
195 | test_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; } | ||
196 | test_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; } | ||
197 | test_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 | |||
199 | test_admin_help() { $luarocks_admin help; } | ||
200 | |||
201 | test_admin_make_manifest() { $luarocks_admin make_manifest; } | ||
202 | test_admin_add_rsync() { $luarocks_admin --server=testing add ./luasocket-2.0.2-5.src.rock; } | ||
203 | test_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"; } | ||
204 | fail_admin_add_missing() { $luarocks_admin --server=testing add; } | ||
205 | fail_admin_invalidserver() { $luarocks_admin --server=invalid add ./luasocket-2.0.2-5.src.rock; } | ||
206 | fail_admin_invalidrock() { $luarocks_admin --server=testing add invalid; } | ||
207 | test_admin_refresh_cache() { $luarocks_admin --server=testing refresh_cache; } | ||
208 | test_admin_remove() { $luarocks_admin --server=testing remove luasocket; } | ||
209 | fail_admin_remove_missing() { $luarocks_admin --server=testing remove; } | ||
210 | |||
211 | fail_deps_mode_invalid_arg() { $luarocks remove luacov --deps-mode; } | ||
212 | test_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 ]; } | ||
213 | test_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 ]; } | ||
214 | test_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 ]; } | ||
215 | test_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 ]; } | ||
216 | test_deps_mode_none() { $luarocks build --tree="$testing_tree" --deps-mode=none lxsh; [ `$luarocks list --tree="$testing_tree" --porcelain lpeg | wc -l` = 0 ]; } | ||
217 | test_deps_mode_nodeps_alias() { $luarocks build --tree="$testing_tree" --nodeps lxsh; [ `$luarocks list --tree="$testing_tree" --porcelain lpeg | wc -l` = 0 ]; } | ||
218 | test_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; } | ||
219 | test_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 | |||
223 | run_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 | |||
249 | run_with_minimal_environment() { | ||
250 | build_environment luacov | ||
251 | run_tests $1 | ||
252 | } | ||
253 | |||
254 | run_with_full_environment() { | ||
255 | build_environment luacov luafilesystem luasocket luabitop luaposix md5 lzlib | ||
256 | run_tests $1 | ||
257 | } | ||
258 | |||
259 | run_all_tests() { | ||
260 | run_with_minimal_environment $1 | ||
261 | run_with_full_environment $1 | ||
262 | } | ||
263 | |||
264 | run_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 | |||
269 | cat $testing_dir/luacov.report.out | ||