summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2015-10-15 10:24:53 +0200
committerDaniel Silverstone <dsilvers@digital-scurf.org>2015-10-15 10:24:53 +0200
commit968ec2e65eb4b1abcc4203c32d856c8097a87d1c (patch)
tree3b91752b9b86c8c19b01067f928596faf30ace3f
parent1d3167b0da37a294298f570500901724fa72be06 (diff)
downloadsupple-968ec2e65eb4b1abcc4203c32d856c8097a87d1c.tar.gz
Better support testing supple during things like package buildsv1.0
-rw-r--r--Makefile4
-rw-r--r--lib/supple/host.lua2
-rw-r--r--src/wrapper.c17
3 files changed, 16 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index 3f6d2fd..adaff8f 100644
--- a/Makefile
+++ b/Makefile
@@ -71,7 +71,7 @@ ifeq ($(DEBUG),gdb)
GDB := gdb --args
endif
-LUA := LUA_PATH="$(shell pwd)/lib/?.lua;$(shell pwd)/extras/luacov/src/?.lua;;" LUA_CPATH="$(shell pwd)/lib/?.so;;" $(GDB) $(LUA_INTERP_PATH)
+LUA := SUPPLE_TEST_WRAPPER="$(shell pwd)/testwrapper" LUA_PATH="$(shell pwd)/lib/?.lua;$(shell pwd)/extras/luacov/src/?.lua;;" LUA_CPATH="$(shell pwd)/lib/?.so;;" $(GDB) $(LUA_INTERP_PATH)
clean:
$(RM) luacov.report.out luacov.stats.out
@@ -84,7 +84,7 @@ distclean: clean
.PHONY: example
example:
- $(LUA) example/supple-example.lua
+ $(LUA) example/simple-example.lua
.PHONY: test
test: build testwrapper
diff --git a/lib/supple/host.lua b/lib/supple/host.lua
index 596fba1..d782115 100644
--- a/lib/supple/host.lua
+++ b/lib/supple/host.lua
@@ -47,7 +47,7 @@ end
local function run_wrapper()
local wrapperpath = "@@WRAPPER_BIN@@"
-- START_TEST_SUPPLE
- wrapperpath = "./testwrapper"
+ wrapperpath = os.getenv "SUPPLE_TEST_WRAPPER"
-- END_TEST_SUPPLE
local fds = {}
local ret, errno = luxio.socketpair(luxio.AF_UNIX, luxio.SOCK_STREAM,
diff --git a/src/wrapper.c b/src/wrapper.c
index 3d11e01..b27651c 100644
--- a/src/wrapper.c
+++ b/src/wrapper.c
@@ -28,7 +28,16 @@ protected_main(lua_State *L)
prot_args *parg = (prot_args *)lua_touserdata(L, 1);
luaL_openlibs(L);
-
+
+#ifdef TESTING_SUPPLE
+ if (getenv("LUA_INIT") != NULL) {
+ if (luaL_dostring(L, getenv("LUA_INIT")) != 0) {
+ parg->retcode = 1;
+ return 0;
+ }
+ }
+#endif
+
lua_getglobal(L, "require");
lua_pushstring(L, "supple");
lua_call(L, 1, 1);
@@ -57,8 +66,8 @@ main(int argc, char **argv)
unsetenv("LUA_PATH");
unsetenv("LUA_CPATH");
unsetenv("SUPPLE_MKDTEMP");
-#endif
unsetenv("LUA_INIT");
+#endif
L = luaL_newstate();
if (L == NULL) {
@@ -70,11 +79,11 @@ main(int argc, char **argv)
lua_pushcclosure(L, &protected_main, 0);
lua_pushlightuserdata(L, &parg);
- success = lua_pcall(L, -1, 0, 0);
+ success = lua_pcall(L, 1, 0, 0);
if (success != 0) {
size_t l;
- const char *s = lua_tolstring(L, 1, &l);
+ const char *s = lua_tolstring(L, -1, &l);
write(2, s, l);
}