summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-04-13 12:59:16 +1000
committerdaurnimator <quae@daurnimator.com>2017-04-19 17:25:28 +1000
commitd0b19d0a978b78d3fb4e6e5842af13736f58b316 (patch)
tree5790fdcc7405c29a8914f33bc55964ea5562ee74
parentcfd6ac4b61f3d175725620895120b7480056bafd (diff)
downloadfengari-d0b19d0a978b78d3fb4e6e5842af13736f58b316.tar.gz
fengari-d0b19d0a978b78d3fb4e6e5842af13736f58b316.tar.bz2
fengari-d0b19d0a978b78d3fb4e6e5842af13736f58b316.zip
lua-cli: Run LUA_INIT if set
-rwxr-xr-xtests/manual-tests/lua-cli.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/manual-tests/lua-cli.js b/tests/manual-tests/lua-cli.js
index 0b5519b..e32067e 100755
--- a/tests/manual-tests/lua-cli.js
+++ b/tests/manual-tests/lua-cli.js
@@ -16,6 +16,24 @@ const L = lauxlib.luaL_newstate();
linit.luaL_openlibs(L);
+let init = process.env["LUA_INIT"+lua.LUA_VERSUFFIX] || process.env["LUA_INIT"];
+if (init) {
+ let status;
+ if (init[0] === "@") {
+ status = lauxlib.luaL_loadfile(L, lua.to_luastring(init.substring(1)));
+ } else {
+ status = lauxlib.luaL_loadstring(L, lua.to_luastring(init));
+ }
+ if (status === lua.thread_status.LUA_OK) {
+ status = lapi.lua_pcall(L, 0, 0, 0);
+ }
+ if (status !== lua.thread_status.LUA_OK) {
+ lauxlib.lua_writestringerror(`${lapi.lua_tojsstring(L, -1)}\n`);
+ lapi.lua_pop(L, 1);
+ return process.exit(1);
+ }
+}
+
console.log(lua.FENGARI_COPYRIGHT);
for (;;) {