diff options
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | lib/supple/host.lua | 2 | ||||
-rw-r--r-- | src/wrapper.c | 17 |
3 files changed, 16 insertions, 7 deletions
@@ -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); } |