aboutsummaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2024-03-13 15:32:35 -0300
committerHisham Muhammad <hisham@gobolinux.org>2024-03-13 19:08:05 +0000
commit4117ad5045b310a7902edb6a78c1c1386ddeaea0 (patch)
treee96d515f1d2646817bad41307770c1f56f3066db /spec
parent1829ba36d0764c3210766bd0bc878695282114aa (diff)
downloadluarocks-4117ad5045b310a7902edb6a78c1c1386ddeaea0.tar.gz
luarocks-4117ad5045b310a7902edb6a78c1c1386ddeaea0.tar.bz2
luarocks-4117ad5045b310a7902edb6a78c1c1386ddeaea0.zip
tests: convert most pack tests
Diffstat (limited to 'spec')
-rw-r--r--spec/pack_spec.lua67
-rw-r--r--spec/quick/pack.q128
-rw-r--r--spec/quick_spec.lua4
-rw-r--r--spec/util/quick.lua2
4 files changed, 135 insertions, 66 deletions
diff --git a/spec/pack_spec.lua b/spec/pack_spec.lua
index 20a2b3ef..2a2fb3a5 100644
--- a/spec/pack_spec.lua
+++ b/spec/pack_spec.lua
@@ -4,60 +4,10 @@ local run = test_env.run
4local testing_paths = test_env.testing_paths 4local testing_paths = test_env.testing_paths
5local write_file = test_env.write_file 5local write_file = test_env.write_file
6 6
7local extra_rocks = {
8 "/luassert-1.7.0-1.src.rock",
9 "/luasocket-${LUASOCKET}.src.rock",
10 "/luasocket-${LUASOCKET}.rockspec",
11 "/say-1.2-1.src.rock",
12 "/say-1.0-1.src.rock"
13}
14
15describe("luarocks pack #integration", function() 7describe("luarocks pack #integration", function()
16 8
17 before_each(function() 9 lazy_setup(function()
18 test_env.setup_specs(extra_rocks) 10 test_env.setup_specs()
19 end)
20
21 it("with no flags/arguments", function()
22 assert.is_false(run.luarocks_bool("pack"))
23 end)
24
25 it("basic", function()
26 assert(run.luarocks_bool("pack luacov"))
27 assert(test_env.remove_files(lfs.currentdir(), "luacov%-"))
28 end)
29
30 it("invalid rockspec", function()
31 assert.is_false(run.luarocks_bool("pack " .. testing_paths.fixtures_dir .. "/invalid_say-1.3-1.rockspec"))
32 end)
33
34 it("not installed rock", function()
35 assert.is_false(run.luarocks_bool("pack cjson"))
36 end)
37
38 it("not installed rock from non existing manifest", function()
39 assert.is_false(run.luarocks_bool("pack /non/exist/temp.manif"))
40 end)
41
42 it("detects latest version version of rock", function()
43 assert(run.luarocks_bool("install say 1.2"))
44 assert(run.luarocks_bool("install luassert"))
45 assert(run.luarocks_bool("install say 1.0"))
46 assert(run.luarocks_bool("pack say"))
47 assert.is_truthy(lfs.attributes("say-1.2-1.all.rock"))
48 assert(test_env.remove_files(lfs.currentdir(), "say%-"))
49 end)
50
51 pending("#gpg --sign", function()
52 assert(run.luarocks_bool("install say 1.2"))
53 assert(run.luarocks_bool("install luassert"))
54 assert(run.luarocks_bool("install say 1.0"))
55 os.delete("say-1.2-1.all.rock")
56 os.delete("say-1.2-1.all.rock.asc")
57 assert(run.luarocks_bool("pack say --sign"))
58 assert.is_truthy(lfs.attributes("say-1.2-1.all.rock"))
59 assert.is_truthy(lfs.attributes("say-1.2-1.all.rock.asc"))
60 assert(test_env.remove_files(lfs.currentdir(), "say%-"))
61 end) 11 end)
62 12
63 describe("#mock", function() 13 describe("#mock", function()
@@ -149,17 +99,4 @@ describe("luarocks pack #integration", function()
149 end) 99 end)
150 end) 100 end)
151 end) 101 end)
152
153 describe("#namespaces", function()
154 it("packs a namespaced rock", function()
155 finally(function()
156 os.remove("a_rock-2.0-1.all.rock")
157 end)
158 assert(run.luarocks_bool("build a_user/a_rock --server=" .. testing_paths.fixtures_dir .. "/a_repo" ))
159 assert(run.luarocks_bool("build a_rock --keep --server=" .. testing_paths.fixtures_dir .. "/a_repo" ))
160 assert(run.luarocks_bool("pack a_user/a_rock" ))
161 assert(lfs.attributes("a_rock-2.0-1.all.rock"))
162 end)
163 end)
164
165end) 102end)
diff --git a/spec/quick/pack.q b/spec/quick/pack.q
new file mode 100644
index 00000000..ee44a45f
--- /dev/null
+++ b/spec/quick/pack.q
@@ -0,0 +1,128 @@
1SUITE: luarocks pack
2
3================================================================================
4TEST: fails no arguments
5
6RUN: luarocks pack
7EXIT: 1
8
9
10
11================================================================================
12TEST: fails with invalid rockspec
13
14RUN: luarocks pack $%{fixtures_dir}/invalid_say-1.3-1.rockspec
15EXIT: 1
16
17
18
19================================================================================
20TEST: fails with rock that is not installed
21
22RUN: luarocks pack notinstalled
23EXIT: 1
24
25
26
27================================================================================
28TEST: fails with non existing path
29
30RUN: luarocks pack /notexists/notinstalled
31EXIT: 1
32
33
34
35================================================================================
36TEST: packs latest version version of rock
37
38FILE: myrock-1.0-1.rockspec
39--------------------------------------------------------------------------------
40rockspec_format = "3.0"
41package = "myrock"
42version = "1.0-1"
43source = {
44 url = "file://%{url(%{tmpdir})}/rock.lua"
45}
46build = {
47 modules = { rock = "rock.lua" }
48}
49--------------------------------------------------------------------------------
50
51FILE: myrock-2.0-1.rockspec
52--------------------------------------------------------------------------------
53rockspec_format = "3.0"
54package = "myrock"
55version = "2.0-1"
56source = {
57 url = "file://%{url(%{tmpdir})}/rock.lua"
58}
59build = {
60 modules = { rock = "rock.lua" }
61}
62--------------------------------------------------------------------------------
63
64FILE: rock.lua
65--------------------------------------------------------------------------------
66return "hello"
67--------------------------------------------------------------------------------
68
69RUN: luarocks build myrock-1.0-1.rockspec
70RUN: luarocks build myrock-2.0-1.rockspec --keep
71RUN: luarocks pack myrock
72
73EXISTS: myrock-2.0-1.all.rock
74
75
76
77================================================================================
78TEST: --sign #gpg
79PENDING: true
80
81FILE: myrock-1.0-1.rockspec
82--------------------------------------------------------------------------------
83rockspec_format = "3.0"
84package = "myrock"
85version = "1.0-1"
86source = {
87 url = "file://%{url(%{tmpdir})}/rock.lua"
88}
89build = {
90 modules = { rock = "rock.lua" }
91}
92--------------------------------------------------------------------------------
93
94FILE: myrock-2.0-1.rockspec
95--------------------------------------------------------------------------------
96rockspec_format = "3.0"
97package = "myrock"
98version = "2.0-1"
99source = {
100 url = "file://%{url(%{tmpdir})}/rock.lua"
101}
102build = {
103 modules = { rock = "rock.lua" }
104}
105--------------------------------------------------------------------------------
106
107FILE: rock.lua
108--------------------------------------------------------------------------------
109return "hello"
110--------------------------------------------------------------------------------
111
112RUN: luarocks build myrock-1.0-1.rockspec
113RUN: luarocks build myrock-2.0-1.rockspec --keep
114RUN: luarocks pack myrock --sign
115
116EXISTS: myrock-2.0-1.all.rock
117EXISTS: myrock-2.0-1.all.rock.asc
118
119
120
121================================================================================
122TEST: packs a namespaced rock #namespaces
123
124RUN: luarocks build a_user/a_rock --server=%{fixtures_dir}/a_repo
125RUN: luarocks build a_rock --keep --server=%{fixtures_dir}/a_repo
126RUN: luarocks pack a_user/a_rock
127
128EXISTS: a_rock-2.0-1.all.rock
diff --git a/spec/quick_spec.lua b/spec/quick_spec.lua
index 8b8206cf..c2d8bb59 100644
--- a/spec/quick_spec.lua
+++ b/spec/quick_spec.lua
@@ -12,7 +12,9 @@ describe("quick tests: #quick", function()
12 if f:match("%.q$") then 12 if f:match("%.q$") then
13 local tests = quick.compile(spec_quick .. "/" .. f, getfenv and getfenv() or _ENV) 13 local tests = quick.compile(spec_quick .. "/" .. f, getfenv and getfenv() or _ENV)
14 for _, t in ipairs(tests) do 14 for _, t in ipairs(tests) do
15 it(t.name, t.fn) 15 if not t.pending then
16 it(t.name, t.fn)
17 end
16 end 18 end
17 end 19 end
18 end 20 end
diff --git a/spec/util/quick.lua b/spec/util/quick.lua
index 80c75848..257f570e 100644
--- a/spec/util/quick.lua
+++ b/spec/util/quick.lua
@@ -245,6 +245,8 @@ local function parse(filename)
245 block_start_arg("STDOUT", cur_op, "stdout") 245 block_start_arg("STDOUT", cur_op, "stdout")
246 elseif cmd == "NOT_STDOUT" then 246 elseif cmd == "NOT_STDOUT" then
247 block_start_arg("NOT_STDOUT", cur_op, "not_stdout") 247 block_start_arg("NOT_STDOUT", cur_op, "not_stdout")
248 elseif cmd == "PENDING" then
249 bool_arg("PENDING", cur_test, "pending", arg)
248 elseif cmd == "TEST" then 250 elseif cmd == "TEST" then
249 table.remove(stack) 251 table.remove(stack)
250 start_test(arg) 252 start_test(arg)