diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2024-02-29 00:46:06 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2024-02-29 15:46:16 +0000 |
commit | f76b7a2b13e411df2e696146bb0a6396781acd92 (patch) | |
tree | 38ed32f81f05f6eacd03f36eacd5341e7b1d17dd /spec/quick | |
parent | 0ca8c460e867356342180bb625760ed9201a5503 (diff) | |
download | luarocks-f76b7a2b13e411df2e696146bb0a6396781acd92.tar.gz luarocks-f76b7a2b13e411df2e696146bb0a6396781acd92.tar.bz2 luarocks-f76b7a2b13e411df2e696146bb0a6396781acd92.zip |
tests: speed up and simplify
Diffstat (limited to 'spec/quick')
-rw-r--r-- | spec/quick/admin_make_manifest.q | 46 | ||||
-rw-r--r-- | spec/quick/build.q | 103 | ||||
-rw-r--r-- | spec/quick/doc.q | 13 | ||||
-rw-r--r-- | spec/quick/install.q | 60 | ||||
-rw-r--r-- | spec/quick/list.q | 37 | ||||
-rw-r--r-- | spec/quick/make.q | 51 | ||||
-rw-r--r-- | spec/quick/purge.q | 103 |
7 files changed, 407 insertions, 6 deletions
diff --git a/spec/quick/admin_make_manifest.q b/spec/quick/admin_make_manifest.q new file mode 100644 index 00000000..da203a05 --- /dev/null +++ b/spec/quick/admin_make_manifest.q | |||
@@ -0,0 +1,46 @@ | |||
1 | SUITE: luarocks-admin make_manifest | ||
2 | |||
3 | ================================================================================ | ||
4 | TEST: runs | ||
5 | |||
6 | FILE: test-1.0-1.rockspec | ||
7 | -------------------------------------------------------------------------------- | ||
8 | package = "test" | ||
9 | version = "1.0-1" | ||
10 | source = { | ||
11 | url = "file://%{url(tmpdir)}/test.lua" | ||
12 | } | ||
13 | build = { | ||
14 | type = "builtin", | ||
15 | modules = { | ||
16 | test = "test.lua" | ||
17 | } | ||
18 | } | ||
19 | -------------------------------------------------------------------------------- | ||
20 | |||
21 | FILE: test.lua | ||
22 | -------------------------------------------------------------------------------- | ||
23 | return {} | ||
24 | -------------------------------------------------------------------------------- | ||
25 | |||
26 | RUN: luarocks make --pack-binary-rock ./test-1.0-1.rockspec | ||
27 | |||
28 | RUN: luarocks-admin make_manifest . | ||
29 | |||
30 | FILE_CONTENTS: ./manifest-%{lua_version} | ||
31 | -------------------------------------------------------------------------------- | ||
32 | commands = {} | ||
33 | modules = {} | ||
34 | repository = { | ||
35 | test = { | ||
36 | ["1.0-1"] = { | ||
37 | { | ||
38 | arch = "all" | ||
39 | }, | ||
40 | { | ||
41 | arch = "rockspec" | ||
42 | } | ||
43 | } | ||
44 | } | ||
45 | } | ||
46 | -------------------------------------------------------------------------------- | ||
diff --git a/spec/quick/build.q b/spec/quick/build.q index a1731da2..ee519adf 100644 --- a/spec/quick/build.q +++ b/spec/quick/build.q | |||
@@ -1,4 +1,7 @@ | |||
1 | TEST: luarocks build: fails when given invalid argument | 1 | SUITE: luarocks build |
2 | |||
3 | ================================================================================ | ||
4 | TEST: fails when given invalid argument | ||
2 | RUN: luarocks build aoesuthaoeusahtoeustnaou --only-server=localhost | 5 | RUN: luarocks build aoesuthaoeusahtoeustnaou --only-server=localhost |
3 | EXIT: 1 | 6 | EXIT: 1 |
4 | STDERR: | 7 | STDERR: |
@@ -9,7 +12,7 @@ Could not find a result named aoesuthaoeusahtoeustnaou | |||
9 | 12 | ||
10 | 13 | ||
11 | ================================================================================ | 14 | ================================================================================ |
12 | TEST: luarocks build: with no arguments behaves as luarocks make | 15 | TEST: with no arguments behaves as luarocks make |
13 | 16 | ||
14 | FILE: c_module-1.0-1.rockspec | 17 | FILE: c_module-1.0-1.rockspec |
15 | -------------------------------------------------------------------------------- | 18 | -------------------------------------------------------------------------------- |
@@ -43,7 +46,7 @@ EXISTS: c_module.%{lib_extension} | |||
43 | 46 | ||
44 | 47 | ||
45 | ================================================================================ | 48 | ================================================================================ |
46 | TEST: luarocks build: defaults to builtin type | 49 | TEST: defaults to builtin type |
47 | 50 | ||
48 | FILE: a_rock-1.0-1.rockspec | 51 | FILE: a_rock-1.0-1.rockspec |
49 | -------------------------------------------------------------------------------- | 52 | -------------------------------------------------------------------------------- |
@@ -74,7 +77,7 @@ a_rock 1.0 | |||
74 | 77 | ||
75 | 78 | ||
76 | ================================================================================ | 79 | ================================================================================ |
77 | TEST: luarocks build: fails if no permissions to access the specified tree #unix | 80 | TEST: fails if no permissions to access the specified tree #unix |
78 | 81 | ||
79 | RUN: luarocks build --tree=/usr ./a_rock-1.0.1-rockspec | 82 | RUN: luarocks build --tree=/usr ./a_rock-1.0.1-rockspec |
80 | EXIT: 4 | 83 | EXIT: 4 |
@@ -99,7 +102,7 @@ NOT_EXISTS: %{testing_sys_rocks}/a_rock/1.0-1/a_rock-1.0-1.rockspec | |||
99 | 102 | ||
100 | 103 | ||
101 | ================================================================================ | 104 | ================================================================================ |
102 | TEST: luarocks build: fails if no permissions to access the parent #unix | 105 | TEST: fails if no permissions to access the parent #unix |
103 | 106 | ||
104 | RUN: luarocks build --tree=/usr/invalid ./a_rock-1.0.1-rockspec | 107 | RUN: luarocks build --tree=/usr/invalid ./a_rock-1.0.1-rockspec |
105 | EXIT: 4 | 108 | EXIT: 4 |
@@ -160,3 +163,93 @@ STDOUT: | |||
160 | a_rock 1.0-1 is already installed | 163 | a_rock 1.0-1 is already installed |
161 | Use --force to reinstall | 164 | Use --force to reinstall |
162 | -------------------------------------------------------------------------------- | 165 | -------------------------------------------------------------------------------- |
166 | |||
167 | |||
168 | |||
169 | ================================================================================ | ||
170 | TEST: supports --pin #pinning | ||
171 | |||
172 | FILE: test-1.0-1.rockspec | ||
173 | -------------------------------------------------------------------------------- | ||
174 | package = "test" | ||
175 | version = "1.0-1" | ||
176 | source = { | ||
177 | url = "file://%{url(tmpdir)}/test.lua" | ||
178 | } | ||
179 | dependencies = { | ||
180 | "a_rock >= 0.8" | ||
181 | } | ||
182 | build = { | ||
183 | type = "builtin", | ||
184 | modules = { | ||
185 | test = "test.lua" | ||
186 | } | ||
187 | } | ||
188 | -------------------------------------------------------------------------------- | ||
189 | |||
190 | FILE: test.lua | ||
191 | -------------------------------------------------------------------------------- | ||
192 | return {} | ||
193 | -------------------------------------------------------------------------------- | ||
194 | |||
195 | RUN: luarocks build --only-server=%{fixtures_dir}/a_repo test-1.0-1.rockspec --pin --tree=lua_modules | ||
196 | |||
197 | EXISTS: ./lua_modules/lib/luarocks/rocks-%{lua_version}/test/1.0-1/test-1.0-1.rockspec | ||
198 | EXISTS: ./lua_modules/lib/luarocks/rocks-%{lua_version}/a_rock/2.0-1/a_rock-2.0-1.rockspec | ||
199 | |||
200 | EXISTS: ./lua_modules/lib/luarocks/rocks-%{lua_version}/test/1.0-1/luarocks.lock | ||
201 | |||
202 | FILE_CONTENTS: ./lua_modules/lib/luarocks/rocks-%{lua_version}/test/1.0-1/luarocks.lock | ||
203 | -------------------------------------------------------------------------------- | ||
204 | return { | ||
205 | dependencies = { | ||
206 | a_rock = "2.0-1", | ||
207 | lua = "%{lua_version}-1" | ||
208 | } | ||
209 | } | ||
210 | -------------------------------------------------------------------------------- | ||
211 | |||
212 | |||
213 | |||
214 | ================================================================================ | ||
215 | TEST: supports --pin --only-deps #pinning | ||
216 | |||
217 | FILE: test-1.0-1.rockspec | ||
218 | -------------------------------------------------------------------------------- | ||
219 | package = "test" | ||
220 | version = "1.0-1" | ||
221 | source = { | ||
222 | url = "file://%{url(tmpdir)}/test.lua" | ||
223 | } | ||
224 | dependencies = { | ||
225 | "a_rock >= 0.8" | ||
226 | } | ||
227 | build = { | ||
228 | type = "builtin", | ||
229 | modules = { | ||
230 | test = "test.lua" | ||
231 | } | ||
232 | } | ||
233 | -------------------------------------------------------------------------------- | ||
234 | |||
235 | FILE: test.lua | ||
236 | -------------------------------------------------------------------------------- | ||
237 | return {} | ||
238 | -------------------------------------------------------------------------------- | ||
239 | |||
240 | RUN: luarocks build --only-server=%{fixtures_dir}/a_repo test-1.0-1.rockspec --pin --only-deps --tree=lua_modules | ||
241 | |||
242 | NOT_EXISTS: ./lua_modules/lib/luarocks/rocks-%{lua_version}/test/1.0-1/test-1.0-1.rockspec | ||
243 | EXISTS: ./lua_modules/lib/luarocks/rocks-%{lua_version}/a_rock/2.0-1/a_rock-2.0-1.rockspec | ||
244 | |||
245 | EXISTS: ./luarocks.lock | ||
246 | |||
247 | FILE_CONTENTS: ./luarocks.lock | ||
248 | -------------------------------------------------------------------------------- | ||
249 | return { | ||
250 | dependencies = { | ||
251 | a_rock = "2.0-1", | ||
252 | lua = "%{lua_version}-1" | ||
253 | } | ||
254 | } | ||
255 | -------------------------------------------------------------------------------- | ||
diff --git a/spec/quick/doc.q b/spec/quick/doc.q new file mode 100644 index 00000000..4c71f838 --- /dev/null +++ b/spec/quick/doc.q | |||
@@ -0,0 +1,13 @@ | |||
1 | SUITE: luarocks doc | ||
2 | |||
3 | ================================================================================ | ||
4 | TEST: --local | ||
5 | |||
6 | RUN: luarocks install --local --only-server=%{fixtures_dir}/a_repo a_rock | ||
7 | |||
8 | RUN: luarocks doc a_rock --local | ||
9 | |||
10 | STDOUT: | ||
11 | -------------------------------------------------------------------------------- | ||
12 | opening http://www.example.com | ||
13 | -------------------------------------------------------------------------------- | ||
diff --git a/spec/quick/install.q b/spec/quick/install.q index 503aaacc..72795504 100644 --- a/spec/quick/install.q +++ b/spec/quick/install.q | |||
@@ -415,3 +415,63 @@ STDOUT: | |||
415 | myrock 1.0-1 is already installed | 415 | myrock 1.0-1 is already installed |
416 | Use --force to reinstall | 416 | Use --force to reinstall |
417 | -------------------------------------------------------------------------------- | 417 | -------------------------------------------------------------------------------- |
418 | |||
419 | |||
420 | |||
421 | ================================================================================ | ||
422 | TEST: installation rolls back on failure | ||
423 | |||
424 | FILE: myrock-1.0-1.rockspec | ||
425 | -------------------------------------------------------------------------------- | ||
426 | rockspec_format = "3.0" | ||
427 | package = "myrock" | ||
428 | version = "1.0-1" | ||
429 | source = { | ||
430 | url = "file://%{url(tmpdir)}/rock.lua" | ||
431 | } | ||
432 | build = { | ||
433 | modules = { | ||
434 | ["folder.rock"] = "rock.lua", | ||
435 | ["xyz"] = "xyz.lua", | ||
436 | }, | ||
437 | } | ||
438 | -------------------------------------------------------------------------------- | ||
439 | |||
440 | FILE: rock.lua | ||
441 | -------------------------------------------------------------------------------- | ||
442 | return {} | ||
443 | -------------------------------------------------------------------------------- | ||
444 | |||
445 | FILE: xyz.lua | ||
446 | -------------------------------------------------------------------------------- | ||
447 | return {} | ||
448 | -------------------------------------------------------------------------------- | ||
449 | |||
450 | RUN: luarocks make --pack-binary-rock ./myrock-1.0-1.rockspec | ||
451 | |||
452 | FILE: %{testing_sys_tree}/share/lua/%{lua_version}/folder | ||
453 | -------------------------------------------------------------------------------- | ||
454 | a file where a folder should be | ||
455 | -------------------------------------------------------------------------------- | ||
456 | |||
457 | Try to install and fail because the file is in the folder's spot: | ||
458 | |||
459 | RUN: luarocks install ./myrock-1.0-1.all.rock | ||
460 | EXIT: 1 | ||
461 | |||
462 | EXISTS: %{testing_sys_tree}/share/lua/%{lua_version}/folder | ||
463 | |||
464 | No leftovers from the failed installation: | ||
465 | |||
466 | NOT_EXISTS: %{testing_sys_tree}/share/lua/%{lua_version}/xyz.lua | ||
467 | |||
468 | Now we remove the file... | ||
469 | |||
470 | RM: %{testing_sys_tree}/share/lua/%{lua_version}/folder | ||
471 | |||
472 | Try again and succeed: | ||
473 | |||
474 | RUN: luarocks install ./myrock-1.0-1.all.rock | ||
475 | |||
476 | EXISTS: %{testing_sys_tree}/share/lua/%{lua_version}/folder/rock.lua | ||
477 | EXISTS: %{testing_sys_tree}/share/lua/%{lua_version}/xyz.lua | ||
diff --git a/spec/quick/list.q b/spec/quick/list.q index fbb3f557..a40f37ef 100644 --- a/spec/quick/list.q +++ b/spec/quick/list.q | |||
@@ -1,5 +1,7 @@ | |||
1 | SUITE: luarocks list | ||
2 | |||
1 | ================================================================================ | 3 | ================================================================================ |
2 | TEST: luarocks list: invalid tree | 4 | TEST: invalid tree |
3 | 5 | ||
4 | RUN: luarocks --tree=%{path(/some/invalid/tree)} list | 6 | RUN: luarocks --tree=%{path(/some/invalid/tree)} list |
5 | 7 | ||
@@ -8,3 +10,36 @@ STDOUT: | |||
8 | Rocks installed for Lua %{lua_version} in %{path(/some/invalid/tree)} | 10 | Rocks installed for Lua %{lua_version} in %{path(/some/invalid/tree)} |
9 | -------------------------------------------------------------------------------- | 11 | -------------------------------------------------------------------------------- |
10 | 12 | ||
13 | |||
14 | |||
15 | ================================================================================ | ||
16 | TEST: --porcelain | ||
17 | |||
18 | FILE: a_rock-1.0-1.rockspec | ||
19 | -------------------------------------------------------------------------------- | ||
20 | rockspec_format = "3.0" | ||
21 | package = "a_rock" | ||
22 | version = "1.0-1" | ||
23 | source = { | ||
24 | url = "file://%{url(%{fixtures_dir})}/a_rock.lua" | ||
25 | } | ||
26 | description = { | ||
27 | summary = "An example rockspec", | ||
28 | } | ||
29 | dependencies = { | ||
30 | "lua >= 5.1" | ||
31 | } | ||
32 | build = { | ||
33 | modules = { | ||
34 | build = "a_rock.lua" | ||
35 | }, | ||
36 | } | ||
37 | -------------------------------------------------------------------------------- | ||
38 | RUN: luarocks build a_rock-1.0-1.rockspec | ||
39 | |||
40 | RUN: luarocks list --porcelain | ||
41 | |||
42 | STDOUT: | ||
43 | -------------------------------------------------------------------------------- | ||
44 | a_rock 1.0-1 installed %{testing_sys_rocks} | ||
45 | -------------------------------------------------------------------------------- | ||
diff --git a/spec/quick/make.q b/spec/quick/make.q new file mode 100644 index 00000000..c77bb499 --- /dev/null +++ b/spec/quick/make.q | |||
@@ -0,0 +1,51 @@ | |||
1 | SUITE: luarocks make | ||
2 | |||
3 | ================================================================================ | ||
4 | TEST: overrides luarocks.lock with --pin #pinning | ||
5 | |||
6 | FILE: test-2.0-1.rockspec | ||
7 | -------------------------------------------------------------------------------- | ||
8 | package = "test" | ||
9 | version = "2.0-1" | ||
10 | source = { | ||
11 | url = "file://%{path(tmpdir)}/test.lua" | ||
12 | } | ||
13 | dependencies = { | ||
14 | "a_rock >= 0.8" | ||
15 | } | ||
16 | build = { | ||
17 | type = "builtin", | ||
18 | modules = { | ||
19 | test = "test.lua" | ||
20 | } | ||
21 | } | ||
22 | -------------------------------------------------------------------------------- | ||
23 | |||
24 | FILE: test.lua | ||
25 | -------------------------------------------------------------------------------- | ||
26 | return {} | ||
27 | -------------------------------------------------------------------------------- | ||
28 | |||
29 | FILE: luarocks.lock | ||
30 | -------------------------------------------------------------------------------- | ||
31 | return { | ||
32 | dependencies = { | ||
33 | ["a_rock"] = "1.0-1", | ||
34 | } | ||
35 | } | ||
36 | -------------------------------------------------------------------------------- | ||
37 | |||
38 | RUN: luarocks make --only-server=%{fixtures_dir}/a_repo --pin --tree=lua_modules | ||
39 | |||
40 | EXISTS: ./lua_modules/lib/luarocks/rocks-%{lua_version}/test/2.0-1/test-2.0-1.rockspec | ||
41 | EXISTS: ./lua_modules/lib/luarocks/rocks-%{lua_version}/a_rock/2.0-1/a_rock-2.0-1.rockspec | ||
42 | |||
43 | FILE_CONTENTS: ./lua_modules/lib/luarocks/rocks-%{lua_version}/test/2.0-1/luarocks.lock | ||
44 | -------------------------------------------------------------------------------- | ||
45 | return { | ||
46 | dependencies = { | ||
47 | a_rock = "2.0-1", | ||
48 | lua = "%{lua_version}-1" | ||
49 | } | ||
50 | } | ||
51 | -------------------------------------------------------------------------------- | ||
diff --git a/spec/quick/purge.q b/spec/quick/purge.q new file mode 100644 index 00000000..a3f24b99 --- /dev/null +++ b/spec/quick/purge.q | |||
@@ -0,0 +1,103 @@ | |||
1 | SUITE: luarocks purge | ||
2 | |||
3 | ================================================================================ | ||
4 | TEST: needs a --tree argument | ||
5 | RUN: luarocks purge | ||
6 | EXIT: 1 | ||
7 | |||
8 | ================================================================================ | ||
9 | TEST: missing tree | ||
10 | RUN: luarocks purge --tree=missing-tree | ||
11 | EXIT: 1 | ||
12 | |||
13 | ================================================================================ | ||
14 | TEST: missing --tree argument | ||
15 | RUN: luarocks purge --tree= | ||
16 | EXIT: 1 | ||
17 | |||
18 | |||
19 | ================================================================================ | ||
20 | TEST: runs | ||
21 | |||
22 | FILE: testrock-1.0-1.rockspec | ||
23 | -------------------------------------------------------------------------------- | ||
24 | package = "testrock" | ||
25 | version = "1.0-1" | ||
26 | source = { | ||
27 | url = "file://%{url(tmpdir)}/testrock.lua" | ||
28 | } | ||
29 | dependencies = { | ||
30 | "a_rock >= 0.8" | ||
31 | } | ||
32 | build = { | ||
33 | type = "builtin", | ||
34 | modules = { | ||
35 | testrock = "testrock.lua" | ||
36 | } | ||
37 | } | ||
38 | -------------------------------------------------------------------------------- | ||
39 | |||
40 | FILE: testrock.lua | ||
41 | -------------------------------------------------------------------------------- | ||
42 | return {} | ||
43 | -------------------------------------------------------------------------------- | ||
44 | |||
45 | RUN: luarocks build --only-server=%{fixtures_dir}/a_repo testrock-1.0-1.rockspec | ||
46 | |||
47 | EXISTS: %{testing_sys_rocks}/testrock | ||
48 | EXISTS: %{testing_sys_rocks}/a_rock | ||
49 | |||
50 | RUN: luarocks purge --tree=%{testing_sys_tree} | ||
51 | |||
52 | NOT_EXISTS: %{testing_sys_rocks}/testrock | ||
53 | NOT_EXISTS: %{testing_sys_rocks}/a_rock | ||
54 | |||
55 | |||
56 | |||
57 | ================================================================================ | ||
58 | TEST: works with missing files | ||
59 | |||
60 | FILE: testrock-1.0-1.rockspec | ||
61 | -------------------------------------------------------------------------------- | ||
62 | package = "testrock" | ||
63 | version = "1.0-1" | ||
64 | source = { | ||
65 | url = "file://%{url(tmpdir)}/testrock.lua" | ||
66 | } | ||
67 | dependencies = { | ||
68 | "a_rock >= 0.8" | ||
69 | } | ||
70 | build = { | ||
71 | type = "builtin", | ||
72 | modules = { | ||
73 | testrock = "testrock.lua" | ||
74 | } | ||
75 | } | ||
76 | -------------------------------------------------------------------------------- | ||
77 | |||
78 | FILE: testrock.lua | ||
79 | -------------------------------------------------------------------------------- | ||
80 | return {} | ||
81 | -------------------------------------------------------------------------------- | ||
82 | |||
83 | RUN: luarocks build --only-server=%{fixtures_dir}/a_repo testrock-1.0-1.rockspec | ||
84 | |||
85 | RMDIR: %{testing_sys_tree}/share/lua/%{lua_version}/testrock | ||
86 | |||
87 | RUN: luarocks purge --tree=%{testing_sys_tree} | ||
88 | |||
89 | NOT_EXISTS: %{testing_sys_rocks}/testrock | ||
90 | NOT_EXISTS: %{testing_sys_rocks}/a_rock | ||
91 | |||
92 | |||
93 | |||
94 | ================================================================================ | ||
95 | TEST: --old-versions | ||
96 | |||
97 | RUN: luarocks install --only-server=%{fixtures_dir}/a_repo a_rock 2.0 | ||
98 | RUN: luarocks install --only-server=%{fixtures_dir}/a_repo a_rock 1.0 --keep | ||
99 | |||
100 | RUN: luarocks purge --old-versions --tree=%{testing_sys_tree} | ||
101 | |||
102 | EXISTS: %{testing_sys_rocks}/a_rock/2.0-1 | ||
103 | NOT_EXISTS: %{testing_sys_rocks}/a_rock/1.0-1 | ||