/usr/share/lua/5.1/busted/init.lua is in lua-busted 2.0~rc12-1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | local function init(busted)
local block = require 'busted.block'(busted)
local file = function(file)
busted.wrap(file.run)
if busted.safe_publish('file', { 'file', 'start' }, file) then
block.execute('file', file)
end
busted.safe_publish('file', { 'file', 'end' }, file)
end
local describe = function(describe)
local parent = busted.context.parent(describe)
if busted.safe_publish('describe', { 'describe', 'start' }, describe, parent) then
block.execute('describe', describe)
end
busted.safe_publish('describe', { 'describe', 'end' }, describe, parent)
end
local it = function(element)
local parent = busted.context.parent(element)
local finally
if not block.lazySetup(parent) then
-- skip test if any setup failed
return
end
if not element.env then element.env = {} end
block.rejectAll(element)
element.env.finally = function(fn) finally = fn end
element.env.pending = busted.pending
local pass, ancestor = block.execAll('before_each', parent, true)
if pass then
local status = busted.status('success')
if busted.safe_publish('test', { 'test', 'start' }, element, parent) then
status:update(busted.safe('it', element.run, element))
if finally then
block.reject('pending', element)
status:update(busted.safe('finally', finally, element))
end
else
status = busted.status('error')
end
busted.safe_publish('test', { 'test', 'end' }, element, parent, tostring(status))
end
block.dexecAll('after_each', ancestor, true)
end
local pending = function(element)
local parent = busted.context.parent(element)
local status = 'pending'
if not busted.safe_publish('it', { 'test', 'start' }, element, parent) then
status = 'error'
end
busted.safe_publish('it', { 'test', 'end' }, element, parent, status)
end
busted.register('file', file, { envmode = 'insulate' })
busted.register('describe', describe)
busted.register('insulate', 'describe', { envmode = 'insulate' })
busted.register('expose', 'describe', { envmode = 'expose' })
busted.register('it', it)
busted.register('pending', pending)
busted.register('before_each', { envmode = 'unwrap' })
busted.register('after_each', { envmode = 'unwrap' })
busted.register('lazy_setup', { envmode = 'unwrap' })
busted.register('lazy_teardown', { envmode = 'unwrap' })
busted.register('strict_setup', { envmode = 'unwrap' })
busted.register('strict_teardown', { envmode = 'unwrap' })
busted.register('setup', 'strict_setup')
busted.register('teardown', 'strict_teardown')
busted.register('context', 'describe')
busted.register('spec', 'it')
busted.register('test', 'it')
busted.hide('file')
local assert = require 'luassert'
local spy = require 'luassert.spy'
local mock = require 'luassert.mock'
local stub = require 'luassert.stub'
local match = require 'luassert.match'
busted.export('assert', assert)
busted.export('spy', spy)
busted.export('mock', mock)
busted.export('stub', stub)
busted.export('match', match)
busted.exportApi('publish', busted.publish)
busted.exportApi('subscribe', busted.subscribe)
busted.exportApi('unsubscribe', busted.unsubscribe)
busted.exportApi('bindfenv', busted.bindfenv)
busted.exportApi('fail', busted.fail)
busted.exportApi('gettime', busted.gettime)
busted.exportApi('monotime', busted.monotime)
busted.exportApi('sleep', busted.sleep)
busted.exportApi('parent', busted.context.parent)
busted.exportApi('children', busted.context.children)
busted.exportApi('version', busted.version)
busted.bindfenv(assert, 'error', busted.fail)
busted.bindfenv(assert.is_true, 'error', busted.fail)
return busted
end
return setmetatable({}, {
__call = function(self, busted)
init(busted)
return setmetatable(self, {
__index = function(self, key)
return busted.api[key]
end,
__newindex = function(self, key, value)
error('Attempt to modify busted')
end
})
end
})
|