-
-
Notifications
You must be signed in to change notification settings - Fork 75
Description
So I have a lua runtime that can run luaL_dostring calls just fine. But when I call require 'other_lua_file_in_load_path' in luaL_dostring, I get the error:
(2): error loading module 'other_lua_file_in_load_path' from file './other_lua_file_in_load_path.lua':
(null)
Similarly, loading the file with luaL_dofile, luaL_loadfile, or luaL_loadfilex (mode 't') all return an error code 2 and a null error message on the stack. This doesn't appear to be a syntax error in the file, the lua cli runs it just fine, and the file is deliberately simple. Additionally, if the file is completely empty (no newlines or anything), then the file loads fine. (but returns nothing, of course)
I'm using node v13.11.0, fengari 0.1.4, and fengari-interop 0.1.2 on OS X 10.15.5
How do I proceed in debugging this?
(Copied the following from the Jest version of this issue:)
To Reproduce
Steps to reproduce the behavior:
Try loading a lua file through Fengari in a Jest test:
global.WEB = false // not sure if this is needed
const { lua, lauxlib, lualib, to_luastring: toLuaString } = require('fengari')
const interop = require('fengari-interop')
test('Lua can load a file', () => {
const L = lauxlib.luaL_newstate()
lualib.luaL_openlibs(L)
lauxlib.luaL_requiref(L, toLuaString('js'), interop.luaopen_js, 1)
lua.lua_pop(L, 1) // remove lib from stack
const errorCode = lauxlib.luaL_dofile(L, 'test-load.lua')
if (errorCode) {
throw Error(`${errorCode}: ${lua.lua_tojsstring(L, -1)}`)
}
expect(interop.tojs(L, -1)).toBe('file loaded')
})file ./test-load.lua
return 'file loaded'The result I get back is error code 2, with a null message
Expected behavior
Test passes: The result of the Lua script is returned to the jest test. (As it is with jasmine).
envinfo
System:
OS: macOS 10.15.5
CPU: (8) x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
Binaries:
Node: 13.11.0 - /usr/local/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 6.13.7 - /usr/local/bin/npm
npmPackages:
jest: ^24.9.0 => 24.9.0
fengari: 0.1.4
fengari-interop: 0.1.2
jest.config.js:
module.exports = {
testEnvironment: 'node',
// Exit the test suite immediately upon the first failing test suite
bail: true,
// Each individual test should be reported during the run
verbose: true,
setupFilesAfterEnv: ['jest-extended'],
collectCoverageFrom: ['app/**/*.{js,jsx}', '!**/node_modules/**'],
coverageReporters: ['html', 'text', 'cobertura'],
testPathIgnorePatterns: ['/node_modules/'],
testMatch: ['<rootDir>/test/**/?(*.)+(spec|test).js?(x)']
}