lunarmodules / busted

Elegant Lua unit testing.
https://lunarmodules.github.io/busted/
MIT License
1.43k stars 186 forks source link

TAP handler is segfaulting... #569

Closed jszakmeister closed 4 years ago

jszakmeister commented 6 years ago

We use busted on Neovim and it looks like the TAP handler is backtracing with:

17:53:19,189 WARN  - /Users/quickbuild/buildagent/workspace/root/neovim/pull-requests-automated/.deps/usr/bin/luajit: ./busted/outputHandlers/TAP.lua:37: attempt to concatenate field 'currentline' (a nil value)
17:53:19,190 WARN  - stack traceback:
17:53:19,190 WARN  -     ./busted/outputHandlers/TAP.lua:37: in function 'showFailure'
17:53:19,190 WARN  -     ./busted/outputHandlers/TAP.lua:78: in function 'fn'
17:53:19,190 WARN  -     ...-requests-automated/.deps/usr/share/lua/5.1/mediator.lua:103: in function 'publish'
17:53:19,190 WARN  -     ...ted/.deps/usr/share/lua/5.1/busted/modules/files/lua.lua:18: in function 'loadTestFile'
17:53:19,190 WARN  -     ...ps/usr/share/lua/5.1/busted/modules/test_file_loader.lua:74: in function 'testFileLoader'
17:53:19,190 WARN  -     ...ests-automated/.deps/usr/share/lua/5.1/busted/runner.lua:158: in function <...ests-automated/.deps/usr/share/lua/5.1/busted/runner.lua:11>
17:53:19,190 WARN  -     ./.deps/usr/lib/luarocks/rocks/busted/2.0.rc12-1/bin/busted:3: in main chunk
17:53:19,190 WARN  -     [C]: at 0x0100001890

I'm not sure how long this has been going on, but I think it's at least fairly recent.

Tieske commented 6 years ago

There haven't been any recent busted releases. What changes caused the new behaviour?

jszakmeister commented 6 years ago

I think it's just that the failure mode is different (the way in which we're failing is different). It still seems like it shouldn't break this way though--but I could be missing a detail too. I'm not sure about this traceback either. Line 37 doesn't reference currentline, but 34 does:

    print('# ' .. t.element.trace.short_src .. ' @ ' .. t.element.trace.currentline)

I'm not sure if it's possible for trace to be empty or currentline to be missing. It seems like a possibility since there is this on line 24:

local trace = t.trace or {}

But I don't know how t.trace and t.element.trace are related.

Tieske commented 6 years ago

I can't match the line numbers to the source of master nor the last release tag. This could be because Busted does some stacktrace rewriting, but not sure.

What strikes me though is this line:

...ps/usr/share/lua/5.1/busted/modules/test_file_loader.lua:74: in function 'testFileLoader'

So it appears to me it errors during loading a file, not while running the tests. So could it be an issue with your test file? (still shouldn't error like this probably)

DorianGray commented 6 years ago

@jszakmeister did you ever figure it out? Do you have a small test case that reproduces the behavior? It would be good to make it so debugging these issues is more straightforward in the future

jszakmeister commented 6 years ago

@DorianGray Unfortunately, no. The problem stopped reproducing (I think it was a timing problem on our end), but I agree--it'd be nice to have it handled better. I'm also poor at Lua, so tracing back to where the nil originated from was a huge hurdle. I tried, but just didn't have the hours needed to track it down via print statements. Sorry. :-(

Tieske commented 4 years ago

closing this now