aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2020-09-23 12:14:58 -0300
committerGitHub <noreply@github.com>2020-09-23 12:14:58 -0300
commit0cf93c431c5ff251324c7f6b875d9d56feeb3cad (patch)
tree8c0cea6ebc0325a788a868b7835db9e95b8d02a3
parentf162d2ec3ca13d9e757db9dd6eb0f13979bac74b (diff)
downloadluarocks-0cf93c431c5ff251324c7f6b875d9d56feeb3cad.tar.gz
luarocks-0cf93c431c5ff251324c7f6b875d9d56feeb3cad.tar.bz2
luarocks-0cf93c431c5ff251324c7f6b875d9d56feeb3cad.zip
Support --pin and --only-deps together (#1222)
-rw-r--r--spec/build_spec.lua36
-rw-r--r--src/luarocks/build.lua3
2 files changed, 39 insertions, 0 deletions
diff --git a/spec/build_spec.lua b/spec/build_spec.lua
index 4843ed73..7d18ae4c 100644
--- a/spec/build_spec.lua
+++ b/spec/build_spec.lua
@@ -237,6 +237,42 @@ describe("LuaRocks build #integration", function()
237 end) 237 end)
238 end) 238 end)
239 239
240 it("supports --pin --only-deps #pinning", function()
241 test_env.run_in_tmp(function(tmpdir)
242 write_file("test-1.0-1.rockspec", [[
243 package = "test"
244 version = "1.0-1"
245 source = {
246 url = "file://]] .. tmpdir:gsub("\\", "/") .. [[/test.lua"
247 }
248 dependencies = {
249 "a_rock >= 0.8"
250 }
251 build = {
252 type = "builtin",
253 modules = {
254 test = "test.lua"
255 }
256 }
257 ]], finally)
258 write_file("test.lua", "return {}", finally)
259
260 assert.is_true(run.luarocks_bool("build --server=" .. testing_paths.fixtures_dir .. "/a_repo test-1.0-1.rockspec --pin --only-deps --tree=lua_modules"))
261 assert.is.falsy(lfs.attributes("./lua_modules/lib/luarocks/rocks-" .. test_env.lua_version .. "/test/1.0-1/test-1.0-1.rockspec"))
262 assert.is.truthy(lfs.attributes("./lua_modules/lib/luarocks/rocks-" .. test_env.lua_version .. "/a_rock/2.0-1/a_rock-2.0-1.rockspec"))
263 assert.is.truthy(lfs.attributes("./luarocks.lock"))
264 local lockfilename = "./luarocks.lock"
265 assert.is.truthy(lfs.attributes(lockfilename))
266 local lockdata = loadfile(lockfilename)()
267 assert.same({
268 dependencies = {
269 ["a_rock"] = "2.0-1",
270 ["lua"] = test_env.lua_version .. "-1",
271 }
272 }, lockdata)
273 end)
274 end)
275
240 it("lmathx deps partial match", function() 276 it("lmathx deps partial match", function()
241 assert.is_true(run.luarocks_bool("build lmathx")) 277 assert.is_true(run.luarocks_bool("build lmathx"))
242 278
diff --git a/src/luarocks/build.lua b/src/luarocks/build.lua
index f11edb6f..c410fbde 100644
--- a/src/luarocks/build.lua
+++ b/src/luarocks/build.lua
@@ -383,6 +383,9 @@ function build.build_rockspec(rockspec, opts)
383 383
384 local name, version = rockspec.name, rockspec.version 384 local name, version = rockspec.name, rockspec.version
385 if opts.build_only_deps then 385 if opts.build_only_deps then
386 if opts.pin then
387 deplocks.write_file()
388 end
386 return name, version 389 return name, version
387 end 390 end
388 391