runner icon indicating copy to clipboard operation
runner copied to clipboard

Lua preloaded code not preloaded

Open slashOwO opened this issue 1 year ago • 3 comments

Describe the bug In Lua, if the test case doesn't include require "setup", the preloaded code will not be preloaded. Even if require "setup" is included, functions like describe or it will not be be accessible.

To Reproduce Without require "setup" With require "setup"

Expected behavior The preloaded code should preloaded correctly.

slashOwO avatar Jul 06 '24 06:07 slashOwO

Does anything else than it and describe work when put in preloaded? Preloaded is not meant to hold elements of tests, like test groups or test cases. I am not yet sure if the behavior of preloaded you see is wrong or not, but definitely having it in preloaded does not sound right.

hobovsky avatar Jul 06 '24 09:07 hobovsky

Does anything else than it and describe work when put in preloaded? Anything that isn't from busted works fine. The behavior is like require "solution"

Preloaded is not meant to hold elements of tests There are katas that hold test elements in the preloaded code. For example, this one.

slashOwO avatar Jul 07 '24 08:07 slashOwO

I am not very familiar with LUA and its module loading mechanisms, and I did not manage to figure out how to make busted visible in the preloaded snippet. But that being said, I would say that the test suite you showed as an example is not built correctly and would have to be fixed. It makes a bunch of incorrect assumptions about CW testing in general, about how Busted works, and about LUA setup on Codewars. I would recommend against following the patterns presented in this test suite, and focus on doing things properly: code of tests belongs to tests snippets.

hobovsky avatar Jul 07 '24 14:07 hobovsky