aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2017-11-06 18:11:38 -0200
committerHisham Muhammad <hisham@gobolinux.org>2017-11-06 18:26:32 -0200
commit9c7e9fed578b58fff14e7a3dd95bdad62ff6ab31 (patch)
treecaf5be2af131c535b3f9901cd379f08dcf0d3752
parentc9d9487e9e21fb2454b4c7f89494299b7473b0d1 (diff)
downloadluarocks-9c7e9fed578b58fff14e7a3dd95bdad62ff6ab31.tar.gz
luarocks-9c7e9fed578b58fff14e7a3dd95bdad62ff6ab31.tar.bz2
luarocks-9c7e9fed578b58fff14e7a3dd95bdad62ff6ab31.zip
Tests: build using INCDIR for an external dependency
-rw-r--r--spec/build_spec.lua26
-rw-r--r--test/testfiles/with_external_dep-0.1-1.rockspec25
-rw-r--r--test/testfiles/with_external_dep.c10
-rw-r--r--test/testfiles/with_external_dep/foo/foo.h1
-rw-r--r--test/testfiles/with_external_dep/foo/foo.h.gchbin0 -> 1503664 bytes
5 files changed, 58 insertions, 4 deletions
diff --git a/spec/build_spec.lua b/spec/build_spec.lua
index ffae144d..c6d5f717 100644
--- a/spec/build_spec.lua
+++ b/spec/build_spec.lua
@@ -189,12 +189,30 @@ describe("LuaRocks build tests #blackbox #b_build", function()
189 assert.is_true(os.remove("validate-args-1.5.4-1.rockspec")) 189 assert.is_true(os.remove("validate-args-1.5.4-1.rockspec"))
190 end) 190 end)
191 191
192 it("LuaRocks build missing external", function()
193 assert.is_false(run.luarocks_bool("build " .. testing_paths.testing_dir .. "/testfiles/missing_external-0.1-1.rockspec INEXISTENT_INCDIR=\"/invalid/dir\""))
194 end)
195
196 it("LuaRocks build invalid patch", function() 192 it("LuaRocks build invalid patch", function()
197 assert.is_false(run.luarocks_bool("build " .. testing_paths.testing_dir .. "/testfiles/invalid_patch-0.1-1.rockspec")) 193 assert.is_false(run.luarocks_bool("build " .. testing_paths.testing_dir .. "/testfiles/invalid_patch-0.1-1.rockspec"))
198 end) 194 end)
199 end) 195 end)
196
197 describe("external dependencies", function()
198 setup(function()
199 test_env.mock_server_init()
200 end)
201
202 teardown(function()
203 test_env.mock_server_done()
204 end)
205
206 it("fails when missing external dependency", function()
207 assert.is_false(run.luarocks_bool("build " .. testing_paths.testing_dir .. "/testfiles/missing_external-0.1-1.rockspec INEXISTENT_INCDIR=\"/invalid/dir\""))
208 end)
209
210 it("builds with external dependency", function()
211 local rockspec = testing_paths.testing_dir .. "/testfiles/with_external_dep-0.1-1.rockspec"
212 local foo_incdir = testing_paths.testing_dir .. "/testfiles/with_external_dep"
213 assert.is_truthy(run.luarocks_bool("build " .. rockspec .. " FOO_INCDIR=\"" .. foo_incdir .. "\""))
214 assert.is.truthy(run.luarocks("show with_external_dep"))
215 end)
216 end)
217
200end) 218end)
diff --git a/test/testfiles/with_external_dep-0.1-1.rockspec b/test/testfiles/with_external_dep-0.1-1.rockspec
new file mode 100644
index 00000000..45fea4bd
--- /dev/null
+++ b/test/testfiles/with_external_dep-0.1-1.rockspec
@@ -0,0 +1,25 @@
1package = "with_external_dep"
2version = "0.1-1"
3source = {
4 url = "http://localhost:8080/file/with_external_dep.c"
5}
6description = {
7 summary = "An example rockspec",
8}
9external_dependencies = {
10 FOO = {
11 header = "foo/foo.h"
12 }
13}
14dependencies = {
15 "lua >= 5.1"
16}
17build = {
18 type = "builtin",
19 modules = {
20 with_external_dep = {
21 sources = "with_external_dep.c",
22 incdirs = "$(FOO_INCDIR)",
23 }
24 }
25}
diff --git a/test/testfiles/with_external_dep.c b/test/testfiles/with_external_dep.c
new file mode 100644
index 00000000..16435d8f
--- /dev/null
+++ b/test/testfiles/with_external_dep.c
@@ -0,0 +1,10 @@
1#include <foo/foo.h>
2#include <lua.h>
3#include <lauxlib.h>
4
5int luaopen_with_external_dep(lua_State* L) {
6 lua_newtable(L);
7 lua_pushinteger(L, FOO);
8 lua_setfield(L, -2, "foo");
9 return 1;
10}
diff --git a/test/testfiles/with_external_dep/foo/foo.h b/test/testfiles/with_external_dep/foo/foo.h
new file mode 100644
index 00000000..eedd558f
--- /dev/null
+++ b/test/testfiles/with_external_dep/foo/foo.h
@@ -0,0 +1 @@
#define FOO 42
diff --git a/test/testfiles/with_external_dep/foo/foo.h.gch b/test/testfiles/with_external_dep/foo/foo.h.gch
new file mode 100644
index 00000000..66165c9e
--- /dev/null
+++ b/test/testfiles/with_external_dep/foo/foo.h.gch
Binary files differ