lunarmodules / busted

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

fix(TAP-output): error if no test files #731

Closed notomo closed 8 months ago

notomo commented 8 months ago

This pr will fix the following error that if no test files:

busted --output=TAP
not ok 1 - 
/home/linuxbrew/.linuxbrew/opt/lua/bin/lua5.4: ...w/.linuxbrew/share/lua/5.4/busted/outputHandlers/TAP.lua:44: attempt to concatenate a nil value (field 'currentline')
stack traceback:
        ...w/.linuxbrew/share/lua/5.4/busted/outputHandlers/TAP.lua:44: in upvalue 'showFailure'
        ...w/.linuxbrew/share/lua/5.4/busted/outputHandlers/TAP.lua:87: in field 'fn'
        /home/linuxbrew/.linuxbrew/share/lua/5.4/mediator.lua:103: in function </home/linuxbrew/.linuxbrew/share/lua/5.4/mediator.lua:96>
        (...tail calls...)
        ...uxbrew/share/lua/5.4/busted/modules/test_file_loader.lua:46: in upvalue 'getTestFiles'
        ...uxbrew/share/lua/5.4/busted/modules/test_file_loader.lua:57: in upvalue 'getAllTestFiles'
        ...uxbrew/share/lua/5.4/busted/modules/test_file_loader.lua:72: in local 'testFileLoader'
        /home/linuxbrew/.linuxbrew/share/lua/5.4/busted/runner.lua:173: in function 'busted.runner'
        ...linuxbrew/lib/luarocks/rocks-5.4/busted/scm-1/bin/busted:3: in main chunk
        [C]: in ?

📝 after fix

This behavior is the same with others output handlers.

busted --output=TAP
not ok 1 - 
# Failure message: Cannot find file or directory: spec
not ok 2 - 
# Failure message: No test files found matching Lua pattern: _spec
1..2
alerque commented 8 months ago

Thanks for taking the time to contribute @notomo.