-
-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In node, lua require 'file'
, lual_dofile
, luaL_loadfile
, etc. doesn't seem to be working with non-empty files in jest tests
#182
Comments
Ok, so I was testing this in a jest environment. It was having issues there, but running it directly seems to be working... That is odd... |
require 'file'
, lual_dofile
, luaL_loadfile
, etc. doesn't seem to be working with non-empty filesrequire 'file'
, lual_dofile
, luaL_loadfile
, etc. doesn't seem to be working with non-empty files in jest tests
Yes, confirmed that in jest tests, the code does not seem able to load files, but outside jest tests, the code works fine. So I assume there's some global state or the like that jest is messing with, but I'm not sure what that might be. |
fengari itself uses jest; so this seems odd... |
I added the details and an example project, hope that helps. There doesn't seem to be anything useful on the stack. I ran a debugger, and was looking at the buffers lua was parsing as it was loading, and they didn't seem to match my file contents. that may have been because they weren't file buffers, and I was confused though. but they were full of non-printable characters (maybe \0? I didn't check though). Hopefully you get the same result that I did when running the example. If that's not the case, then I'll see about debugging more. |
I just stumbled upon the same problem. For me it was require in lua failing that made me break out the debugger. I've written more details on an issue filed with Jest here: |
Thanks for digging a bit @fmhdp . This sounds like a jest issue. However, it might be possible to rewrite https://github.com/fengari-lua/fengari/blob/master/src/lauxlib.js#L903-L944 to not use e.g. you could keep a |
It's good to know that fengari is still maintained and contributions are welcome. I will keep that in mind :) Since this problem vanishes when setting the correct test environment with Jest, I'm not sure if rewriting this part is really necessary. If I can find some time for open source contributions to fengari, I'd probably focus on the io library instead, since I could use support for writing files to disk in a node environment. |
So I have a lua runtime that can run
luaL_dostring
calls just fine. But when I callrequire 'other_lua_file_in_load_path'
inluaL_dostring
, I get the error:Similarly, loading the file with
luaL_dofile
,luaL_loadfile
, orluaL_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, thelua
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
, andfengari-interop 0.1.2
on OS X 10.15.5How 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:
file
./test-load.lua
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
jest.config.js:
The text was updated successfully, but these errors were encountered: