File: standalone_loader.lua

package info (click to toggle)
lua-busted 2.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 820 kB
  • sloc: sh: 198; makefile: 2
file content (28 lines) | stat: -rw-r--r-- 685 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
local getTrace = function(filename, info)
  local index = info.traceback:find('\n%s*%[C]')
  info.traceback = info.traceback:sub(1, index)
  return info
end

return function(busted)
  local loadCurrentFile = function(info, options)
    local filename = 'string'
    if info.source:sub(1,1) == '@' or info.source:sub(1,1) == '=' then
      filename = info.source:sub(2)
    end

    -- Setup test file to be compatible with live coding
    if info.func then
      local file = setmetatable({
        getTrace = getTrace,
        rewriteMessage = nil
      }, {
        __call = info.func
      })

      busted.executors.file(filename, file)
    end
  end

  return loadCurrentFile
end