diff options
author | daurnimator <quae@daurnimator.com> | 2017-04-13 12:59:16 +1000 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2017-04-19 17:25:28 +1000 |
commit | d0b19d0a978b78d3fb4e6e5842af13736f58b316 (patch) | |
tree | 5790fdcc7405c29a8914f33bc55964ea5562ee74 /tests | |
parent | cfd6ac4b61f3d175725620895120b7480056bafd (diff) | |
download | fengari-d0b19d0a978b78d3fb4e6e5842af13736f58b316.tar.gz fengari-d0b19d0a978b78d3fb4e6e5842af13736f58b316.tar.bz2 fengari-d0b19d0a978b78d3fb4e6e5842af13736f58b316.zip |
lua-cli: Run LUA_INIT if set
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/manual-tests/lua-cli.js | 18 |
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 (;;) { |