aboutsummaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorHugo Levy-Falk <hugo@klafyvel.me>2026-07-14 00:10:33 +0200
committerHisham Muhammad <hisham@gobolinux.org>2026-07-13 19:50:25 -0300
commitddbf1ac2e38415a48c89f09238ad9b28d0c3fa68 (patch)
treeaeb7935abbb3ed8161d6128d127a50aec352bb69 /spec
parent3e48d87a0d0527b51eb9520662b5cc2e54d5b66f (diff)
downloadluarocks-ddbf1ac2e38415a48c89f09238ad9b28d0c3fa68.tar.gz
luarocks-ddbf1ac2e38415a48c89f09238ad9b28d0c3fa68.tar.bz2
luarocks-ddbf1ac2e38415a48c89f09238ad9b28d0c3fa68.zip
fix: make write_rockspec command write valid rockspec given the rockspec_format argument.
Diffstat (limited to 'spec')
-rw-r--r--spec/init_spec.lua22
-rw-r--r--spec/write_rockspec_spec.lua22
2 files changed, 26 insertions, 18 deletions
diff --git a/spec/init_spec.lua b/spec/init_spec.lua
index ae211706..c193c32d 100644
--- a/spec/init_spec.lua
+++ b/spec/init_spec.lua
@@ -18,7 +18,7 @@ describe("luarocks #init #integration", function()
18 lfs.mkdir(myproject) 18 lfs.mkdir(myproject)
19 lfs.chdir(myproject) 19 lfs.chdir(myproject)
20 20
21 assert(run.luarocks("init")) 21 assert(run.luarocks_bool("init"))
22 if is_win then 22 if is_win then
23 assert.truthy(lfs.attributes(myproject .. "/lua.bat")) 23 assert.truthy(lfs.attributes(myproject .. "/lua.bat"))
24 assert.truthy(lfs.attributes(myproject .. "/luarocks.bat")) 24 assert.truthy(lfs.attributes(myproject .. "/luarocks.bat"))
@@ -41,7 +41,7 @@ describe("luarocks #init #integration", function()
41 lfs.mkdir(myproject) 41 lfs.mkdir(myproject)
42 lfs.chdir(myproject) 42 lfs.chdir(myproject)
43 43
44 assert(run.luarocks("init --no-gitignore")) 44 assert(run.luarocks_bool("init --no-gitignore"))
45 if is_win then 45 if is_win then
46 assert.truthy(lfs.attributes(myproject .. "/lua.bat")) 46 assert.truthy(lfs.attributes(myproject .. "/lua.bat"))
47 assert.truthy(lfs.attributes(myproject .. "/luarocks.bat")) 47 assert.truthy(lfs.attributes(myproject .. "/luarocks.bat"))
@@ -64,7 +64,7 @@ describe("luarocks #init #integration", function()
64 lfs.mkdir(myproject) 64 lfs.mkdir(myproject)
65 lfs.chdir(myproject) 65 lfs.chdir(myproject)
66 66
67 assert(run.luarocks("init --no-wrapper-scripts")) 67 assert(run.luarocks_bool("init --no-wrapper-scripts"))
68 assert.falsy(lfs.attributes(myproject .. "/lua.bat")) 68 assert.falsy(lfs.attributes(myproject .. "/lua.bat"))
69 assert.falsy(lfs.attributes(myproject .. "/luarocks.bat")) 69 assert.falsy(lfs.attributes(myproject .. "/luarocks.bat"))
70 assert.falsy(lfs.attributes(myproject .. "/lua")) 70 assert.falsy(lfs.attributes(myproject .. "/lua"))
@@ -84,7 +84,7 @@ describe("luarocks #init #integration", function()
84 lfs.mkdir(myproject) 84 lfs.mkdir(myproject)
85 lfs.chdir(myproject) 85 lfs.chdir(myproject)
86 86
87 assert(run.luarocks("init --wrapper-dir=./bin")) 87 assert(run.luarocks_bool("init --wrapper-dir=./bin"))
88 if is_win then 88 if is_win then
89 assert.truthy(lfs.attributes(myproject .. "/bin/lua.bat")) 89 assert.truthy(lfs.attributes(myproject .. "/bin/lua.bat"))
90 assert.truthy(lfs.attributes(myproject .. "/bin/luarocks.bat")) 90 assert.truthy(lfs.attributes(myproject .. "/bin/luarocks.bat"))
@@ -107,7 +107,7 @@ describe("luarocks #init #integration", function()
107 lfs.mkdir(myproject) 107 lfs.mkdir(myproject)
108 lfs.chdir(myproject) 108 lfs.chdir(myproject)
109 109
110 assert(run.luarocks("init")) 110 assert(run.luarocks_bool("init"))
111 if is_win then 111 if is_win then
112 assert.truthy(lfs.attributes(myproject .. "/lua.bat")) 112 assert.truthy(lfs.attributes(myproject .. "/lua.bat"))
113 assert.truthy(lfs.attributes(myproject .. "/luarocks.bat")) 113 assert.truthy(lfs.attributes(myproject .. "/luarocks.bat"))
@@ -146,7 +146,7 @@ describe("luarocks #init #integration", function()
146 lfs.mkdir(myproject) 146 lfs.mkdir(myproject)
147 lfs.chdir(myproject) 147 lfs.chdir(myproject)
148 148
149 assert(run.luarocks("init customname 1.0")) 149 assert(run.luarocks_bool("init customname 1.0"))
150 assert.truthy(lfs.attributes(myproject .. "/customname-1.0-1.rockspec")) 150 assert.truthy(lfs.attributes(myproject .. "/customname-1.0-1.rockspec"))
151 assert.truthy(run.luarocks_bool("lint " .. myproject .. "/customname-1.0-1.rockspec")) 151 assert.truthy(run.luarocks_bool("lint " .. myproject .. "/customname-1.0-1.rockspec"))
152 end, finally) 152 end, finally)
@@ -158,7 +158,7 @@ describe("luarocks #init #integration", function()
158 lfs.mkdir(myproject) 158 lfs.mkdir(myproject)
159 lfs.chdir(myproject) 159 lfs.chdir(myproject)
160 160
161 assert(run.luarocks("init --lua-versions=5.1,5.2,5.3,5.4,5.5")) 161 assert(run.luarocks_bool("init --lua-versions=5.1,5.2,5.3,5.4,5.5"))
162 local rockspec_name = myproject .. "/myproject-dev-1.rockspec" 162 local rockspec_name = myproject .. "/myproject-dev-1.rockspec"
163 assert.truthy(lfs.attributes(rockspec_name)) 163 assert.truthy(lfs.attributes(rockspec_name))
164 local fd = assert(io.open(rockspec_name, "rb")) 164 local fd = assert(io.open(rockspec_name, "rb"))
@@ -175,7 +175,7 @@ describe("luarocks #init #integration", function()
175 copy_dir(testing_paths.fixtures_dir .. "/git_repo", myproject) 175 copy_dir(testing_paths.fixtures_dir .. "/git_repo", myproject)
176 lfs.chdir(myproject) 176 lfs.chdir(myproject)
177 177
178 assert(run.luarocks("init")) 178 assert(run.luarocks_bool("init"))
179 local fd = assert(io.open(myproject .. "/myproject-dev-1.rockspec", "r")) 179 local fd = assert(io.open(myproject .. "/myproject-dev-1.rockspec", "r"))
180 local content = assert(fd:read("*a")) 180 local content = assert(fd:read("*a"))
181 assert.truthy(content:find("summary = \"Test repo\"")) 181 assert.truthy(content:find("summary = \"Test repo\""))
@@ -197,7 +197,7 @@ describe("luarocks #init #integration", function()
197 lfs.mkdir(myproject) 197 lfs.mkdir(myproject)
198 lfs.chdir(myproject) 198 lfs.chdir(myproject)
199 199
200 assert(run.luarocks("init")) 200 assert(run.luarocks_bool("init"))
201 assert.truthy(lfs.attributes(myproject .. "/.luarocks/config-" .. test_env.lua_version .. ".lua")) 201 assert.truthy(lfs.attributes(myproject .. "/.luarocks/config-" .. test_env.lua_version .. ".lua"))
202 local rockspec_filename = myproject .. "/myproject-dev-1.rockspec" 202 local rockspec_filename = myproject .. "/myproject-dev-1.rockspec"
203 assert.truthy(lfs.attributes(rockspec_filename)) 203 assert.truthy(lfs.attributes(rockspec_filename))
@@ -218,14 +218,14 @@ describe("luarocks #init #integration", function()
218 ]], finally) 218 ]], finally)
219 write_file(tmpdir .. "/my_dependency.lua", "return {}", finally) 219 write_file(tmpdir .. "/my_dependency.lua", "return {}", finally)
220 220
221 assert.truthy(run.luarocks("build my_dependency-1.0-1.rockspec")) 221 assert.truthy(run.luarocks_bool("build my_dependency-1.0-1.rockspec"))
222 assert.truthy(lfs.attributes(myproject .. "/lua_modules/share/lua/" .. test_env.lua_version .."/my_dependency.lua")) 222 assert.truthy(lfs.attributes(myproject .. "/lua_modules/share/lua/" .. test_env.lua_version .."/my_dependency.lua"))
223 223
224 os.remove(rockspec_filename) 224 os.remove(rockspec_filename)
225 os.remove("my_dependency-1.0-1.rockspec") 225 os.remove("my_dependency-1.0-1.rockspec")
226 226
227 -- re-run init 227 -- re-run init
228 assert(run.luarocks("init")) 228 assert(run.luarocks_bool("init"))
229 229
230 -- file is recreated 230 -- file is recreated
231 assert.truthy(lfs.attributes(rockspec_filename)) 231 assert.truthy(lfs.attributes(rockspec_filename))
diff --git a/spec/write_rockspec_spec.lua b/spec/write_rockspec_spec.lua
index 2ade5986..7a8554bb 100644
--- a/spec/write_rockspec_spec.lua
+++ b/spec/write_rockspec_spec.lua
@@ -55,13 +55,21 @@ describe("luarocks ##write_rockspec tests #integration", function()
55 -- TODO check contents 55 -- TODO check contents
56 end) 56 end)
57 57
58 it("runs with format flag", function() 58 local formats = {
59 finally(function() os.remove("testrock-dev-1.rockspec") end) 59 "1.0",
60 assert.is_true(run.luarocks_bool("write_rockspec git://localhost/testrock --rockspec-format=1.1 --lua-versions=5.1,5.2")) 60 "1.1",
61 assert.is.truthy(lfs.attributes("testrock-dev-1.rockspec")) 61 "3.0",
62 assert.truthy(run.luarocks_bool("lint " .. "testrock-dev-1.rockspec")) 62 "3.1",
63 -- TODO check contents 63 }
64 end) 64 for i, format in ipairs(formats) do
65 it("runs with format flag " .. format, function()
66 finally(function() os.remove("testrock-dev-1.rockspec") end)
67 assert.is_true(run.luarocks_bool("write_rockspec git://localhost/testrock --rockspec-format=" .. format .. " --lua-versions=5.1,5.2"))
68 assert.is.truthy(lfs.attributes("testrock-dev-1.rockspec"))
69 assert.truthy(run.luarocks_bool("lint " .. "testrock-dev-1.rockspec"))
70 -- TODO check contents
71 end)
72 end
65 73
66 it("runs with full flags", function() 74 it("runs with full flags", function()
67 finally(function() os.remove("testrock-dev-1.rockspec") end) 75 finally(function() os.remove("testrock-dev-1.rockspec") end)