Aire-One 1 year ago
parent 83222420f9
commit 407b66bcfc

@ -1,53 +0,0 @@
local _tl_compat; if (tonumber((_VERSION or ''):match('[%d.]*$')) or 0) < 5.3 then local p, m = pcall(require, 'compat53.module'); if p then _tl_compat = m end end; local pcall = _tl_compat and _tl_compat.pcall or pcall; local string = _tl_compat and _tl_compat.string or string; local file = require("pl.file")
local path = require("pl.path")
local teal_available, tl = pcall(require, 'tl')
local rewrite_filename = function(filename)
return filename:match('string "(.+)"') or filename
end
local rewriteMessage = function(_filename, message)
local fname, line, msg = message:match('^([^\n]-):(%d+): (.*)')
if not fname then
return message
end
fname = rewrite_filename(fname)
return fname .. ':' .. tostring(line) .. ': ' .. msg
end
local getTrace = function(_filename, info)
local index = info.traceback:find('\n%s*%[C]')
info.traceback = info.traceback:sub(1, index)
info.short_src = rewrite_filename(info.short_src)
return info
end
local ret = {}
function ret.match(_busted, filename)
return teal_available and path.extension(filename) == '.tl'
end
function ret.load(busted, filename)
local content = file.read(filename)
local program, err = tl.load(content, filename)
if not program then
busted.publish({ 'error', 'file' }, { descriptor = 'file', name = filename }, nil, err, {})
end
return program, getTrace, rewriteMessage
end
return ret
Loading…
Cancel
Save