aboutsummaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2019-09-02 14:32:54 -0300
committerHisham Muhammad <hisham@gobolinux.org>2019-09-03 14:56:49 -0300
commit96b6b9ca9cf77922863d440247850b6b7c4bb9ae (patch)
treef090af9c1d03c21bf3ba8f6d556b17f7630e3a57 /spec
parent989c58dff675532cf6378ade3790fd7e28e5bc07 (diff)
downloadluarocks-96b6b9ca9cf77922863d440247850b6b7c4bb9ae.tar.gz
luarocks-96b6b9ca9cf77922863d440247850b6b7c4bb9ae.tar.bz2
luarocks-96b6b9ca9cf77922863d440247850b6b7c4bb9ae.zip
build: fix --branch flag
The `--branch` flag is optional and takes a string argument. The `--branch` flag does not make sense for `luarocks make` because it does not fetch sources, it builds/installs based on whatever is in the current directory. This also adds tests that verify the behavior, but these don't run in Travis CI because of issues running a Git daemon there. They were verified locally.
Diffstat (limited to 'spec')
-rw-r--r--spec/build_spec.lua35
-rw-r--r--spec/install_spec.lua29
-rw-r--r--spec/util/git_repo.lua1
3 files changed, 58 insertions, 7 deletions
diff --git a/spec/build_spec.lua b/spec/build_spec.lua
index 41c169d9..f0377b5f 100644
--- a/spec/build_spec.lua
+++ b/spec/build_spec.lua
@@ -4,6 +4,7 @@ local get_tmp_path = test_env.get_tmp_path
4local run = test_env.run 4local run = test_env.run
5local testing_paths = test_env.testing_paths 5local testing_paths = test_env.testing_paths
6local write_file = test_env.write_file 6local write_file = test_env.write_file
7local git_repo = require("spec.util.git_repo")
7 8
8test_env.unload_luarocks() 9test_env.unload_luarocks()
9local cfg = require("luarocks.core.cfg") 10local cfg = require("luarocks.core.cfg")
@@ -109,12 +110,6 @@ describe("LuaRocks build tests #integration", function()
109 end, finally) 110 end, finally)
110 end) 111 end)
111 112
112 it("LuaRocks build lpeg branch=master", function()
113 -- FIXME should use dev package
114 assert.is_true(run.luarocks_bool("build --branch=master lpeg"))
115 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec"))
116 end)
117
118 it("LuaRocks build fails if the deps-mode argument is invalid", function() 113 it("LuaRocks build fails if the deps-mode argument is invalid", function()
119 assert.is_false(run.luarocks_bool("build --deps-mode=123 " .. testing_paths.fixtures_dir .. "/a_rock-1.0-1.rockspec")) 114 assert.is_false(run.luarocks_bool("build --deps-mode=123 " .. testing_paths.fixtures_dir .. "/a_rock-1.0-1.rockspec"))
120 assert.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/a_rock/1.0-1/a_rock-1.0-1.rockspec")) 115 assert.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/a_rock/1.0-1/a_rock-1.0-1.rockspec"))
@@ -928,5 +923,33 @@ describe("LuaRocks build tests #unit", function()
928 end) 923 end)
929 end) 924 end)
930 end) 925 end)
926
927 describe("#unix build from #git", function()
928 local git
929
930 setup(function()
931 git = git_repo.start()
932 end)
933
934 teardown(function()
935 if git then
936 git:stop()
937 end
938 end)
939
940 it("using --branch", function()
941 write_file("my_branch-1.0-1.rockspec", [[
942 rockspec_format = "3.0"
943 package = "my_branch"
944 version = "1.0-1"
945 source = {
946 url = "git://localhost/testrock"
947 }
948 ]], finally)
949 assert.is_false(run.luarocks_bool("build --branch unknown-branch ./my_branch-1.0-1.rockspec"))
950 assert.is_true(run.luarocks_bool("build --branch test-branch ./my_branch-1.0-1.rockspec"))
951 end)
952 end)
953
931end) 954end)
932 955
diff --git a/spec/install_spec.lua b/spec/install_spec.lua
index 77ac6225..3b0b22fb 100644
--- a/spec/install_spec.lua
+++ b/spec/install_spec.lua
@@ -3,8 +3,8 @@ local lfs = require("lfs")
3local run = test_env.run 3local run = test_env.run
4local testing_paths = test_env.testing_paths 4local testing_paths = test_env.testing_paths
5local env_variables = test_env.env_variables 5local env_variables = test_env.env_variables
6local get_tmp_path = test_env.get_tmp_path
7local write_file = test_env.write_file 6local write_file = test_env.write_file
7local git_repo = require("spec.util.git_repo")
8 8
9test_env.unload_luarocks() 9test_env.unload_luarocks()
10 10
@@ -234,4 +234,31 @@ describe("luarocks install #integration", function()
234 end) 234 end)
235 end) 235 end)
236 236
237 describe("#unix install runs build from #git", function()
238 local git
239
240 setup(function()
241 git = git_repo.start()
242 end)
243
244 teardown(function()
245 if git then
246 git:stop()
247 end
248 end)
249
250 it("using --branch", function()
251 write_file("my_branch-1.0-1.rockspec", [[
252 rockspec_format = "3.0"
253 package = "my_branch"
254 version = "1.0-1"
255 source = {
256 url = "git://localhost/testrock"
257 }
258 ]], finally)
259 assert.is_false(run.luarocks_bool("install --branch unknown-branch ./my_branch-1.0-1.rockspec"))
260 assert.is_true(run.luarocks_bool("install --branch test-branch ./my_branch-1.0-1.rockspec"))
261 end)
262 end)
263
237end) 264end)
diff --git a/spec/util/git_repo.lua b/spec/util/git_repo.lua
index 6cccfcc4..b3ddd9ef 100644
--- a/spec/util/git_repo.lua
+++ b/spec/util/git_repo.lua
@@ -82,6 +82,7 @@ function git_repo.start()
82 test_env.execute("git add " .. name) 82 test_env.execute("git add " .. name)
83 end 83 end
84 assert(test_env.execute("git commit -a -m 'initial commit'")) 84 assert(test_env.execute("git commit -a -m 'initial commit'"))
85 assert(test_env.execute("git branch test-branch"))
85 print("git daemon --reuseaddr --pid-file="..pidfile.." --base-path="..basedir.." --export-all "..repodir.." &") 86 print("git daemon --reuseaddr --pid-file="..pidfile.." --base-path="..basedir.." --export-all "..repodir.." &")
86 assert(test_env.execute("git daemon --reuseaddr --pid-file="..pidfile.." --base-path="..basedir.." --export-all "..repodir.." &")) 87 assert(test_env.execute("git daemon --reuseaddr --pid-file="..pidfile.." --base-path="..basedir.." --export-all "..repodir.." &"))
87 assert(test_env.execute("sleep 0.1; netstat -ln | grep '0.0.0.0:9418 .* LISTEN'")) 88 assert(test_env.execute("sleep 0.1; netstat -ln | grep '0.0.0.0:9418 .* LISTEN'"))