Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update from upstream #3

Open
wants to merge 46 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
72edf02
Options --sort takes precedence over --shuffle
o-lim May 28, 2016
0dee229
Option --list honors --sort, --shuffle, --suppress-pending
o-lim May 28, 2016
eb6367e
Merge pull request #522 from o-lim/list-shuffle-sort
DorianGray Jun 6, 2016
aa6f4c9
Support running standalone tests from stdin
o-lim May 26, 2016
2734e08
Rename output handler option for runner
o-lim May 27, 2016
1a7bfe6
Merge pull request #521 from o-lim/stdin-compatibility
DorianGray Jun 7, 2016
830f175
Fix testcase time
cjtallman Jun 10, 2016
cd6debf
Merge pull request #525 from cjtallman/junit_testcase_time
DorianGray Jun 14, 2016
4e4df7a
Use '%u' to format unsigned numbers
o-lim Jul 15, 2016
2d92840
Merge pull request #527 from o-lim/fix-format-unsigned-values
DorianGray Jul 16, 2016
ed3f708
Fix failing tests after penlight upgrade
o-lim Aug 29, 2016
8ff1fc9
Forward non-positive arg keys
o-lim Aug 29, 2016
b5060dd
Output error message when test file/dir not found
o-lim Aug 29, 2016
5f10a67
Merge pull request #533 from o-lim/fix-pl-upgrade
DorianGray Aug 29, 2016
b0aa72c
Merge pull request #532 from o-lim/forward-cmdline-args
DorianGray Aug 29, 2016
6a01c53
Merge pull request #531 from o-lim/file-not-found-error
DorianGray Aug 29, 2016
907cd54
add italian language support
haianos Oct 4, 2016
dcd49b0
add it lang rockspec support
haianos Oct 4, 2016
2a9bfe6
Merge pull request #536 from haianos/master
ajacksified Oct 11, 2016
3002020
Make busted capitalization more consistent
Jan 1, 2017
a467dbd
Merge pull request #540 from CrackedP0t/master
ajacksified Jan 3, 2017
f9db364
TAP handler: flush output immediately
justinmk Jul 1, 2017
9abdb19
Merge pull request #554 from justinmk/flush-tap
DorianGray Jul 11, 2017
db6d8b4
fix LuaJIT segfaults due to ffi reloading
Tieske Jul 17, 2017
997514a
Merge pull request #555 from Tieske/fix/luajit
DorianGray Jul 17, 2017
6367736
fix(cli) fail if LuaCov is specified but unavailable
Tieske Jul 16, 2018
10f3fff
Merge pull request #577 from Tieske/luacov-mandatory
ajacksified Jul 20, 2018
a3c62fe
Release 2.0.rc13-0
ajacksified Sep 24, 2018
fd939b7
allow parameters when testing busted itself
Tieske Dec 6, 2018
85daab6
move rockspecs into separate directory
Tieske Dec 6, 2018
a98e43e
Merge pull request #582 from Tieske/params-test
ajacksified Dec 13, 2018
c8eefae
Fix typo in cli option processing for config-file
notCalle Feb 3, 2019
452b763
Allow ROOT to contain hidden directories.
LiamLeFey Jun 2, 2019
72cad53
Added test case.
LiamLeFey Jun 3, 2019
ff73042
Cache io to be robust about mocking io in tests
mkpankov Jun 24, 2019
9d49231
fix: properly error out on bad config files
Tieske Jun 24, 2019
d4759b4
Merge pull request #600 from Tieske/config
ajacksified Jun 28, 2019
dc99249
Merge pull request #599 from mkpankov/cache-io
ajacksified Jun 28, 2019
779ecc4
Merge pull request #594 from LiamLeFey/allow-explicit-hidden-dir
ajacksified Jun 28, 2019
acbcc29
Merge pull request #587 from notCalle/fix-cli-option-config-file
ajacksified Jun 28, 2019
1f19347
v2.0.0; luassert 1.8
ajacksified Jun 28, 2019
bf3405c
fix(rockspecs) proper usage of rockspec revision numbers
Tieske Jul 1, 2019
7ee7110
Merge pull request #603 from Tieske/rockspecs
ajacksified Jul 1, 2019
045d088
fix(ci) do not specify a rockspec, just build the only one there
Tieske Jul 1, 2019
8bbf64d
Merge pull request #604 from Tieske/fixci
ajacksified Jul 1, 2019
8d4cfeb
Merge remote-tracking branch 'upstream/master'
Nov 26, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ before_install:
- luarocks install moonscript

install:
- luarocks make busted-scm-0.rockspec
- luarocks make

script: busted

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Busted
busted
======

