lunarmodules / busted

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

Busted can't run multiple tests: Error → Nil error #664

Closed andrew141 closed 2 years ago

andrew141 commented 3 years ago

Hello everybody, I have a problem with running multiple tests via busted. I have 3 simple test scripts:

The problem is when I run them with command busted or busted -c, because after second test script there's an error saying:

Error → Nil error
suite spec/test_script_3_spec.lua

It seems like requiring terra causes an error due to which the following test scripts cannot be executed. My version of Lua is LuaJIT 2.1.0-beta3 -- Copyright (C) 2005-2017 Mike Pall. http://luajit.org/ And I have terra installed with Luapower (distribution for LuaJIT, Terra and OpenResty). Does somebody know how to deal with this type of error, please? I would appreciate any help. Thank you very much and have a nice day.

Andrej

Tieske commented 3 years ago

Use the verbose flag on the command line

andrew141 commented 3 years ago

@Tieske thank you for your hint, so I tried busted -v (as well as busted --verbose) and here's the output:

root@2626552b0fa8:/luadev/luaserver# busted -v

Setup function for Test script 1
Test function for Test script 1
●
Setup function for Main test script 2
Test function for Main test script 2
●✱
2 successes / 0 failures / 1 error / 0 pending : 0.065986 seconds

Error → Nil error
suite spec/test_script_3_spec.lua
root@2626552b0fa8:/luadev/luaserver# 
Tieske commented 3 years ago

hmmm... some output options do not display set up error properly, try for example -o TAP and see if that adds more info

andrew141 commented 3 years ago

@Tieske thank you, seems like that helped a little, there's longer output with -o TAP:

root@2626552b0fa8:/luadev/luaserver# busted -o TAP

Setup function for Test script 1
Test function for Test script 1
ok 1 - Test script 1 Test function for Test script 1

Setup function for Main test script 2
Test function for Main test script 2
ok 2 - Main test script 2 (with terra require) Test function for Main test script 2
not ok 3 - suite spec/test_script_3_spec.lua
not ok 4 - suite spec/test_script_3_spec.lua
/usr/local/bin/luajit: /usr/local/share/lua/5.1/busted/outputHandlers/TAP.lua:35: attempt to index field 'trace' (a nil value)
stack traceback:
    /usr/local/share/lua/5.1/busted/outputHandlers/TAP.lua:35: in function 'showFailure'
    /usr/local/share/lua/5.1/busted/outputHandlers/TAP.lua:76: in function 'fn'
    /usr/local/share/lua/5.1/mediator.lua:103: in function 'publish'
    /usr/local/share/lua/5.1/busted/core.lua:201: in function 'safe'
    /usr/local/share/lua/5.1/busted/core.lua:312: in function 'execute'
    /usr/local/share/lua/5.1/busted/execute.lua:58: in function 'execute'
    /usr/local/share/lua/5.1/busted/runner.lua:197: in function </usr/local/share/lua/5.1/busted/runner.lua:11>
    /usr/local/lib/luarocks/rocks-5.1/busted/2.0.0-1/bin/busted:3: in main chunk
    [C]: at 0x5616e1667620
root@2626552b0fa8:/luadev/luaserver# 

But anyway, I'm still struggling with the error, I don't know what's wrong with terra.

alerque commented 2 years ago

Did you ever figure this out @andrew141?

andrew141 commented 2 years ago

@alerque Hi, probably yes (as I passed the subject in school), but now I'm not sure what really helped my scripts. I was solving this problem more than one year ago and I don't remember the solution, I'm sorry.

alerque commented 2 years ago

Fair enough. If anybody ever bumps into the same thing and ends up here with a Google search or whatever feel free to drop a comment and we can look into it further.