From c75bc4beb9d6b659dec58ff5991fdcb6f0078809 Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Sat, 26 Dec 2020 10:23:39 +0100 Subject: [PATCH 01/32] chore(readme) fix bad example fixes comment https://github.com/Olivine-Labs/busted/commit/8ff2ce96b5048f91984f7524d6021171b1e5fdc8#r45400286 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 85cd8de1..8ed3d5c8 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Check out the [official docs](http://olivinelabs.com/busted) for extended info. busted test specs read naturally without being too verbose. You can even -chain asserts and negations, such as `assert.not.equals`. Nest blocks of +chain asserts and negations, such as `assert.is_not.equal`. Nest blocks of tests with contextual descriptions using `describe`, and add tags to blocks so you can run arbitrary groups of tests. From 2e4799e06b865c352baa7f7721e32aedaafd19d6 Mon Sep 17 00:00:00 2001 From: Nicholas Omer Chiasson Date: Mon, 15 Mar 2021 13:49:56 -0400 Subject: [PATCH 02/32] conf(cli) add support for luacov config path (#660) adds new option `--coverage-config-file=FILE` --- .github/workflows/busted.yml | 1 + .gitignore | 1 + busted/modules/cli.lua | 1 + busted/modules/luacov.lua | 4 +-- busted/runner.lua | 2 +- spec/.hidden/.luacov | 52 ++++++++++++++++++++++++++++++++++++ spec/cl_spec.lua | 15 +++++++++++ spec/modules/cli_spec.lua | 3 +++ 8 files changed, 76 insertions(+), 3 deletions(-) create mode 100644 spec/.hidden/.luacov diff --git a/.github/workflows/busted.yml b/.github/workflows/busted.yml index 7eaad912..25d7d86b 100644 --- a/.github/workflows/busted.yml +++ b/.github/workflows/busted.yml @@ -29,6 +29,7 @@ jobs: luarocks install moonscript luarocks install copas luarocks install lua-ev + luarocks install luacov - name: Cache Lua machinery uses: actions/cache@v2 with: diff --git a/.gitignore b/.gitignore index 945fd724..e4cce8aa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.swp /luacov.report.out +/.ignore* diff --git a/busted/modules/cli.lua b/busted/modules/cli.lua index dba2938f..b60b9087 100644 --- a/busted/modules/cli.lua +++ b/busted/modules/cli.lua @@ -125,6 +125,7 @@ return function(options) 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, processOption) + cli:option('--coverage-config-file=FILE', 'load luacov 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) diff --git a/busted/modules/luacov.lua b/busted/modules/luacov.lua index 51a9ad33..c26be480 100644 --- a/busted/modules/luacov.lua +++ b/busted/modules/luacov.lua @@ -1,6 +1,6 @@ return function() -- Function to initialize luacov if available - local loadLuaCov = function() + local loadLuaCov = function(config) local result, luacov = pcall(require, 'luacov.runner') if not result then @@ -8,7 +8,7 @@ return function() end -- call it to start - luacov() + luacov(config) -- exclude busted files table.insert(luacov.configuration.exclude, 'busted_bootstrap$') diff --git a/busted/runner.lua b/busted/runner.lua index 274a3c39..eb81bca1 100644 --- a/busted/runner.lua +++ b/busted/runner.lua @@ -56,7 +56,7 @@ return function(options) -- If coverage arg is passed in, load LuaCovsupport if cliArgs.coverage then - local ok, err = luacov() + local ok, err = luacov(cliArgs['coverage-config-file']) if not ok then io.stderr:write(appName .. ': error: ' .. err .. '\n') exit(1, forceExit) diff --git a/spec/.hidden/.luacov b/spec/.hidden/.luacov new file mode 100644 index 00000000..3b2b8889 --- /dev/null +++ b/spec/.hidden/.luacov @@ -0,0 +1,52 @@ +--- Global configuration file. Copy, customize and store in your +-- project folder as '.luacov' for project specific configuration +-- @class module +-- @name luacov.defaults +return { + + -- default filename to load for config options if not provided + -- only has effect in 'luacov.defaults.lua' + ['configfile'] = '.luacov', + + -- filename to store stats collected + ['statsfile'] = '.ignore.luacov.stats.out', + + -- filename to store report + ['reportfile'] = '.ignore.luacov.report.out', + + -- Run reporter on completion? (won't work for ticks) + runreport = true, + + -- Delete stats file after reporting? + deletestats = true, + + -- Patterns for files to include when reporting + -- all will be included if nothing is listed + -- (exclude overrules include, do not include + -- the .lua extension) + ['include'] = { + }, + + -- Patterns for files to exclude when reporting + -- all will be included if nothing is listed + -- (exclude overrules include, do not include + -- the .lua extension) + ['exclude'] = { + 'luacov$', + 'luacov.reporter$', + 'luacov.defaults$', + 'luacov.runner$', + 'luacov.stats$', + 'luacov.tick$', + 'term$', + 'term.colors$', + 'term.cursor$', + 'term.init$', + 'copas$', + 'coxpcall$', + 'mediator$', + 'moonscript.*$', + }, + + +} diff --git a/spec/cl_spec.lua b/spec/cl_spec.lua index c9377857..d482bac0 100644 --- a/spec/cl_spec.lua +++ b/spec/cl_spec.lua @@ -1,4 +1,5 @@ local utils = require 'pl.utils' +local file = require 'pl.file' local path = require 'pl.path' local normpath = path.normpath local busted_cmd = path.is_windows and 'lua bin/busted' or 'bin/busted' @@ -257,6 +258,20 @@ describe('Tests the busted command-line options', function() assert.is_equal(0, errcnt) assert.equal('bin/busted --ignore-lua --lua=' .. lua_exe .. ' spec/cl_success.lua\n', out) end) + + it('tests running a configfile for luacov', function() + local custom_config = normpath('spec/.hidden/.luacov') + local custom_report = normpath('.ignore.luacov.report.out') + local success, errcnt = executeBusted('--coverage-config-file=' .. custom_config .. ' spec/cl_success.lua') + assert.is_true(success) + assert.is_equal(0, errcnt) + assert.is_false(path.isfile(custom_report)) + success, errcnt = executeBusted('--coverage --coverage-config-file=' .. custom_config .. ' spec/cl_success.lua') + assert.is_true(success) + assert.is_equal(0, errcnt) + assert.is_true(path.isfile(custom_report)) + file.delete(custom_report) + end) end) describe('Tests failing tests through the commandline', function() diff --git a/spec/modules/cli_spec.lua b/spec/modules/cli_spec.lua index 13715363..20a2b9af 100644 --- a/spec/modules/cli_spec.lua +++ b/spec/modules/cli_spec.lua @@ -38,6 +38,7 @@ describe('Tests command-line interface', function() assert.is_false(args['defer-print']) assert.is_nil(args.f) assert.is_nil(args['config-file']) + assert.is_nil(args['coverage-config-file']) assert.is_nil(args.shuffle) assert.is_nil(args['shuffle-files']) assert.is_nil(args['shuffle-tests']) @@ -362,6 +363,7 @@ describe('Tests using .busted tasks', function() assert.is_false(args['defer-print']) assert.is_nil(args.f) assert.is_nil(args['config-file']) + assert.is_nil(args['coverage-config-file']) assert.is_nil(args.shuffle) assert.is_nil(args['shuffle-files']) assert.is_nil(args['shuffle-tests']) @@ -421,6 +423,7 @@ describe('Tests using .busted tasks', function() assert.is_false(args['enable-sound']) assert.is_false(args['suppress-pending']) assert.is_false(args['defer-print']) + assert.is_nil(args['coverage-config-file']) assert.is_nil(args.shuffle) assert.is_nil(args['shuffle-files']) assert.is_nil(args['shuffle-tests']) From 5b1f99d9311aabc62f17fdef7ab47729e4995b4d Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Thu, 25 Mar 2021 17:56:16 +0100 Subject: [PATCH 03/32] feat(fixtures) add helpers to read/load fixtures Also moves the fixture_path function from a global to the 'fixtures' module. This is non-breaking since that hasn't been released yet. --- busted/fixtures.lua | 96 +++++++++++++++++++++++++----- busted/init.lua | 3 +- spec/.hidden/dont_execute_spec.lua | 1 - spec/.hidden/some_file.lua | 1 + spec/fixtures_spec.lua | 74 ++++++++++++++++++++++- 5 files changed, 154 insertions(+), 21 deletions(-) create mode 100644 spec/.hidden/some_file.lua diff --git a/busted/fixtures.lua b/busted/fixtures.lua index 57a6381e..469c0394 100644 --- a/busted/fixtures.lua +++ b/busted/fixtures.lua @@ -1,17 +1,83 @@ local pl_path = require 'pl.path' +local pl_utils = require 'pl.utils' -return { - -- returns an absolute path to where the current test file is located. - -- @param sub_path [optional] a relative path to a file to be appended - fixture_path = function(sub_path) - local info = debug.getinfo(2) - local path = info.source - if path:sub(1,1) == "@" then - path = path:sub(2, -1) - end - path = pl_path.abspath(path) -- based on PWD - path = pl_path.splitpath(path) -- drop filename, keep path only - path = pl_path.join(path, sub_path) - return pl_path.normpath(path, sub_path) - end, -} +local fixtures = {} + +-- returns an absolute path to where the current test file is located. +-- @param sub_path [optional] a relative path to, to be appended +-- @return returns the (normalized) absolute path +function fixtures.path(sub_path) + if type(sub_path) ~= "string" and type(sub_path) ~= "nil" then + error("bad argument to 'path' expected a string (relative filename) or nil, got: " .. type(sub_path), 2) + end + + local info = debug.getinfo(1) + local myname = info.source -- path to this code file + + local path + local level = 1 + repeat + -- other functions in this module call this one as well, so traverse up the + -- stack until we find the first call from outside this module, that's + -- the file to use as a baseline for our relative search + level = level + 1 + info = debug.getinfo(level) + path = info.source + until path ~= myname + + if path:sub(1,1) == "@" then + path = path:sub(2, -1) + end + path = pl_path.abspath(path) -- based on PWD + path = pl_path.splitpath(path) -- drop filename, keep path only + path = pl_path.join(path, sub_path) + return pl_path.normpath(path, sub_path) +end + + +-- reads a file relative from the current test file. +-- @param rel_path (string) the relative path to the file +-- @param is_bin (boolean) whether to load the file as a binary file +-- @return returns the file contents or errors on failure +function fixtures.read(rel_path, is_bin) + if type(rel_path) ~= "string" then + error("bad argument to 'read' expected a string (relative filename), got: " .. type(rel_path), 2) + end + + local fname = fixtures.path(rel_path) + + local contents, err = pl_utils.readfile(fname, is_bin) + if not contents then + error(("Error reading file '%s': %s"):format(tostring(fname), tostring(err)), 2) + end + + return contents +end + + +-- loads (and executes) a Lua-file relative from the current test file. +-- @param rel_path (string) the relative path to the file +-- @return returns the results of the executed file (similar to a module) +function fixtures.load(rel_path) + if type(rel_path) ~= "string" then + error("bad argument to 'load' expected a string (relative filename), got: " .. type(rel_path), 2) + end + local extension = "lua" + if not rel_path:match("%."..extension.."$") then + rel_path = rel_path .. "." .. extension + end + local code, err = fixtures.read(rel_path) + if not code then + error(("Error loading file '%s': %s"):format(tostring(rel_path), tostring(err)), 2) + end + + local func, err = loadstring(code, rel_path) + if not func then + error(("Error loading code from '%s': %s"):format(tostring(rel_path), tostring(err)), 2) + end + + return func() +end + + +return fixtures diff --git a/busted/init.lua b/busted/init.lua index 5092960c..01d6d4a5 100644 --- a/busted/init.lua +++ b/busted/init.lua @@ -93,14 +93,13 @@ local function init(busted) local stub = require 'luassert.stub' local match = require 'luassert.match' - local fixture_path = require('busted.fixtures').fixture_path + require 'busted.fixtures' -- just load into the environment, not exposing it busted.export('assert', assert) busted.export('spy', spy) busted.export('mock', mock) busted.export('stub', stub) busted.export('match', match) - busted.export('fixture_path', fixture_path) busted.exportApi('publish', busted.publish) busted.exportApi('subscribe', busted.subscribe) diff --git a/spec/.hidden/dont_execute_spec.lua b/spec/.hidden/dont_execute_spec.lua index c13027c9..4047dd5b 100644 --- a/spec/.hidden/dont_execute_spec.lua +++ b/spec/.hidden/dont_execute_spec.lua @@ -1,2 +1 @@ assert(false,'should not be executed') - diff --git a/spec/.hidden/some_file.lua b/spec/.hidden/some_file.lua new file mode 100644 index 00000000..05c334d1 --- /dev/null +++ b/spec/.hidden/some_file.lua @@ -0,0 +1 @@ +return "hello world" diff --git a/spec/fixtures_spec.lua b/spec/fixtures_spec.lua index 60a4c222..a42f149f 100644 --- a/spec/fixtures_spec.lua +++ b/spec/fixtures_spec.lua @@ -1,18 +1,86 @@ +local fixtures = require 'busted.fixtures' + describe("fixtures:", function() - describe("fixture_path()", function() + describe("path()", function() it("returns the absolute fixture path", function() - local path = fixture_path("fixtures/myfile.txt") -- luacheck: ignore + local path = fixtures.path("fixtures/myfile.txt") assert.match("^.-busted[/\\]spec[/\\]fixtures[/\\]myfile.txt$", path) end) it("returns the absolute fixture path normalized", function() - local path = fixture_path("../fixtures/myfile.txt") -- luacheck: ignore + local path = fixtures.path("../fixtures/myfile.txt") assert.match("^.-busted[/\\]fixtures[/\\]myfile.txt$", path) end) + it("errors on bad input", function() + assert.has.error(function() + fixtures.path(123) -- pass in a number + end, "bad argument to 'path' expected a string (relative filename) or nil, got: number") + end) + end) + + + describe("read()", function() + + it("returns the contents of a file", function() + local contents, err = fixtures.read("../spec/.hidden/dont_execute_spec.lua") + assert.is_nil(err) + assert.equal("assert(false,'should not be executed')\n", contents) + end) + + it("errors on bad input", function() + assert.has.error(function() + fixtures.read(123) -- pass in a number + end, "bad argument to 'read' expected a string (relative filename), got: number") + end) + + it("errors on read failure", function() + assert.has.error(function() + fixtures.read("./doesnt/really/exist") + end) + end) + + end) + + + describe("load()", function() + + it("returns the executed contents of a lua file", function() + local contents, err = fixtures.load("../spec/.hidden/some_file.lua") + assert.is_nil(err) + assert.equal("hello world", contents) + end) + + it("returns the executed contents of a lua file, without specifying the extension", function() + local contents, err = fixtures.load("../spec/.hidden/some_file") + assert.is_nil(err) + assert.equal("hello world", contents) + end) + + it("errors on bad input", function() + assert.has.error(function() + fixtures.load(123) -- pass in a number + end, "bad argument to 'load' expected a string (relative filename), got: number") + end) + + it("errors on read failure", function() + assert.has.error(function() + fixtures.load("./doesnt/really/exist") + end) + end) + + it("errors on compile failure", function() + assert.has.error(function() + fixtures.load("./cl_compile_fail.lua") + end) + end) + + end) + + end) From 86ccf71f4d66195b5570f0b20d1b8393620f6b5d Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Thu, 25 Mar 2021 18:39:24 +0100 Subject: [PATCH 04/32] add Lua 5.2+ compat (load instead of loadstring) --- busted/fixtures.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/busted/fixtures.lua b/busted/fixtures.lua index 469c0394..62003e53 100644 --- a/busted/fixtures.lua +++ b/busted/fixtures.lua @@ -71,7 +71,7 @@ function fixtures.load(rel_path) error(("Error loading file '%s': %s"):format(tostring(rel_path), tostring(err)), 2) end - local func, err = loadstring(code, rel_path) + local func, err = (loadstring or load)(code, rel_path) if not func then error(("Error loading code from '%s': %s"):format(tostring(rel_path), tostring(err)), 2) end From cceb81b25d9f3daf7cb97dc1b630df8a8f72302d Mon Sep 17 00:00:00 2001 From: Henrik Ilgen Date: Tue, 7 Sep 2021 23:22:09 +0200 Subject: [PATCH 05/32] Issue 666: restore globals set to nil in insulate block (#667) Co-authored-by: Henrik Ilgen --- busted/context.lua | 6 ++++++ spec/insulate-expose_spec.lua | 28 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/busted/context.lua b/busted/context.lua index 2a8bc6b9..a93a903a 100644 --- a/busted/context.lua +++ b/busted/context.lua @@ -17,6 +17,12 @@ local function restore(state) for k,_ in next, _G, nil do rawset(_G, k, state.g[k]) end + for k, v in next, state.g, nil do + -- reset globals that were set to nil during the insulation block + if rawget(_G, k) == nil then + rawset(_G, k, v) + end + end for k,_ in pairs(package.loaded) do package.loaded[k] = state.loaded[k] end diff --git a/spec/insulate-expose_spec.lua b/spec/insulate-expose_spec.lua index bba84bd6..4c78e576 100644 --- a/spec/insulate-expose_spec.lua +++ b/spec/insulate-expose_spec.lua @@ -34,6 +34,34 @@ describe('Tests insulation', function() end) end) +insulate('Tests insulation with values set to nil', function() + -- The tests in this block need to be run in order, as we're testing state recovery between tests. + + _G.some_global = true + + describe('environment before insulate', function() + it('has global', function() + assert.is_not_nil(some_global) + assert.is_not_nil(_G.some_global) + end) + end) + + insulate('environment inside insulate', function() + it('sets global to nil', function() + _G.some_global = nil + assert.is_nil(some_global) + assert.is_nil(_G.some_global) + end) + end) + + describe('environment after insulate', function() + it('has restored the global', function() + assert.is_not_nil(some_global) + assert.is_not_nil(_G.some_global) + end) + end) +end) + insulate('', function() describe('Tests expose', function() insulate('inside insulate block', function() From 6fe48ce2bb27b20474a5607739b488ffdf40b8a5 Mon Sep 17 00:00:00 2001 From: 1337M0nst3r Date: Tue, 11 Jan 2022 13:32:13 +0200 Subject: [PATCH 06/32] add romanian translation --- busted/languages/ro.lua | 50 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 busted/languages/ro.lua diff --git a/busted/languages/ro.lua b/busted/languages/ro.lua new file mode 100644 index 00000000..6e1550f4 --- /dev/null +++ b/busted/languages/ro.lua @@ -0,0 +1,50 @@ +local s = require('say') + +s:set_namespace('ro') + +-- 'Pending: test.lua @ 12 \n description +s:set('output.pending', 'În așteptare') +s:set('output.failure', 'Eșec') +s:set('output.error', 'Eroare') +s:set('output.success', 'Succes') + +s:set('output.pending_plural', 'în așteptare') +s:set('output.failure_plural', 'eșecuri') +s:set('output.error_plural', 'erori') +s:set('output.success_plural', 'succese') + +s:set('output.pending_zero', 'în așteptare') +s:set('output.failure_zero', 'eșecuri') +s:set('output.error_zero', 'erori') +s:set('output.success_zero', 'succese') + +s:set('output.pending_single', 'în așteptare') +s:set('output.failure_single', 'eșec') +s:set('output.error_single', 'eroare') +s:set('output.success_single', 'succes') + +s:set('output.seconds', 'secunde') + +s:set('output.no_test_files_match', 'Niciun fișier de testare găsit care să se potrivească cu tiparul Lua: %s') +s:set('output.file_not_found', 'Nu pot găsi fișierul sau folderul: %s') + +-- definitions following are not used within the 'say' namespace +return { + failure_messages = { + 'Ai %d teste praf', + 'Testele tale sunt varză', + 'Codul tău este rău și ar trebui să te simți rău', + 'Codul tău este în Zona Periculoasă', + 'Ce joc ciudat. Singura cale de a câștiga este să nu testezi', + 'Bunica mea scria teste mai bune pe un 3 86', + 'De fiecare dată când este un eșec, bea incă o bere', + 'Se simte rău omule' + }, + success_messages = { + 'Ooo da, trec testele', + 'Nu contează, am avut teste', + 'Se simte bine, omule', + 'Grozav succes', + 'Testele trec, bea altă bere', + } +} From 75b2c8930ed22d99dc5f6e41547ec333feee6197 Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Thu, 27 Jan 2022 13:26:22 +0100 Subject: [PATCH 07/32] fix(output) enable color overrides for utf+gtest handlers (#675) --- busted/outputHandlers/gtest.lua | 37 ++++++++++++++++++++------ busted/outputHandlers/utfTerminal.lua | 38 +++++++++++++++++++++------ spec/cl_output_handler.lua | 7 ++++- 3 files changed, 65 insertions(+), 17 deletions(-) diff --git a/busted/outputHandlers/gtest.lua b/busted/outputHandlers/gtest.lua index 3f4a8658..ab076612 100644 --- a/busted/outputHandlers/gtest.lua +++ b/busted/outputHandlers/gtest.lua @@ -6,22 +6,43 @@ local ipairs = ipairs local string_format = string.format local io_write = io.write local io_flush = io.flush - local colors local isatty = io.type(io.stdout) == 'file' and term.isatty(io.stdout) -local isWindows = package.config:sub(1,1) == '\\' - -if isWindows and not os.getenv("ANSICON") or not isatty then - colors = setmetatable({}, {__index = function() return function(s) return s end end}) -else - colors = require 'term.colors' -end return function(options) local busted = require 'busted' local handler = require 'busted.outputHandlers.base'() + local cli = require 'cliargs' + local args = options.arguments + + cli:set_name('gtest output handler') + cli:flag('--color', 'force use of color') + cli:flag('--plain', 'force use of no color') + + local cliArgs, err = cli:parse(args) + if not cliArgs and err then + io.stderr:write(string.format('%s: %s\n\n', cli.name, err)) + io.stderr:write(cli.printer.generate_help_and_usage().. '\n') + os.exit(1) + end + + if cliArgs.plain then + colors = setmetatable({}, {__index = function() return function(s) return s end end}) + + elseif cliArgs.color then + colors = require 'term.colors' + + else + if package.config:sub(1,1) == '\\' and not os.getenv("ANSICON") or not isatty then + -- Disable colors on Windows. + colors = setmetatable({}, {__index = function() return function(s) return s end end}) + else + colors = require 'term.colors' + end + end + local repeatSuiteString = '\nRepeating all tests (run %u of %u) . . .\n\n' local randomizeString = colors.yellow('Note: Randomizing test order with a seed of %u.\n') local suiteStartString = colors.green ('[==========]') .. ' Running tests from scanned files.\n' diff --git a/busted/outputHandlers/utfTerminal.lua b/busted/outputHandlers/utfTerminal.lua index 6ecb399c..ba187814 100644 --- a/busted/outputHandlers/utfTerminal.lua +++ b/busted/outputHandlers/utfTerminal.lua @@ -1,5 +1,6 @@ local s = require 'say' local pretty = require 'pl.pretty' +local term = require 'term' local io = io local type = type local string_format = string.format @@ -7,20 +8,41 @@ local string_gsub = string.gsub local io_write = io.write local io_flush = io.flush local pairs = pairs - - local colors -if package.config:sub(1,1) == '\\' and not os.getenv("ANSICON") then - -- Disable colors on Windows. - colors = setmetatable({}, {__index = function() return function(s) return s end end}) -else - colors = require 'term.colors' -end +local isatty = io.type(io.stdout) == 'file' and term.isatty(io.stdout) return function(options) local busted = require 'busted' local handler = require 'busted.outputHandlers.base'() + local cli = require 'cliargs' + local args = options.arguments + + cli:set_name('utfTerminal output handler') + cli:flag('--color', 'force use of color') + cli:flag('--plain', 'force use of no color') + + local cliArgs, err = cli:parse(args) + if not cliArgs and err then + io.stderr:write(string.format('%s: %s\n\n', cli.name, err)) + io.stderr:write(cli.printer.generate_help_and_usage().. '\n') + os.exit(1) + end + + if cliArgs.plain then + colors = setmetatable({}, {__index = function() return function(s) return s end end}) + + elseif cliArgs.color then + colors = require 'term.colors' + + else + if package.config:sub(1,1) == '\\' and not os.getenv("ANSICON") or not isatty then + -- Disable colors on Windows. + colors = setmetatable({}, {__index = function() return function(s) return s end end}) + else + colors = require 'term.colors' + end + end local successDot = colors.green('●') local failureDot = colors.red('◼') diff --git a/spec/cl_output_handler.lua b/spec/cl_output_handler.lua index 8a253a4a..47e775ed 100644 --- a/spec/cl_output_handler.lua +++ b/spec/cl_output_handler.lua @@ -10,7 +10,12 @@ return function(options) cli:flag('--time', 'show timestamps') cli:option('--time-format=FORMAT', 'format string according to strftime', '!%a %b %d %H:%M:%S %Y') - local cliArgs = cli:parse(args) + local cliArgs, err = cli:parse(args) + if not cliArgs and err then + io.stderr:write(string.format('%s: %s\n\n', cli.name, err)) + io.stderr:write(cli.printer.generate_help_and_usage().. '\n') + os.exit(1) + end handler.testEnd = function(element, parent, status, debug) local showTime = cliArgs.time From 14c69b8ececb4575869c5efc61cd54820332fabe Mon Sep 17 00:00:00 2001 From: Frans de Jonge Date: Sun, 20 Mar 2022 12:16:48 +0100 Subject: [PATCH 08/32] Change rockspec URL to git+https Resolves this error: ``` Cloning into 'busted'... fatal: remote error: The unauthenticated git protocol on port 9418 is no longer supported. Please see https://github.blog/2021-09-01-improving-git-protocol-security-github/ for more information. ``` Cf. . --- busted-scm-2.rockspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/busted-scm-2.rockspec b/busted-scm-2.rockspec index e5482330..05b7d257 100644 --- a/busted-scm-2.rockspec +++ b/busted-scm-2.rockspec @@ -1,7 +1,7 @@ package = 'busted' version = 'scm-2' source = { - url = "git://github.com/Olivine-Labs/busted", + url = "git+https://github.com/Olivine-Labs/busted", branch = "master" } description = { From 0fc1f4faedcfee287fb925fec78ef88488a2df3a Mon Sep 17 00:00:00 2001 From: Trendyne <78870353+Trendyne@users.noreply.github.com> Date: Fri, 27 May 2022 22:46:26 +0000 Subject: [PATCH 09/32] icelandic --- busted/languages/is.lua | 44 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 busted/languages/is.lua diff --git a/busted/languages/is.lua b/busted/languages/is.lua new file mode 100644 index 00000000..5cc0daa5 --- /dev/null +++ b/busted/languages/is.lua @@ -0,0 +1,44 @@ +local s = require('say') + +s:set_namespace('is') + +-- 'Pending: test.lua @ 12 \n description +s:set('output.pending', 'Í bið') +s:set('output.failure', 'Bilun') +s:set('output.error', 'Villa') +s:set('output.success', 'Tókst') + +s:set('output.pending_plural', 'í bið') +s:set('output.failure_plural', 'bilanir') +s:set('output.error_plural', 'villur') +s:set('output.success_plural', 'tókst') + +s:set('output.pending_zero', 'í bið') +s:set('output.failure_zero', 'bilanir') +s:set('output.error_zero', 'villur') +s:set('output.success_zero', 'tókst') + +s:set('output.pending_single', 'í bið') +s:set('output.failure_single', 'bilun') +s:set('output.error_single', 'villa') +s:set('output.success_single', 'tókst') + +s:set('output.seconds', 'sekúndur') + +s:set('output.no_test_files_match', 'Engar prufuskrár fundust sem passa við Lúa mynstur: %s') +s:set('output.file_not_found', 'Get ekki fundið skrá eða möppu: %s') + +-- definitions following are not used within the 'say' namespace +return { + failure_messages = { + 'Þú hefur %d brotnar fyrirmyndir', + 'Fyrirmyndirnar þínar eru brotnar', + 'Kóðinn þinn er slæmur og þér ætti að líða illa', + 'Í hvert skipti sem það er bilun skaltu drekka annan bjór', + }, + success_messages = { + 'Húrra!', + 'Frábært!', + 'Geggjað!', + } +} From fc266fead9d402b8a95d1036d3f5f1e44a97bdd2 Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Sat, 6 Aug 2022 08:39:32 +0200 Subject: [PATCH 10/32] fix(rockspec) add missing languages and sort for easier comparison --- busted-scm-2.rockspec | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/busted-scm-2.rockspec b/busted-scm-2.rockspec index e5482330..fad5a77d 100644 --- a/busted-scm-2.rockspec +++ b/busted-scm-2.rockspec @@ -70,18 +70,21 @@ build = { ['busted.outputHandlers.gtest'] = 'busted/outputHandlers/gtest.lua', ['busted.outputHandlers.sound'] = 'busted/outputHandlers/sound.lua', - ['busted.languages.en'] = 'busted/languages/en.lua', ['busted.languages.ar'] = 'busted/languages/ar.lua', ['busted.languages.de'] = 'busted/languages/de.lua', + ['busted.languages.en'] = 'busted/languages/en.lua', ['busted.languages.es'] = 'busted/languages/es.lua', ['busted.languages.fr'] = 'busted/languages/fr.lua', + ['busted.languages.is'] = 'busted/languages/is.lua', + ['busted.languages.it'] = 'busted/languages/it.lua', ['busted.languages.ja'] = 'busted/languages/ja.lua', ['busted.languages.nl'] = 'busted/languages/nl.lua', + ['busted.languages.pt-BR'] = 'busted/languages/pt-BR.lua', + ['busted.languages.ro'] = 'busted/languages/ro.lua', ['busted.languages.ru'] = 'busted/languages/ru.lua', ['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 = { From 71754440f9a869296aec49f72fafc3613602cfbd Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Sat, 6 Aug 2022 08:47:47 +0200 Subject: [PATCH 11/32] fix(color) utf+gtest handlers now also set luassert color previously luassert did its own detection. Now the override in busted will set luassert coloring options --- busted/outputHandlers/gtest.lua | 4 ++++ busted/outputHandlers/utfTerminal.lua | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/busted/outputHandlers/gtest.lua b/busted/outputHandlers/gtest.lua index ab076612..c0939f7d 100644 --- a/busted/outputHandlers/gtest.lua +++ b/busted/outputHandlers/gtest.lua @@ -30,16 +30,20 @@ return function(options) if cliArgs.plain then colors = setmetatable({}, {__index = function() return function(s) return s end end}) + assert:set_parameter("TableErrorHighlightColor", "none") elseif cliArgs.color then colors = require 'term.colors' + assert:set_parameter("TableErrorHighlightColor", "red") else if package.config:sub(1,1) == '\\' and not os.getenv("ANSICON") or not isatty then -- Disable colors on Windows. colors = setmetatable({}, {__index = function() return function(s) return s end end}) + assert:set_parameter("TableErrorHighlightColor", "none") else colors = require 'term.colors' + assert:set_parameter("TableErrorHighlightColor", "red") end end diff --git a/busted/outputHandlers/utfTerminal.lua b/busted/outputHandlers/utfTerminal.lua index ba187814..8b4b1220 100644 --- a/busted/outputHandlers/utfTerminal.lua +++ b/busted/outputHandlers/utfTerminal.lua @@ -31,16 +31,20 @@ return function(options) if cliArgs.plain then colors = setmetatable({}, {__index = function() return function(s) return s end end}) + assert:set_parameter("TableErrorHighlightColor", "none") elseif cliArgs.color then colors = require 'term.colors' + assert:set_parameter("TableErrorHighlightColor", "red") else if package.config:sub(1,1) == '\\' and not os.getenv("ANSICON") or not isatty then -- Disable colors on Windows. colors = setmetatable({}, {__index = function() return function(s) return s end end}) + assert:set_parameter("TableErrorHighlightColor", "none") else colors = require 'term.colors' + assert:set_parameter("TableErrorHighlightColor", "red") end end From 21ba89c004e75c6052c79c99308d297fcae698eb Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Mon, 8 Aug 2022 08:24:33 +0300 Subject: [PATCH 12/32] chore(ci): Simplify workflow with Luacheck's GH Action --- .github/workflows/luacheck.yml | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/.github/workflows/luacheck.yml b/.github/workflows/luacheck.yml index 9d6ff913..2f20456a 100644 --- a/.github/workflows/luacheck.yml +++ b/.github/workflows/luacheck.yml @@ -7,15 +7,7 @@ jobs: luacheck: runs-on: ubuntu-20.04 steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Setup ‘lua’ - uses: leafo/gh-actions-lua@v8 - with: - luaVersion: 5.3 - - name: Setup ‘luarocks’ - uses: leafo/gh-actions-luarocks@v4 - - name: Setup ‘luacheck’ - run: luarocks install luacheck - - name: Run ‘luacheck’ linter - run: luacheck . + - name: Checkout + uses: actions/checkout@v3 + - name: Luacheck + uses: lunarmodules/luacheck@v0 From 805302621b028c7af04395ed4887375efc6a684f Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Mon, 15 Aug 2022 12:06:10 +0200 Subject: [PATCH 13/32] fix(output) gtest and utfhandlers would error if color was set (#688) --- busted/outputHandlers/gtest.lua | 9 +++++---- busted/outputHandlers/utfTerminal.lua | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/busted/outputHandlers/gtest.lua b/busted/outputHandlers/gtest.lua index c0939f7d..2ba35db9 100644 --- a/busted/outputHandlers/gtest.lua +++ b/busted/outputHandlers/gtest.lua @@ -1,5 +1,6 @@ local pretty = require 'pl.pretty' local term = require 'term' +local luassert = require 'luassert' local io = io local type = type local ipairs = ipairs @@ -30,20 +31,20 @@ return function(options) if cliArgs.plain then colors = setmetatable({}, {__index = function() return function(s) return s end end}) - assert:set_parameter("TableErrorHighlightColor", "none") + luassert:set_parameter("TableErrorHighlightColor", "none") elseif cliArgs.color then colors = require 'term.colors' - assert:set_parameter("TableErrorHighlightColor", "red") + luassert:set_parameter("TableErrorHighlightColor", "red") else if package.config:sub(1,1) == '\\' and not os.getenv("ANSICON") or not isatty then -- Disable colors on Windows. colors = setmetatable({}, {__index = function() return function(s) return s end end}) - assert:set_parameter("TableErrorHighlightColor", "none") + luassert:set_parameter("TableErrorHighlightColor", "none") else colors = require 'term.colors' - assert:set_parameter("TableErrorHighlightColor", "red") + luassert:set_parameter("TableErrorHighlightColor", "red") end end diff --git a/busted/outputHandlers/utfTerminal.lua b/busted/outputHandlers/utfTerminal.lua index 8b4b1220..7ea3b512 100644 --- a/busted/outputHandlers/utfTerminal.lua +++ b/busted/outputHandlers/utfTerminal.lua @@ -1,6 +1,7 @@ local s = require 'say' local pretty = require 'pl.pretty' local term = require 'term' +local luassert = require 'luassert' local io = io local type = type local string_format = string.format @@ -31,20 +32,20 @@ return function(options) if cliArgs.plain then colors = setmetatable({}, {__index = function() return function(s) return s end end}) - assert:set_parameter("TableErrorHighlightColor", "none") + luassert:set_parameter("TableErrorHighlightColor", "none") elseif cliArgs.color then colors = require 'term.colors' - assert:set_parameter("TableErrorHighlightColor", "red") + luassert:set_parameter("TableErrorHighlightColor", "red") else if package.config:sub(1,1) == '\\' and not os.getenv("ANSICON") or not isatty then -- Disable colors on Windows. colors = setmetatable({}, {__index = function() return function(s) return s end end}) - assert:set_parameter("TableErrorHighlightColor", "none") + luassert:set_parameter("TableErrorHighlightColor", "none") else colors = require 'term.colors' - assert:set_parameter("TableErrorHighlightColor", "red") + luassert:set_parameter("TableErrorHighlightColor", "red") end end From d9dd556b3ee0277f97f7be59eecb059fa3551cd9 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 16 Aug 2022 20:40:57 +0300 Subject: [PATCH 14/32] docs(readme): Update self-referential links to new org home --- CONTRIBUTING.md | 4 ++-- README.md | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 393d12f8..d791bac1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -15,7 +15,7 @@ Here's some examples of things you might want to make a pull request for: If you have a more deeply-rooted problem with how the program is built or some of the stylistic decisions made in the code, it's best to -[create an issue](https://github.com/Olivine-Labs/busted/issues) before putting +[create an issue](https://github.com/lunarmodules/busted/issues) before putting the effort into a pull request. The same goes for new features - it is best to check the project's direction, existing pull requests, and currently open and closed issues first. @@ -34,7 +34,7 @@ be found in the README. ## Using Git appropriately -1. [Fork the repository](https://github.com/Olivine-Labs/busted/fork_select) to +1. [Fork the repository](https://github.com/lunarmodules/busted/fork_select) to your Github account. 2. Create a *topical branch* - a branch whose name is succint but explains what you're doing, such as "romanian-translation" diff --git a/README.md b/README.md index 8ed3d5c8..e6349601 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,16 @@ busted ====== -[![Luacheck Lint Status](https://img.shields.io/github/workflow/status/Olivine-Labs/busted/Luacheck?label=Luacheck&logo=Lua)](https://github.com/Olivine-Labs/busted/actions?workflow=Luacheck) -[![Busted Test Status](https://img.shields.io/github/workflow/status/Olivine-Labs/busted/Busted?label=Linux%20Build&logo=Github)](https://github.com/Olivine-Labs/busted/actions?workflow=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) +[![Luacheck Lint Status](https://img.shields.io/github/workflow/status/lunarmodules/busted/Luacheck?label=Luacheck&logo=Lua)](https://github.com/lunarmodules/busted/actions?workflow=Luacheck) +[![Busted Test Status](https://img.shields.io/github/workflow/status/lunarmodules/busted/Busted?label=Linux%20Build&logo=Github)](https://github.com/lunarmodules/busted/actions?workflow=Busted) +[![Join the chat at https://gitter.im/lunarmodules/busted](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/lunarmodules/busted?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) busted is a unit testing framework with a focus on being **easy to use**. Supports Lua >= 5.1, luajit >= 2.0.0, and moonscript. -Check out the [official docs](http://olivinelabs.com/busted) for +Check out the [official docs](https://lunarmodules.github.io/busted/) for extended info. busted test specs read naturally without being too verbose. You can even @@ -62,7 +62,7 @@ end) Contributing ------------ -See [CONTRIBUTING.md](https://github.com/Olivine-Labs/busted/blob/master/CONTRIBUTING.md). +See [CONTRIBUTING.md](https://github.com/lunarmodules/busted/blob/master/CONTRIBUTING.md). All issues, suggestions, and most importantly pull requests are welcome. Testing @@ -93,4 +93,4 @@ License ------- Copyright 2012-2020 Olivine Labs, LLC. -MIT licensed. See [LICENSE for details](https://github.com/Olivine-Labs/busted/blob/master/LICENSE). +MIT licensed. See [LICENSE for details](https://github.com/lunarmodules/busted/blob/master/LICENSE). From 1e525e65c08f68df740843a4e50a725048cb44d2 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 16 Aug 2022 20:57:25 +0300 Subject: [PATCH 15/32] chore(ci): Overhaul self-referential busted workflow in line with Luacheck --- .github/workflows/busted.yml | 88 +++++++++++++++++++++--------------- 1 file changed, 52 insertions(+), 36 deletions(-) diff --git a/.github/workflows/busted.yml b/.github/workflows/busted.yml index 25d7d86b..58e79c09 100644 --- a/.github/workflows/busted.yml +++ b/.github/workflows/busted.yml @@ -1,6 +1,19 @@ +# ATTENTION +# +# This is *not* a typical busted workflow! Do not copy this to other projects! +# Instead of installing busted from somewhere and using it on a code base, +# we're actually building and running the current HEAD version on ourselves: +# basically this is a combination bootstrap test and dogfooding. The upshot is +# that we check both that everything works (and end-to-end test) and that the +# current codebase checks against itself. This ensures we can fix a bug or make +# a breaking change in busted without being blocked by our own CI using a +# different busted verision. +# +# See the README.md file for examples suitable for use in other projects. + name: Busted -on: [push, pull_request] +on: [ push, pull_request ] jobs: @@ -8,39 +21,42 @@ jobs: strategy: fail-fast: false matrix: - luaVersion: ["5.4", "5.3", "5.2", "5.1", "luajit", "luajit-openresty"] - penlightVersion: ["1.9.2", "1.8.0", "1.6.0", "1.3.2"] - runs-on: ubuntu-20.04 + luaVersion: [ "5.4", "5.3", "5.2", "5.1", "luajit" ] #, "luajit-openresty" ] + penlightVersion: [ "1.13.1", "1.9.2", "1.8.0", "1.6.0", "1.3.2" ] + runs-on: ubuntu-22.04 steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Setup ‘lua’ - uses: leafo/gh-actions-lua@v8 - with: - luaVersion: ${{ matrix.luaVersion }} - - name: Setup ‘luarocks’ - uses: leafo/gh-actions-luarocks@v4 - - name: Setup dependencies - run: | - sudo apt-get install libev-dev - luarocks install penlight ${{ matrix.penlightVersion }} - luarocks install --only-deps busted-scm-2.rockspec - luarocks install luasec - luarocks install moonscript - luarocks install copas - luarocks install lua-ev - luarocks install luacov - - name: Cache Lua machinery - uses: actions/cache@v2 - with: - path: | - .install - .lua - .luarocks - key: lua-${{ matrix.luaVersion }}-${{ matrix.penlightVersion }}-${{ hashFiles('busted-scm-2.rockspec', '.github/workflows/busted.yml') }} - - name: Build - run: | - luarocks remove busted --force ||: - luarocks make - - name: Run tests - run: busted -v + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup ‘lua’ + uses: leafo/gh-actions-lua@v9 + with: + luaVersion: ${{ matrix.luaVersion }} + + - name: Setup ‘luarocks’ + uses: leafo/gh-actions-luarocks@v4 + + - name: Setup dependencies + run: | + sudo apt-get install libev-dev + luarocks install penlight ${{ matrix.penlightVersion }} + luarocks install luasec + luarocks install moonscript + luarocks install copas + luarocks install lua-ev + luarocks install luacov + luarocks install --deps-only busted-scm-2.rockspec + + - name: Build ‘busted’ (bootstrap) + run: | + luarocks make + + - name: Run ‘busted’ (dogfood) + run: busted -c -v + + - name: Report test coverage + if: success() + continue-on-error: true + run: luacov-coveralls -i src -e .luarocks + env: + COVERALLS_REPO_TOKEN: ${{ github.token }} From 5dca0fbdc62ab81b8f192360d1a73b8872d2055c Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Thu, 18 Aug 2022 23:33:21 +0300 Subject: [PATCH 16/32] feat(ci): Add deploy to Luarocks from CI Adapted from luacheck --- .github/workflows/deploy.yml | 34 ++++++++++++++++++++++++++++++++ .github/workflows/versioning.yml | 16 +++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 .github/workflows/deploy.yml create mode 100644 .github/workflows/versioning.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000..0899727e --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,34 @@ +name: Deploy + +on: [ push, workflow_dispatch ] + +jobs: + + affected: + uses: lunarmodules/.github/.github/workflows/list_affected_rockspecs.yml@main + + build: + needs: affected + if: ${{ needs.affected.outputs.rockspecs }} + uses: lunarmodules/.github/.github/workflows/test_build_rock.yml@main + with: + rockspecs: ${{ needs.affected.outputs.rockspecs }} + + upload: + needs: [ affected, build ] + # Only run upload if: + # 1. We are on the canonical repository (no uploads from forks) + # 2. The current commit is either tagged or on the default branch (the workflow will upload dev/scm rockspecs any + # time they are touched, tagged ones whenever the edited rockspec and tag match) + # 3. Some rockspecs were changed — this implies the commit changing the rockspec is the same one that gets tagged + if: >- + ${{ + github.repository == 'lunarmodules/busted' && + ( github.ref_name == 'master' || startsWith(github.ref, 'refs/tags/') ) && + needs.affected.outputs.rockspecs + }} + uses: lunarmodules/.github/.github/workflows/upload_to_luarocks.yml@main + with: + rockspecs: ${{ needs.affected.outputs.rockspecs }} + secrets: + apikey: ${{ secrets.LUAROCKS_APIKEY }} diff --git a/.github/workflows/versioning.yml b/.github/workflows/versioning.yml new file mode 100644 index 00000000..37d8fd06 --- /dev/null +++ b/.github/workflows/versioning.yml @@ -0,0 +1,16 @@ +name: Versioning + +on: + release: + types: [ created, published, edited ] + +jobs: + actions-tagger: + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Update release tags + uses: Actions-R-Us/actions-tagger@v2 + with: + publish_latest_tag: true From 89aa95d94a5a93c53c95ac7337ba47c74cefe1f4 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 20 Aug 2022 22:04:12 +0300 Subject: [PATCH 17/32] chore: Tweak scm rockspec, normalize with others This is partly to force a publish to make sure our CI machinery is working, but also to bring the style in line with Penlight, luassert, say, and others in this org. --- busted-scm-2.rockspec | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/busted-scm-2.rockspec b/busted-scm-2.rockspec index fad5a77d..fb69ac09 100644 --- a/busted-scm-2.rockspec +++ b/busted-scm-2.rockspec @@ -1,11 +1,19 @@ -package = 'busted' -version = 'scm-2' +local package_name = "busted" +local package_version = "scm" +local rockspec_revision = "2" +local github_account_name = "lunarmodules" +local github_repo_name = package_name +local git_checkout = package_version == "scm" and "master" or package_version + +rockspec_format = "3.0" +package = package_name +version = package_version .. "-" .. rockspec_revision source = { - url = "git://github.com/Olivine-Labs/busted", - branch = "master" + url = "git+https://github.com/"..github_account_name.."/"..github_repo_name..".git", + branch = git_checkout } description = { - summary = 'Elegant Lua unit testing.', + summary = 'Elegant Lua unit testing', detailed = [[ An elegant, extensible, testing framework. Ships with a large amount of useful asserts, @@ -14,7 +22,7 @@ description = { or TAP for CI integration. Great for TDD and unit, integration, and functional tests. ]], - homepage = 'http://olivinelabs.com/busted/', + homepage = "https://lunarmodules.github.io/busted/", license = 'MIT ' } dependencies = { @@ -30,6 +38,14 @@ dependencies = { 'mediator_lua >= 1.1.1', } +test_dependencies = { + "busted", +} + +test = { + type = "busted", +} + build = { type = 'builtin', modules = { From 5664adfee0af4bd68d9f9544c7591062cfae5347 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 16 Aug 2022 20:59:09 +0300 Subject: [PATCH 18/32] feat(ci): Add tooling for use *as* GitHub action --- .github/workflows/deploy.yml | 13 +++++++++++++ Dockerfile | 31 +++++++++++++++++++++++++++++++ action.yml | 17 +++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 Dockerfile create mode 100644 action.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 0899727e..f9d4c746 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -32,3 +32,16 @@ jobs: rockspecs: ${{ needs.affected.outputs.rockspecs }} secrets: apikey: ${{ secrets.LUAROCKS_APIKEY }} + + docker: + if: >- + ${{ + github.repository == 'lunarmodules/busted' && + ( github.ref_name == 'master' || startsWith(github.ref, 'refs/tags/') ) + }} + uses: lunarmodules/.github/.github/workflows/docker_ghcr_deploy.yml@main + with: + username: ${{ github.actor }} + tag: ${{ github.ref_name }} + secrets: + token: ${{ secrets.GHCR_PAT }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..ca458920 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +#syntax=docker/dockerfile:1.2 + +FROM akorn/luarocks:lua5.4-alpine AS builder + +RUN apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing \ + dumb-init gcc libc-dev + +COPY ./ /src +WORKDIR /src + +RUN luarocks --tree /pkgdir/usr/local make +RUN find /pkgdir -type f -exec sed -i -e 's!/pkgdir!!g' {} \; + +FROM akorn/luarocks:lua5.4-alpine AS final + +RUN apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing \ + dumb-init + +LABEL org.opencontainers.image.title="Busted" +LABEL org.opencontainers.image.description="A containerized version of Busted, a unit testing framework for Lua." +LABEL org.opencontainers.image.authors="Caleb Maclennan " +LABEL org.opencontainers.image.licenses="MIT" +LABEL org.opencontainers.image.url="https://github.com/lunarmodules/busted/pkgs/container/busted" +LABEL org.opencontainers.image.source="https://github.com/lunarmodules/busted" + +COPY --from=builder /pkgdir / +RUN busted --version + +WORKDIR /data + +ENTRYPOINT ["busted", "--verbose"] diff --git a/action.yml b/action.yml new file mode 100644 index 00000000..f5487aa4 --- /dev/null +++ b/action.yml @@ -0,0 +1,17 @@ +name: Busted +description: Busted +inputs: + args: + description: Arguments passed to busted + required: false + default: "." +runs: + using: docker + image: docker://ghcr.io/lunarmodules/busted:v2.0.0 + entrypoint: sh + args: + - -c + - busted ${{ inputs.args }} +branding: + icon: check + color: yellow From 3dc706dc6a987982528eb5c5225756bd476a8a57 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 20 Aug 2022 23:02:19 +0300 Subject: [PATCH 19/32] docs(readme): Explain usage for Docker & GH Action --- README.md | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/README.md b/README.md index e6349601..1fde624a 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,79 @@ luarocks make busted spec ``` +Docker +------ + +Alternatively Busted can be run as a standalone docker container. +This approach is somewhat limited because many projects will require extra dependencies which will need to be installed inside the Docker container. +Luarocks is provided in the container so many dependencies can be added. +The images are based on Alpine Linux so you can also use `apk add` to install system dependencies if needed. +The Docker use case is probably most advantageous for pure-Lua projects with no dependencies: i.g. small libraries not large apps. + +The usage of docker is fairly simple. +You can either build your own or download a prebuilt version. +To build your own, execute the following command from the source directory of this project: + +```console +$ docker build -t ghcr.io/lunarmodules/busted:HEAD . +``` + +To use a prebuilt one, download it from the GitHub Container Registry. +Here we use the one tagged *latest*, but you can substitute *latest* for any tagged release. + +```console +$ docker pull ghcr.io/lunarmodules/busted:latest +``` + +Once you have a container you can run it on one file or a source tree (substitute *latest* with *HEAD* if you built your own or with the tagged version you want if applicable): + +```console +# Run on an entire project +$ docker run -v "$(pwd):/data" ghcr.io/lunarmodules/busted:latest + +# Run on one directory: +$ docker run -v "$(pwd):/data" ghcr.io/lunarmodules/busted:latest specs +``` + +A less verbose way to run it in most shells is with at alias: + +```console +# In a shell or in your shell's RC file: +$ alias busted='docker run -v "$(pwd):/data" ghcr.io/lunarmodules/busted:latest' + +# Thereafter just run: +$ busted +``` +### Use as a CI job + +There are actually many ways to run Busted remotely as part of a CI work flow. +Because packages are available for many platforms, one way would be to just use your platforms native package installation system to pull them into whatever CI runner environment you already use. +Another way is to pull in the prebuilt Docker container and run that. + +As a case study, here is how a workflow could be setup in GitHub Actions: + +```yaml +name: Busted +on: [push, pull_request] +jobs: + sile: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Run Busted + uses: lunarmodules/busted@v0 +``` + +By default the GH Action is configured to run `busted --verbose`, but you can also pass it your own `args` to replace the default input of `.`. + +```yaml + - name: Run Busted + uses: lunarmodules/busted@v0 + with: + args: --tags=MYTAGS +``` + License ------- From 41014cb3bd3e9c5854a4c87dc2e4940d7a8fe2ce Mon Sep 17 00:00:00 2001 From: Damian Monogue <3660+demonnic@users.noreply.github.com> Date: Mon, 22 Aug 2022 05:50:36 -0400 Subject: [PATCH 20/32] docs(readme): Update documentation link to new location (#693) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8ed3d5c8..24b3e68e 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ busted busted is a unit testing framework with a focus on being **easy to use**. Supports Lua >= 5.1, luajit >= 2.0.0, and moonscript. -Check out the [official docs](http://olivinelabs.com/busted) for +Check out the [official docs](https://lunarmodules.github.io/busted/) for extended info. busted test specs read naturally without being too verbose. You can even From e2d1b01489a8946a9973f441ae2a420f0156ceda Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 23 Aug 2022 12:59:00 +0300 Subject: [PATCH 21/32] chore(ci): Fix typos Co-authored-by: Thijs Schreijer --- .github/workflows/busted.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/busted.yml b/.github/workflows/busted.yml index 58e79c09..c382968a 100644 --- a/.github/workflows/busted.yml +++ b/.github/workflows/busted.yml @@ -7,7 +7,7 @@ # that we check both that everything works (and end-to-end test) and that the # current codebase checks against itself. This ensures we can fix a bug or make # a breaking change in busted without being blocked by our own CI using a -# different busted verision. +# different busted version. # # See the README.md file for examples suitable for use in other projects. From 3a185b7511851b686f1d387a4b5caff8132ac08d Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 23 Aug 2022 13:01:55 +0300 Subject: [PATCH 22/32] chore(ci): Disable use of local lua paths, test only with installed paths Co-authored-by: Thijs Schreijer --- .github/workflows/busted.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/busted.yml b/.github/workflows/busted.yml index c382968a..81784d37 100644 --- a/.github/workflows/busted.yml +++ b/.github/workflows/busted.yml @@ -52,7 +52,8 @@ jobs: luarocks make - name: Run ‘busted’ (dogfood) - run: busted -c -v + # disable the paths to force use of installed rockspec + run: busted -c -v --lpath="" --cpath="" --Xoutput "--color" - name: Report test coverage if: success() From 24cd0c76e839c75661f295b3061bdbb7eda77aeb Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Wed, 24 Aug 2022 00:38:00 +0300 Subject: [PATCH 23/32] chore(build): Rewind unnecessary SCM rockrel bump, never published We're force pushing updates to dev/scm rockspecs on change anyway, these are not expected to remain unchanged. --- .github/workflows/busted.yml | 8 ++++---- busted-scm-2.rockspec => busted-scm-1.rockspec | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) rename busted-scm-2.rockspec => busted-scm-1.rockspec (99%) diff --git a/.github/workflows/busted.yml b/.github/workflows/busted.yml index 81784d37..d86540f0 100644 --- a/.github/workflows/busted.yml +++ b/.github/workflows/busted.yml @@ -45,18 +45,18 @@ jobs: luarocks install copas luarocks install lua-ev luarocks install luacov - luarocks install --deps-only busted-scm-2.rockspec + luarocks install --deps-only busted-scm-1.rockspec - name: Build ‘busted’ (bootstrap) run: | luarocks make - name: Run ‘busted’ (dogfood) - # disable the paths to force use of installed rockspec - run: busted -c -v --lpath="" --cpath="" --Xoutput "--color" + # disable project-local path prefixes to force use of system installation + run: busted --coverage --lpath="" --cpath="" -Xoutput --color - name: Report test coverage - if: success() + if: ${{ success() && github.repository == 'lunarmodules/busted' }} continue-on-error: true run: luacov-coveralls -i src -e .luarocks env: diff --git a/busted-scm-2.rockspec b/busted-scm-1.rockspec similarity index 99% rename from busted-scm-2.rockspec rename to busted-scm-1.rockspec index fb69ac09..a86d68eb 100644 --- a/busted-scm-2.rockspec +++ b/busted-scm-1.rockspec @@ -1,6 +1,6 @@ local package_name = "busted" local package_version = "scm" -local rockspec_revision = "2" +local rockspec_revision = "1" local github_account_name = "lunarmodules" local github_repo_name = package_name local git_checkout = package_version == "scm" and "master" or package_version From d7fe6d8dacef1c4ffba93f94ea9261cd16f11d6d Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Wed, 24 Aug 2022 00:53:10 +0300 Subject: [PATCH 24/32] chore(build): Refactor rockspec to dodge luarocks 3.1.3 bug Setting source.branch works for most cases, but when the branch is actually a tag and not a branch then a Luarocks 3.1.3 bug rears and tries to concatenate a nil. This dodges that bullet by setting source.tag explicitly to not trigger the branch_or_tag concatenation. --- busted-scm-1.rockspec | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/busted-scm-1.rockspec b/busted-scm-1.rockspec index a86d68eb..57fa621e 100644 --- a/busted-scm-1.rockspec +++ b/busted-scm-1.rockspec @@ -3,15 +3,17 @@ local package_version = "scm" local rockspec_revision = "1" local github_account_name = "lunarmodules" local github_repo_name = package_name -local git_checkout = package_version == "scm" and "master" or package_version rockspec_format = "3.0" package = package_name version = package_version .. "-" .. rockspec_revision + source = { - url = "git+https://github.com/"..github_account_name.."/"..github_repo_name..".git", - branch = git_checkout + url = "git+https://github.com/" .. github_account_name .. "/" .. github_repo_name .. ".git" } + +if package_version == "scm" then source.branch = "master" else source.tag = "v" .. package_version end + description = { summary = 'Elegant Lua unit testing', detailed = [[ @@ -25,6 +27,7 @@ description = { homepage = "https://lunarmodules.github.io/busted/", license = 'MIT ' } + dependencies = { 'lua >= 5.1', 'lua_cliargs = 3.0', From b640bafbbd27d43f59d39a2534bccff3c8ea0a10 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Wed, 24 Aug 2022 00:55:15 +0300 Subject: [PATCH 25/32] chore(deps): Bump luassert/say deps These two projects are developed and released in cordination with busted so it's reasonable to expect people update them together. We don't test against anything except matching versions, although there is a reasonable chance of them working most of the time. --- busted-scm-1.rockspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/busted-scm-1.rockspec b/busted-scm-1.rockspec index 57fa621e..d40b3291 100644 --- a/busted-scm-1.rockspec +++ b/busted-scm-1.rockspec @@ -34,8 +34,8 @@ dependencies = { 'luafilesystem >= 1.5.0', 'luasystem >= 0.2.0', 'dkjson >= 2.1.0', - 'say >= 1.3', - 'luassert >= 1.7.8', + 'say >= 1.4-1', + 'luassert >= 1.9.0-1', 'lua-term >= 0.1', 'penlight >= 1.3.2', 'mediator_lua >= 1.1.1', From 2c6f027e277d29e59c24c114bb2dc2e3f56a6908 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Wed, 24 Aug 2022 01:01:19 +0300 Subject: [PATCH 26/32] docs(readme): Update badges with Luarocks release indicator --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e6349601..1c72287e 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,12 @@ busted ====== -[![Luacheck Lint Status](https://img.shields.io/github/workflow/status/lunarmodules/busted/Luacheck?label=Luacheck&logo=Lua)](https://github.com/lunarmodules/busted/actions?workflow=Luacheck) -[![Busted Test Status](https://img.shields.io/github/workflow/status/lunarmodules/busted/Busted?label=Linux%20Build&logo=Github)](https://github.com/lunarmodules/busted/actions?workflow=Busted) [![Join the chat at https://gitter.im/lunarmodules/busted](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/lunarmodules/busted?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Busted](https://img.shields.io/github/workflow/status/lunarmodules/busted/Busted?label=Busted=Lua)](https://github.com/lunarmodules/busted/actions?workflow=Busted) +[![Luacheck](https://img.shields.io/github/workflow/status/lunarmodules/busted/Luacheck?label=Luacheck&logo=Lua)](https://github.com/lunarmodules/busted/actions?workflow=Luacheck) +[![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/lunarmodules/busted?label=Tag&logo=GitHub)](https://github.com/lunarmodules/busted/releases) +[![Luarocks](https://img.shields.io/luarocks/v/lunarmodules/busted?label=Luarocks&logo=Lua)](https://luarocks.org/modules/lunarmodules/busted) busted is a unit testing framework with a focus on being **easy to From e586af876b0e87ed8dfe6373ee18e0e725d681c7 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Wed, 24 Aug 2022 15:51:09 +0300 Subject: [PATCH 27/32] chore(docker): Use gtest output driver by default in GH Actions --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index ca458920..4b07431c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,4 +28,4 @@ RUN busted --version WORKDIR /data -ENTRYPOINT ["busted", "--verbose"] +ENTRYPOINT ["busted", "--verbose", "--output=gtest"] From 49772095d28e03ea6e564e8b760d0096ad742ee7 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Wed, 24 Aug 2022 16:23:47 +0300 Subject: [PATCH 28/32] chore: Release v2.1.0 --- action.yml | 2 +- busted/core.lua | 2 +- rockspecs/busted-2.1.0-1.rockspec | 103 ++++++++++++++++++++++++++++++ 3 files changed, 105 insertions(+), 2 deletions(-) create mode 100644 rockspecs/busted-2.1.0-1.rockspec diff --git a/action.yml b/action.yml index f5487aa4..b96c306c 100644 --- a/action.yml +++ b/action.yml @@ -7,7 +7,7 @@ inputs: default: "." runs: using: docker - image: docker://ghcr.io/lunarmodules/busted:v2.0.0 + image: docker://ghcr.io/lunarmodules/busted:v2.1.0 entrypoint: sh args: - -c diff --git a/busted/core.lua b/busted/core.lua index b2faeb7f..94458df2 100644 --- a/busted/core.lua +++ b/busted/core.lua @@ -45,7 +45,7 @@ return function() local mediator = require 'mediator'() local busted = {} - busted.version = '2.0.0-0' + busted.version = '2.1.0' local root = require 'busted.context'() busted.context = root.ref() diff --git a/rockspecs/busted-2.1.0-1.rockspec b/rockspecs/busted-2.1.0-1.rockspec new file mode 100644 index 00000000..9cf44b71 --- /dev/null +++ b/rockspecs/busted-2.1.0-1.rockspec @@ -0,0 +1,103 @@ +local package_name = "busted" +local package_version = "2.1.0" +local rockspec_revision = "1" +local github_account_name = "lunarmodules" +local github_repo_name = package_name + +package = package_name +version = package_version .. "-" .. rockspec_revision +source = { + url = "git+https://github.com/" .. github_account_name .. "/" .. github_repo_name .. ".git" +} + +if package_version == "scm" then source.branch = "master" else source.tag = "v" .. package_version end + +description = { + summary = 'Elegant Lua unit testing', + detailed = [[ + An elegant, extensible, testing framework. + Ships with a large amount of useful asserts, + plus the ability to write your own. Output + in pretty or plain terminal format, JSON, + or TAP for CI integration. Great for TDD + and unit, integration, and functional tests. + ]], + homepage = "https://lunarmodules.github.io/busted/", + license = 'MIT ' +} + +dependencies = { + 'lua >= 5.1', + 'lua_cliargs = 3.0', + 'luafilesystem >= 1.5.0', + 'luasystem >= 0.2.0', + 'dkjson >= 2.1.0', + 'say >= 1.4-1', + 'luassert >= 1.9.0-1', + 'lua-term >= 0.1', + 'penlight >= 1.3.2', + 'mediator_lua >= 1.1.1', +} + +build = { + type = 'builtin', + modules = { + ['busted.core'] = 'busted/core.lua', + ['busted.context'] = 'busted/context.lua', + ['busted.environment'] = 'busted/environment.lua', + ['busted.compatibility'] = 'busted/compatibility.lua', + ['busted.options'] = 'busted/options.lua', + ['busted.done'] = 'busted/done.lua', + ['busted.runner'] = 'busted/runner.lua', + ['busted.status'] = 'busted/status.lua', + ['busted.utils'] = 'busted/utils.lua', + ['busted.block'] = 'busted/block.lua', + ['busted.execute'] = 'busted/execute.lua', + ['busted.init'] = 'busted/init.lua', + ['busted.luajit'] = 'busted/luajit.lua', + ['busted.fixtures'] = 'busted/fixtures.lua', + + ['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', + ['busted.modules.filter_loader'] = 'busted/modules/filter_loader.lua', + ['busted.modules.cli'] = 'busted/modules/cli.lua', + + ['busted.modules.files.lua'] = 'busted/modules/files/lua.lua', + ['busted.modules.files.moonscript'] = 'busted/modules/files/moonscript.lua', + ['busted.modules.files.terra'] = 'busted/modules/files/terra.lua', + + ['busted.outputHandlers.base'] = 'busted/outputHandlers/base.lua', + ['busted.outputHandlers.utfTerminal'] = 'busted/outputHandlers/utfTerminal.lua', + ['busted.outputHandlers.plainTerminal'] = 'busted/outputHandlers/plainTerminal.lua', + ['busted.outputHandlers.TAP'] = 'busted/outputHandlers/TAP.lua', + ['busted.outputHandlers.json'] = 'busted/outputHandlers/json.lua', + ['busted.outputHandlers.junit'] = 'busted/outputHandlers/junit.lua', + ['busted.outputHandlers.gtest'] = 'busted/outputHandlers/gtest.lua', + ['busted.outputHandlers.sound'] = 'busted/outputHandlers/sound.lua', + + ['busted.languages.ar'] = 'busted/languages/ar.lua', + ['busted.languages.de'] = 'busted/languages/de.lua', + ['busted.languages.en'] = 'busted/languages/en.lua', + ['busted.languages.es'] = 'busted/languages/es.lua', + ['busted.languages.fr'] = 'busted/languages/fr.lua', + ['busted.languages.is'] = 'busted/languages/is.lua', + ['busted.languages.it'] = 'busted/languages/it.lua', + ['busted.languages.ja'] = 'busted/languages/ja.lua', + ['busted.languages.nl'] = 'busted/languages/nl.lua', + ['busted.languages.pt-BR'] = 'busted/languages/pt-BR.lua', + ['busted.languages.ro'] = 'busted/languages/ro.lua', + ['busted.languages.ru'] = 'busted/languages/ru.lua', + ['busted.languages.th'] = 'busted/languages/th.lua', + ['busted.languages.ua'] = 'busted/languages/ua.lua', + ['busted.languages.zh'] = 'busted/languages/zh.lua', + }, + install = { + bin = { + ['busted'] = 'bin/busted' + } + } +} From 43f89d9f38c9ec8429e3a777e10196685d22ef34 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Wed, 24 Aug 2022 17:32:36 +0300 Subject: [PATCH 29/32] fix(action): Avoid GitHub marketplace namespace conflict Some puppy that claimed the GitHub username in 2011 and then never did anything with it in a decade is blocking this being published to the marketplace as 'busted'. I had checked that the market namespace was open before picking the name but did not remember than *any* username conflict would be a blocker. This is not ideal but not the end of the world. --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index b96c306c..7117f83a 100644 --- a/action.yml +++ b/action.yml @@ -1,4 +1,4 @@ -name: Busted +name: Lua Busted description: Busted inputs: args: From e3ed48759b625f2e37bf02ccc057b2b98108f108 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Wed, 24 Aug 2022 17:34:58 +0300 Subject: [PATCH 30/32] chore: Release v2.1.1 --- action.yml | 2 +- busted/core.lua | 2 +- rockspecs/busted-2.1.1-1.rockspec | 103 ++++++++++++++++++++++++++++++ 3 files changed, 105 insertions(+), 2 deletions(-) create mode 100644 rockspecs/busted-2.1.1-1.rockspec diff --git a/action.yml b/action.yml index 7117f83a..03d535a5 100644 --- a/action.yml +++ b/action.yml @@ -7,7 +7,7 @@ inputs: default: "." runs: using: docker - image: docker://ghcr.io/lunarmodules/busted:v2.1.0 + image: docker://ghcr.io/lunarmodules/busted:v2.1.1 entrypoint: sh args: - -c diff --git a/busted/core.lua b/busted/core.lua index 94458df2..e2906119 100644 --- a/busted/core.lua +++ b/busted/core.lua @@ -45,7 +45,7 @@ return function() local mediator = require 'mediator'() local busted = {} - busted.version = '2.1.0' + busted.version = '2.1.1' local root = require 'busted.context'() busted.context = root.ref() diff --git a/rockspecs/busted-2.1.1-1.rockspec b/rockspecs/busted-2.1.1-1.rockspec new file mode 100644 index 00000000..f8b975b7 --- /dev/null +++ b/rockspecs/busted-2.1.1-1.rockspec @@ -0,0 +1,103 @@ +local package_name = "busted" +local package_version = "2.1.1" +local rockspec_revision = "1" +local github_account_name = "lunarmodules" +local github_repo_name = package_name + +package = package_name +version = package_version .. "-" .. rockspec_revision +source = { + url = "git+https://github.com/" .. github_account_name .. "/" .. github_repo_name .. ".git" +} + +if package_version == "scm" then source.branch = "master" else source.tag = "v" .. package_version end + +description = { + summary = 'Elegant Lua unit testing', + detailed = [[ + An elegant, extensible, testing framework. + Ships with a large amount of useful asserts, + plus the ability to write your own. Output + in pretty or plain terminal format, JSON, + or TAP for CI integration. Great for TDD + and unit, integration, and functional tests. + ]], + homepage = "https://lunarmodules.github.io/busted/", + license = 'MIT ' +} + +dependencies = { + 'lua >= 5.1', + 'lua_cliargs = 3.0', + 'luafilesystem >= 1.5.0', + 'luasystem >= 0.2.0', + 'dkjson >= 2.1.0', + 'say >= 1.4-1', + 'luassert >= 1.9.0-1', + 'lua-term >= 0.1', + 'penlight >= 1.3.2', + 'mediator_lua >= 1.1.1', +} + +build = { + type = 'builtin', + modules = { + ['busted.core'] = 'busted/core.lua', + ['busted.context'] = 'busted/context.lua', + ['busted.environment'] = 'busted/environment.lua', + ['busted.compatibility'] = 'busted/compatibility.lua', + ['busted.options'] = 'busted/options.lua', + ['busted.done'] = 'busted/done.lua', + ['busted.runner'] = 'busted/runner.lua', + ['busted.status'] = 'busted/status.lua', + ['busted.utils'] = 'busted/utils.lua', + ['busted.block'] = 'busted/block.lua', + ['busted.execute'] = 'busted/execute.lua', + ['busted.init'] = 'busted/init.lua', + ['busted.luajit'] = 'busted/luajit.lua', + ['busted.fixtures'] = 'busted/fixtures.lua', + + ['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', + ['busted.modules.filter_loader'] = 'busted/modules/filter_loader.lua', + ['busted.modules.cli'] = 'busted/modules/cli.lua', + + ['busted.modules.files.lua'] = 'busted/modules/files/lua.lua', + ['busted.modules.files.moonscript'] = 'busted/modules/files/moonscript.lua', + ['busted.modules.files.terra'] = 'busted/modules/files/terra.lua', + + ['busted.outputHandlers.base'] = 'busted/outputHandlers/base.lua', + ['busted.outputHandlers.utfTerminal'] = 'busted/outputHandlers/utfTerminal.lua', + ['busted.outputHandlers.plainTerminal'] = 'busted/outputHandlers/plainTerminal.lua', + ['busted.outputHandlers.TAP'] = 'busted/outputHandlers/TAP.lua', + ['busted.outputHandlers.json'] = 'busted/outputHandlers/json.lua', + ['busted.outputHandlers.junit'] = 'busted/outputHandlers/junit.lua', + ['busted.outputHandlers.gtest'] = 'busted/outputHandlers/gtest.lua', + ['busted.outputHandlers.sound'] = 'busted/outputHandlers/sound.lua', + + ['busted.languages.ar'] = 'busted/languages/ar.lua', + ['busted.languages.de'] = 'busted/languages/de.lua', + ['busted.languages.en'] = 'busted/languages/en.lua', + ['busted.languages.es'] = 'busted/languages/es.lua', + ['busted.languages.fr'] = 'busted/languages/fr.lua', + ['busted.languages.is'] = 'busted/languages/is.lua', + ['busted.languages.it'] = 'busted/languages/it.lua', + ['busted.languages.ja'] = 'busted/languages/ja.lua', + ['busted.languages.nl'] = 'busted/languages/nl.lua', + ['busted.languages.pt-BR'] = 'busted/languages/pt-BR.lua', + ['busted.languages.ro'] = 'busted/languages/ro.lua', + ['busted.languages.ru'] = 'busted/languages/ru.lua', + ['busted.languages.th'] = 'busted/languages/th.lua', + ['busted.languages.ua'] = 'busted/languages/ua.lua', + ['busted.languages.zh'] = 'busted/languages/zh.lua', + }, + install = { + bin = { + ['busted'] = 'bin/busted' + } + } +} From 49821879db7458462ce987a6089bdaa7296fc184 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Wed, 24 Aug 2022 18:11:21 +0300 Subject: [PATCH 31/32] docs(readme): Fix badge icon --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0773dd78..35bda0a2 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ busted [![Join the chat at https://gitter.im/lunarmodules/busted](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/lunarmodules/busted?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -[![Busted](https://img.shields.io/github/workflow/status/lunarmodules/busted/Busted?label=Busted=Lua)](https://github.com/lunarmodules/busted/actions?workflow=Busted) +[![Busted](https://img.shields.io/github/workflow/status/lunarmodules/busted/Busted?label=Busted&logo=Lua)](https://github.com/lunarmodules/busted/actions?workflow=Busted) [![Luacheck](https://img.shields.io/github/workflow/status/lunarmodules/busted/Luacheck?label=Luacheck&logo=Lua)](https://github.com/lunarmodules/busted/actions?workflow=Luacheck) [![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/lunarmodules/busted?label=Tag&logo=GitHub)](https://github.com/lunarmodules/busted/releases) [![Luarocks](https://img.shields.io/luarocks/v/lunarmodules/busted?label=Luarocks&logo=Lua)](https://luarocks.org/modules/lunarmodules/busted) From 64b6c3fbaf3eb7c530e7532b39954415b25dc532 Mon Sep 17 00:00:00 2001 From: eskerda Date: Thu, 11 Feb 2021 09:16:47 +0100 Subject: [PATCH 32/32] feat(helpers): Allow helpers to extend busted --- busted/modules/helper_loader.lua | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/busted/modules/helper_loader.lua b/busted/modules/helper_loader.lua index 300eb166..e7a45f31 100644 --- a/busted/modules/helper_loader.lua +++ b/busted/modules/helper_loader.lua @@ -6,14 +6,21 @@ return function() local loadHelper = function(busted, helper, options) local old_arg = _G.arg local success, err = pcall(function() + local fn + utils.copy_interpreter_args(options.arguments) _G.arg = options.arguments + if helper:match('%.lua$') then - dofile(path.normpath(helper)) + fn = dofile(path.normpath(helper)) elseif hasMoon and helper:match('%.moon$') then - moonscript.dofile(path.normpath(helper)) + fn = moonscript.dofile(path.normpath(helper)) else - require(helper) + fn = require(helper) + end + + if type(fn) == 'function' then + assert(fn(busted, helper, options)) end end)