luvit icon indicating copy to clipboard operation
luvit copied to clipboard

luvit/tap - "Missing 1 expected call" not helpful without location of the error

Open ghost opened this issue 10 years ago • 2 comments

tap's expect() function will produce an error like the following:

  [string ".../libs/tap.lua"]:83: Missing 1 expected call
  stack traceback:
        [C]: in function 'error'
        [string ".../libs/tap.lua"]:83: in function <[string ".../libs/tap.lua"]:64>
        [C]: in function 'xpcall'
        [string ".../libs/tap.lua"]:64: in function 'run'
        [string ".../libs/tap.lua"]:163: in function 'tap'
        [string ".../tests/run.lua"]:24: in function 'fn'
        [string "bundle:deps/require.lua"]:293: in function 'require'
        [string "bundle:main.lua"]:118: in function 'main'
        [string "bundle:init.lua"]:49: in function <[string "bundle:init.lua"]:47>
        [C]: in function 'xpcall'
        [string "bundle:init.lua"]:47: in function 'fn'
        [string "bundle:deps/require.lua"]:293: in function <[string "bundle:deps/require.lua"]:258>

However, without knowing which function was not called, it is hardly helpful.

Would it be possible to make expect() record the stacktrace when it is called and output that on failure?

ghost avatar Nov 20 '15 10:11 ghost

That should be possible, good idea.

creationix avatar Nov 30 '15 18:11 creationix

+1 to this idea, I've suffered writing tests.

kaustavha avatar Nov 30 '15 21:11 kaustavha