lunarmodules / busted

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

ERROR: attempt to yield across C-call boundary #608

Closed ktalebian closed 4 years ago

ktalebian commented 5 years ago

When running busted with option {standalone = false} I get:

ERROR: attempt to yield across C-call boundary
stack traceback:
        coroutine.wrap:21: in function '(for generator)'
        .../lua_modules/share/lua/5.1/pl/dir.lua:459: in function 'getfiles'
        ...odules/share/lua/5.1/busted/modules/test_file_loader.lua:21: in function 'getTestFiles'
        ...odules/share/lua/5.1/busted/modules/test_file_loader.lua:57: in function 'getAllTestFiles'
        ...odules/share/lua/5.1/busted/modules/test_file_loader.lua:72: in function 'testFileLoader'
        .../lua_modules/share/lua/5.1/busted/runner.lua:192: in function <.../lua_modules/share/lua/5.1/busted/runner.lua:11>
        ./spec/setup.lua:4: in main chunk
        [C]: in function 'require'
        spec/app/utils/version.lua:7: in function 'file_gen'
        init_worker_by_lua:46: in function <init_worker_by_lua:44>
        [C]: in function 'xpcall'
        init_worker_by_lua:53: in function <init_worker_by_lua:51>

This is running on a blank test, i.e. my version.lua test file is

package.path = package.path .. ';../?.lua'
require 'spec.setup'

and my spec.setup is

package.path = package.path .. ';../?.lua'
require 'busted.runner'({ standalone = false})

What's the issue?

Tieske commented 5 years ago

first guess would be the multiple require statements. require is implemented as a C function and is a common culprit for these errors. This also depends on the version of the Lua engine you're using PuC Lua is different from LuaJIT, and again from OpenResty for example.

What happens if you replace require 'spec.setup' with the actual contents of that file?

Just wondering whether there is a reason for your setup with version.lua and then calling busted from code? Why not create a busted config file and just call the busted cli script busted ?

Tieske commented 4 years ago

no response, closing