aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2024-03-13 13:49:22 -0300
committerHisham Muhammad <hisham@gobolinux.org>2024-03-13 19:08:05 +0000
commit7cafa62d20246ea17ff1d80bb75c930e8c44feef (patch)
tree32a5392e5135d2ccf5470908159d2d4a2722b25b
parent870948dd2d4e208dd98ada966a109cf7156b3e4d (diff)
downloadluarocks-7cafa62d20246ea17ff1d80bb75c930e8c44feef.tar.gz
luarocks-7cafa62d20246ea17ff1d80bb75c930e8c44feef.tar.bz2
luarocks-7cafa62d20246ea17ff1d80bb75c930e8c44feef.zip
tests: replace new_version with quick tests
-rw-r--r--spec/new_version_spec.lua85
-rw-r--r--spec/quick/new_version.q213
2 files changed, 213 insertions, 85 deletions
diff --git a/spec/new_version_spec.lua b/spec/new_version_spec.lua
deleted file mode 100644
index 18271176..00000000
--- a/spec/new_version_spec.lua
+++ /dev/null
@@ -1,85 +0,0 @@
1local test_env = require("spec.util.test_env")
2local lfs = require("lfs")
3local run = test_env.run
4local testing_paths = test_env.testing_paths
5
6local extra_rocks = {
7 "/abelhas-1.1-1.rockspec",
8 "/lpeg-${LPEG}.rockspec"
9}
10
11describe("luarocks new_version #integration", function()
12
13 lazy_setup(function()
14 test_env.setup_specs(extra_rocks)
15 end)
16
17 describe("basic tests", function()
18 it("with no flags/arguments", function()
19 finally(function()
20 lfs.chdir(testing_paths.testrun_dir)
21 test_env.remove_dir("empty")
22 end)
23 assert(lfs.mkdir("empty"))
24 assert(lfs.chdir("empty"))
25 assert.is_false(run.luarocks_bool("new_version"))
26 end)
27
28 it("with invalid", function()
29 assert.is_false(run.luarocks_bool("new_version invalid"))
30 end)
31
32 it("with invalid url", function()
33 assert.is_true(run.luarocks_bool("download --rockspec abelhas 1.1"))
34 assert.is_true(run.luarocks_bool("new_version abelhas-1.1-1.rockspec 1.1 http://luainvalid"))
35 assert.is.truthy(lfs.attributes("abelhas-1.1-1.rockspec"))
36 test_env.remove_files(lfs.currentdir(), "abelhas%-")
37 end)
38 end)
39
40 describe("more complex tests", function()
41 it("of luacov", function()
42 assert.is_true(run.luarocks_bool("download --rockspec luacov ${LUACOV_V}"))
43 assert.is_true(run.luarocks_bool("new_version luacov-${LUACOV}.rockspec 0.2"))
44 assert.is.truthy(lfs.attributes("luacov-0.2-1.rockspec"))
45 test_env.remove_files(lfs.currentdir(), "luacov%-")
46 end)
47
48 it("url of abelhas", function()
49 assert.is_true(run.luarocks_bool("download --rockspec abelhas 1.1"))
50 assert.is_true(run.luarocks_bool("new_version abelhas-1.1-1.rockspec 1.2 http://example.com/abelhas-1.2.tar.gz"))
51 assert.is.truthy(lfs.attributes("abelhas-1.2-1.rockspec"))
52 test_env.remove_files(lfs.currentdir(), "abelhas%-")
53 end)
54
55 it("of luacov with tag", function()
56 assert.is_true(run.luarocks_bool("download --rockspec luacov ${LUACOV_V}"))
57 assert.is_true(run.luarocks_bool("new_version luacov-${LUACOV}.rockspec --tag v0.3"))
58 assert.is.truthy(lfs.attributes("luacov-0.3-1.rockspec"))
59 test_env.remove_files(lfs.currentdir(), "luacov%-")
60 end)
61
62 it("updating md5", function()
63 assert.is_true(run.luarocks_bool("download --rockspec lpeg ${LPEG_V}"))
64 assert.is_true(run.luarocks_bool("new_version lpeg-${LPEG}.rockspec 0.2 https://luarocks.org/manifests/gvvaughan/lpeg-1.0.0-1.rockspec"))
65 test_env.remove_files(lfs.currentdir(), "lpeg%-")
66 end)
67 end)
68
69 describe("remote tests #mock", function()
70 lazy_setup(function()
71 test_env.setup_specs(extra_rocks, "mock")
72 test_env.mock_server_init()
73 end)
74 lazy_teardown(function()
75 test_env.mock_server_done()
76 end)
77 it("with remote spec", function()
78 assert.is_true(run.luarocks_bool("new_version http://localhost:8080/file/a_rock-1.0-1.rockspec"))
79 assert.is.truthy(lfs.attributes("a_rock-1.0-1.rockspec"))
80 assert.is.truthy(lfs.attributes("a_rock-1.0-2.rockspec"))
81 test_env.remove_files(lfs.currentdir(), "luasocket%-")
82 end)
83 end)
84
85end)
diff --git a/spec/quick/new_version.q b/spec/quick/new_version.q
new file mode 100644
index 00000000..98426db4
--- /dev/null
+++ b/spec/quick/new_version.q
@@ -0,0 +1,213 @@
1SUITE: luarocks new_version
2
3================================================================================
4TEST: fails without a context
5
6RUN: luarocks new_version
7EXIT: 1
8
9
10
11================================================================================
12TEST: fails with invalid arg
13
14RUN: luarocks new_version i_dont_exist
15EXIT: 1
16
17
18
19================================================================================
20TEST: updates a version
21
22FILE: myexample-0.1-1.rockspec
23--------------------------------------------------------------------------------
24package = "myexample"
25version = "0.1-1"
26source = {
27 url = "git+https://localhost/myexample.git",
28 tag = "v0.1"
29}
30description = {
31 summary = "xxx",
32 detailed = "xxx"
33}
34build = {
35 type = "builtin",
36 modules = {
37 foo = "src/foo.lua"
38 }
39}
40--------------------------------------------------------------------------------
41
42RUN: luarocks new_version myexample-0.1-1.rockspec 0.2
43
44FILE_CONTENTS: myexample-0.2-1.rockspec
45--------------------------------------------------------------------------------
46package = "myexample"
47version = "0.2-1"
48source = {
49 url = "git+https://localhost/myexample.git",
50 tag = "v0.2"
51}
52description = {
53 summary = "xxx",
54 detailed = "xxx"
55}
56build = {
57 type = "builtin",
58 modules = {
59 foo = "src/foo.lua"
60 }
61}
62--------------------------------------------------------------------------------
63
64
65
66================================================================================
67TEST: updates via tag
68
69FILE: myexample-0.1-1.rockspec
70--------------------------------------------------------------------------------
71package = "myexample"
72version = "0.1-1"
73source = {
74 url = "git+https://localhost/myexample.git",
75 tag = "v0.1"
76}
77description = {
78 summary = "xxx",
79 detailed = "xxx"
80}
81build = {
82 type = "builtin",
83 modules = {
84 foo = "src/foo.lua"
85 }
86}
87--------------------------------------------------------------------------------
88
89RUN: luarocks new_version myexample-0.1-1.rockspec --tag v0.2
90
91FILE_CONTENTS: myexample-0.2-1.rockspec
92--------------------------------------------------------------------------------
93package = "myexample"
94version = "0.2-1"
95source = {
96 url = "git+https://localhost/myexample.git",
97 tag = "v0.2"
98}
99description = {
100 summary = "xxx",
101 detailed = "xxx"
102}
103build = {
104 type = "builtin",
105 modules = {
106 foo = "src/foo.lua"
107 }
108}
109--------------------------------------------------------------------------------
110
111
112
113================================================================================
114TEST: updates URL
115
116FILE: myexample-0.1-1.rockspec
117--------------------------------------------------------------------------------
118package = "myexample"
119version = "0.1-1"
120source = {
121 url = "https://localhost/myexample-0.1.tar.gz",
122}
123description = {
124 summary = "xxx",
125 detailed = "xxx"
126}
127build = {
128 type = "builtin",
129 modules = {
130 foo = "src/foo.lua"
131 }
132}
133--------------------------------------------------------------------------------
134
135RUN: luarocks new_version myexample-0.1-1.rockspec 0.2 https://localhost/newpath/myexample-0.2.tar.gz
136
137FILE_CONTENTS: myexample-0.2-1.rockspec
138--------------------------------------------------------------------------------
139package = "myexample"
140version = "0.2-1"
141source = {
142 url = "https://localhost/newpath/myexample-0.2.tar.gz"
143}
144description = {
145 summary = "xxx",
146 detailed = "xxx"
147}
148build = {
149 type = "builtin",
150 modules = {
151 foo = "src/foo.lua"
152 }
153}
154--------------------------------------------------------------------------------
155
156
157
158================================================================================
159TEST: updates MD5
160
161FILE: test-1.0-1.rockspec
162--------------------------------------------------------------------------------
163package = "test"
164version = "1.0-1"
165source = {
166 url = "file://%{url(%{fixtures_dir})}/an_upstream_tarball-0.1.tar.gz",
167 md5 = "dca2ac30ce6c27cbd8dac4dd8f447630",
168}
169build = {
170 type = "builtin",
171 modules = {
172 my_module = "src/my_module.lua"
173 },
174 install = {
175 bin = {
176 "src/my_module.lua"
177 }
178 }
179}
180--------------------------------------------------------------------------------
181
182RUN: luarocks new_version test-1.0-1.rockspec 2.0 file://%{url(%{fixtures_dir})}/busted_project-0.1.tar.gz
183
184FILE_CONTENTS: test-2.0-1.rockspec
185--------------------------------------------------------------------------------
186package = "test"
187version = "2.0-1"
188source = {
189 url = "file://%{url(%{fixtures_dir})}/busted_project-0.1.tar.gz",
190 md5 = "adfdfb8f1caa2b1f935a578fb07536eb",
191}
192build = {
193 type = "builtin",
194 modules = {
195 my_module = "src/my_module.lua"
196 },
197 install = {
198 bin = {
199 "src/my_module.lua"
200 }
201 }
202}
203--------------------------------------------------------------------------------
204
205
206
207================================================================================
208TEST: takes a URL, downloads and bumps revision by default
209
210RUN: luarocks new_version file://%{url(%{fixtures_dir})}/a_rock-1.0-1.rockspec
211
212EXISTS: a_rock-1.0-1.rockspec
213EXISTS: a_rock-1.0-2.rockspec