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