[![Join the chat at https://gitter.im/Olivine-Labs/busted](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Olivine-Labs/busted?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
Expand Down
18 changes: 10 additions & 8 deletions busted-scm-0.rockspec → busted-scm-1.rockspec
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package = 'busted'
version = 'scm-0'
version = 'scm-1'
source = {
url = "git://github.com/Olivine-Labs/busted",
branch = "master"
Expand All @@ -19,15 +19,15 @@ description = {
}
dependencies = {
'lua >= 5.1',
'lua_cliargs = 3.0-1',
'lua_cliargs = 3.0',
'luafilesystem >= 1.5.0',
'luasystem >= 0.2.0-0',
'luasystem >= 0.2.0',
'dkjson >= 2.1.0',
'say >= 1.3-0',
'luassert >= 1.7.8-0',
'lua-term >= 0.1-1',
'penlight >= 1.3.2-2',
'mediator_lua >= 1.1.1-0',
'say >= 1.3',
'luassert >= 1.7.8',
'lua-term >= 0.1',
'penlight >= 1.3.2',
'mediator_lua >= 1.1.1',
}

build = {
Expand All @@ -49,6 +49,7 @@ build = {

['busted.modules.configuration_loader'] = 'busted/modules/configuration_loader.lua',
['busted.modules.luacov'] = 'busted/modules/luacov.lua',
['busted.modules.standalone_loader'] = 'busted/modules/standalone_loader.lua',
['busted.modules.test_file_loader'] = 'busted/modules/test_file_loader.lua',
['busted.modules.output_handler_loader'] = 'busted/modules/output_handler_loader.lua',
['busted.modules.helper_loader'] = 'busted/modules/helper_loader.lua',
Expand Down Expand Up @@ -79,6 +80,7 @@ build = {
['busted.languages.th'] = 'busted/languages/th.lua',
['busted.languages.ua'] = 'busted/languages/ua.lua',
['busted.languages.zh'] = 'busted/languages/zh.lua',
['busted.languages.it'] = 'busted/languages/it.lua',
},
install = {
bin = {
Expand Down
6 changes: 3 additions & 3 deletions busted/block.lua
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,11 @@ return function(busted)
end

if busted.safe(descriptor, element.run, element):success() then
if randomize then
if busted.sort then
sort(busted.context.children(element))
elseif randomize then
element.randomseed = randomseed
shuffle(busted.context.children(element), randomseed)
elseif busted.sort then
sort(busted.context.children(element))
end

if block.setup(element) then
Expand Down
4 changes: 2 additions & 2 deletions busted/compatibility.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ return {
loadstring = loadstring or load,
unpack = table.unpack or unpack,

exit = function(code)
if code ~= 0 and _VERSION:match('^Lua 5%.[12]$') then
exit = function(code, force)
if not force and code ~= 0 and _VERSION:match('^Lua 5%.[12]$') then
error()
elseif code ~= 0 then
code = 1
Expand Down
2 changes: 1 addition & 1 deletion busted/core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ return function()
local mediator = require 'mediator'()

local busted = {}
busted.version = '2.0.rc12-0'
busted.version = '2.0.0-0'

local root = require 'busted.context'()
busted.context = root.ref()
Expand Down
6 changes: 3 additions & 3 deletions busted/execute.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ return function(busted)
busted.safe_publish('suite', { 'suite', 'reset' }, root, i, runs)
end

if options.shuffle then
if options.sort then
sort(busted.context.children(root))
elseif options.shuffle then
root.randomseed = busted.randomseed
shuffle(busted.context.children(root), busted.randomseed)
elseif options.sort then
sort(busted.context.children(root))
end

local seed = (busted.randomize and busted.randomseed or nil)
Expand Down
1 change: 1 addition & 0 deletions busted/languages/en.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ s:set('output.success_single', 'success')
s:set('output.seconds', 'seconds')

s:set('output.no_test_files_match', 'No test files found matching Lua pattern: %s')
s:set('output.file_not_found', 'Cannot find file or directory: %s')

-- definitions following are not used within the 'say' namespace
return {
Expand Down
50 changes: 50 additions & 0 deletions busted/languages/it.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
local s = require('say')

s:set_namespace('it')

-- 'Pending: test.lua @ 12 \n description
s:set('output.pending', 'In attesa')
s:set('output.failure', 'Fallimento')
s:set('output.error', 'Errore')
s:set('output.success', 'Successo')

s:set('output.pending_plural', 'in attesa')
s:set('output.failure_plural', 'fallimenti')
s:set('output.error_plural', 'errori')
s:set('output.success_plural', 'successi')

s:set('output.pending_zero', 'in attesa')
s:set('output.failure_zero', 'fallimenti')
s:set('output.error_zero', 'errori')
s:set('output.success_zero', 'successi')

s:set('output.pending_single', 'in attesa')
s:set('output.failure_single', 'fallimento')
s:set('output.error_single', 'errore')
s:set('output.success_single', 'successo')

s:set('output.seconds', 'secondi')

s:set('output.no_test_files_match', 'Nessun file di test trovat che corrisponde al pattern Lua: %s')
s:set('output.file_not_found', 'Nessun file o cartella trovato: %s')

-- definitions following are not used within the 'say' namespace
return {
failure_messages = {
"Hai %d specifiche non conformi",
"Le tue specifiche non sono conformi",
"Il tuo codice fa schifo e dovresti sentirti male per questo",
"Il tuo codice è in pericolo",
"Strano. Il solo modo per terminare con successo i tuoi test è fare nessun test",
"Mia nonna ha scritto migliori specifiche su un 3 86",
"Ogni volta che trovi un errore, bevi un'altra birra",
"I fallimenti fanno male alla salute"
},
success_messages = {
"Ma andiamo! Specifiche Ok!",
"Non importa, avevi le specifiche",
"Bella zio",
"Gran successo",
"Test passato, hai vinto una birra"
}
}
41 changes: 29 additions & 12 deletions busted/modules/cli.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ return function(options)
local configLoader = require 'busted.modules.configuration_loader'()

-- Default cli arg values
local defaultOutput = options.defaultOutput
local defaultOutput = options.output or 'utfTerminal'
local defaultLoaders = 'lua,moonscript'
local defaultPattern = '_spec'
local defaultSeed = '/dev/urandom or os.time()'
Expand Down Expand Up @@ -124,7 +124,7 @@ return function(options)
cli:option('-e STATEMENT', 'execute statement STATEMENT', nil, processMultiOption)
cli:option('-o, --output=LIBRARY', 'output library to load', defaultOutput, processOption)
cli:option('-C, --directory=DIR', 'change to directory DIR before running tests. If multiple options are specified, each is interpreted relative to the previous one.', './', processDir)
cli:option('-f, --config-file=FILE', 'load configuration options from FILE', nil, processOptions)
cli:option('-f, --config-file=FILE', 'load configuration options from FILE', nil, processOption)
cli:option('-t, --tags=TAGS', 'only run tests with these #tags', {}, processList)
cli:option('--exclude-tags=TAGS', 'do not run tests with these #tags, takes precedence over --tags', {}, processList)
cli:option('--filter=PATTERN', 'only run test names matching the Lua pattern', {}, processMultiOption)
Expand Down Expand Up @@ -168,17 +168,34 @@ return function(options)
end

-- Load busted config file if available
local bustedConfigFilePath = cliArgs.f or path.normpath(path.join(cliArgs.directory, '.busted'))
local bustedConfigFile = loadfile(bustedConfigFilePath)
if bustedConfigFile then
local ok, config = pcall(function()
local conf, err = configLoader(bustedConfigFile(), cliArgsParsed, cliArgs)
return conf or error(err, 0)
end)
if not ok then
return nil, appName .. ': error: ' .. config
local bustedConfigFilePath
if cliArgs.f then
-- if the file is given, then we require it to exist
if not path.isfile(cliArgs.f) then
return nil, ("specified config file '%s' not found"):format(cliArgs.f)
end
bustedConfigFilePath = cliArgs.f
else
-- try default file
bustedConfigFilePath = path.normpath(path.join(cliArgs.directory, '.busted'))
if not path.isfile(bustedConfigFilePath) then
bustedConfigFilePath = nil -- clear default file, since it doesn't exist
end
end
if bustedConfigFilePath then
local bustedConfigFile, err = loadfile(bustedConfigFilePath)
if not bustedConfigFile then
return nil, ("failed loading config file `%s`: %s"):format(bustedConfigFilePath, err)
else
cliArgs = config
local ok, config = pcall(function()
local conf, err = configLoader(bustedConfigFile(), cliArgsParsed, cliArgs)
return conf or error(err, 0)
end)
if not ok then
return nil, appName .. ': error: ' .. config
else
cliArgs = config
end
end
else
cliArgs = tablex.merge(cliArgs, cliArgsParsed, true)
Expand Down
2 changes: 1 addition & 1 deletion busted/modules/configuration_loader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ return function()
return nil, '.busted file does not return a table.'
end

local defaults = defaults or {}
defaults = defaults or {}
local run = config.run or defaults.run

if run and run ~= '' then
Expand Down
44 changes: 35 additions & 9 deletions busted/modules/filter_loader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,13 @@ return function()
return nil, (#options.filter == 0)
end

local printNameOnly = function(name, fn, trace)
local fullname = getFullName(name)
if trace and trace.what == 'Lua' then
print(trace.short_src .. ':' .. trace.currentline .. ': ' .. fullname)
else
local printTestName = function(element, parent, status)
if not (options.suppressPending and status == 'pending') then
local fullname = getFullName()
local trace = element.trace
if trace and trace.what == 'Lua' then
fullname = trace.short_src .. ':' .. trace.currentline .. ': ' .. fullname
end
print(fullname)
end
return nil, false
Expand All @@ -69,6 +71,15 @@ return function()
return nil, false
end

local noop = function() end
local stubOut = function(descriptor, name, fn, ...)
if fn == noop then
return nil, true
end
busted.publish({ 'register', descriptor }, name, noop, ...)
return nil, false
end

local skipOnError = function()
return nil, not busted.skipAll
end
Expand All @@ -81,13 +92,28 @@ return function()
end
end

local applyDescFilter = function(descriptors, name, fn)
if options[name] and options[name] ~= '' then
for _, descriptor in ipairs(descriptors) do
local f = function(...) return fn(descriptor, ...) end
busted.subscribe({ 'register', descriptor }, f, { priority = 1 })
end
end
end

if options.list then
busted.subscribe({ 'suite', 'start' }, ignoreAll, { priority = 1 })
busted.subscribe({ 'suite', 'end' }, ignoreAll, { priority = 1 })
applyFilter({ 'setup', 'teardown', 'before_each', 'after_each' }, 'list', ignoreAll)
applyFilter({ 'lazy_setup', 'lazy_teardown' }, 'list', ignoreAll)
applyFilter({ 'strict_setup', 'strict_teardown' }, 'list', ignoreAll)
applyFilter({ 'it', 'pending' }, 'list', printNameOnly)
busted.subscribe({ 'file', 'start' }, ignoreAll, { priority = 1 })
busted.subscribe({ 'file', 'end' }, ignoreAll, { priority = 1 })
busted.subscribe({ 'describe', 'start' }, ignoreAll, { priority = 1 })
busted.subscribe({ 'describe', 'end' }, ignoreAll, { priority = 1 })
busted.subscribe({ 'test', 'start' }, ignoreAll, { priority = 1 })
busted.subscribe({ 'test', 'end' }, printTestName, { priority = 1 })
applyDescFilter({ 'setup', 'teardown', 'before_each', 'after_each' }, 'list', stubOut)
applyDescFilter({ 'lazy_setup', 'lazy_teardown' }, 'list', stubOut)
applyDescFilter({ 'strict_setup', 'strict_teardown' }, 'list', stubOut)
applyDescFilter({ 'it', 'pending' }, 'list', stubOut)
end

applyFilter({ 'lazy_setup', 'lazy_teardown' }, 'nokeepgoing', skipOnError)
Expand Down
6 changes: 4 additions & 2 deletions busted/modules/helper_loader.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
local path = require 'pl.path'
local hasMoon, moonscript = pcall(require, 'moonscript')
local utils = require 'busted.utils'

return function()
local loadHelper = function(busted, helper, options)
local old_arg = arg
local old_arg = _G.arg
local success, err = pcall(function()
arg = options.arguments
utils.copy_interpreter_args(options.arguments)
_G.arg = options.arguments
if helper:match('%.lua$') then
dofile(path.normpath(helper))
elseif hasMoon and helper:match('%.moon$') then
Expand Down
3 changes: 2 additions & 1 deletion busted/modules/luacov.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ return function()
local result, luacov = pcall(require, 'luacov.runner')

if not result then
return print('LuaCov not found on the system, try running without --coverage option, or install LuaCov first')
return nil, 'LuaCov not found on the system, try running without --coverage option, or install LuaCov first'
end

-- call it to start
Expand All @@ -16,6 +16,7 @@ return function()
table.insert(luacov.configuration.exclude, 'luassert%.')
table.insert(luacov.configuration.exclude, 'say%.')
table.insert(luacov.configuration.exclude, 'pl%.')
return true
end

return loadLuaCov
Expand Down
2 changes: 2 additions & 0 deletions busted/modules/output_handler_loader.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
local path = require 'pl.path'
local hasMoon, moonscript = pcall(require, 'moonscript')
local utils = require 'busted.utils'

return function()
local loadOutputHandler = function(busted, output, options)
local handlers = {}

utils.copy_interpreter_args(options.arguments)
local success, err = pcall(function()
for word in output:gmatch("%a+") do
if word:match('%.lua$') then
Expand Down
28 changes: 28 additions & 0 deletions busted/modules/standalone_loader.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,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
Loading