pax_global_header00006660000000000000000000000064145221463770014525gustar00rootroot0000000000000052 comment=02f31a9c103a44e166617cfdb6ba1b8994a9c912 busted-2.2.0/000077500000000000000000000000001452214637700130145ustar00rootroot00000000000000busted-2.2.0/.editorconfig000066400000000000000000000004771452214637700155010ustar00rootroot00000000000000root = true [*] end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true charset = utf-8 [*.lua] indent_style = space indent_size = 2 [Makefile] indent_style = tab [*.bat] end_of_line = crlf busted-2.2.0/.github/000077500000000000000000000000001452214637700143545ustar00rootroot00000000000000busted-2.2.0/.github/workflows/000077500000000000000000000000001452214637700164115ustar00rootroot00000000000000busted-2.2.0/.github/workflows/busted.yml000066400000000000000000000037611452214637700204310ustar00rootroot00000000000000# 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 version. # # See the README.md file for examples suitable for use in other projects. name: Busted on: [ push, pull_request ] jobs: busted: strategy: fail-fast: false matrix: 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@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: | luarocks install penlight ${{ matrix.penlightVersion }} luarocks install moonscript luarocks install luacov luarocks install --deps-only busted-scm-1.rockspec - name: Build ‘busted’ (bootstrap) run: | luarocks make - name: Run ‘busted’ (dogfood) # disable project-local path prefixes to force use of system installation run: busted --coverage --lpath="" --cpath="" --output=gtest -Xoutput --color - name: Report test coverage if: ${{ success() && github.repository == 'lunarmodules/busted' }} continue-on-error: true run: luacov-coveralls -i src -e .luarocks env: COVERALLS_REPO_TOKEN: ${{ github.token }} busted-2.2.0/.github/workflows/deploy.yml000066400000000000000000000031251452214637700204310ustar00rootroot00000000000000name: 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 }} 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 }} busted-2.2.0/.github/workflows/luacheck.yml000066400000000000000000000003311452214637700207100ustar00rootroot00000000000000name: Luacheck on: [push, pull_request] jobs: luacheck: runs-on: ubuntu-20.04 steps: - name: Checkout uses: actions/checkout@v3 - name: Luacheck uses: lunarmodules/luacheck@v0 busted-2.2.0/.github/workflows/versioning.yml000066400000000000000000000005021452214637700213140ustar00rootroot00000000000000name: 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 busted-2.2.0/.gitignore000066400000000000000000000000431452214637700150010ustar00rootroot00000000000000*.swp /luacov.report.out /.ignore* busted-2.2.0/.luacheckrc000066400000000000000000000007121452214637700151210ustar00rootroot00000000000000std = "max+busted" unused_args = false redefined = false max_line_length = false globals = { "randomize", "match", "async", "done", "busted", --"ngx.IS_CLI", } not_globals = { "string.len", "table.getn", } ignore = { --"6.", -- ignore whitespace warnings } exclude_files = { ".install", ".lua", ".luarocks", "spec/insulate-expose_spec.lua", "spec/cl_compile_fail.lua", } busted-2.2.0/.luacov000066400000000000000000000023511452214637700143070ustar00rootroot00000000000000--- 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'] = 'luacov.stats.out', -- filename to store report ['reportfile'] = '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$', 'coxpcall$', 'mediator$', 'moonscript.*$', }, } busted-2.2.0/CONTRIBUTING.md000066400000000000000000000044631452214637700152540ustar00rootroot00000000000000Contributing to Busted ====================== So you want to contribute to busted? Fantastic! Here's a brief overview on how best to do so. ## What to change Here's some examples of things you might want to make a pull request for: * New language translations * New features * Bugfixes * Inefficient blocks of code 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/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. ## Style * Two spaces, not tabs * Variables have_underscores, classes are Uppercase * Wrap everything in `local`, expose blocks of code using the module pattern * Review our [style guide](https://github.com/Olivine-Labs/lua-style-guide) for more information. Look at existing code to get a good feel for the patterns we use. Please run tests before submitting any pull requests. Instructions for running tests can be found in the README. ## Using Git appropriately 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" 3. Make your changes, committing at logical breaks. 4. Push your branch to your personal account 5. [Create a pull request](https://help.github.com/articles/using-pull-requests) 6. Watch for comments or acceptance Please make separate branches for unrelated changes! ## Licensing Busted is MIT licensed. See details in the LICENSE file. This is a very permissive scheme, GPL-compatible but without many of the restrictions of GPL. ## New releases 1. Create a new rockspec in the `./rockspecs` folder, copied from the `scm` in the repo root folder. 2. Update the line `busted.version = 'x.y.z'` in file `./busted/core.lua`. 3. in `./action.yml` update the version number in the `image` tag. 4. commit the changes, and tag it in `vX.Y.Z` format 5. push the commit and the tags 6. Edit GitHub tag to make a release and edit it changelog notes 7. Attach rockspec and src.rock (preferably downloaded from luarocks.org so checksums match) busted-2.2.0/Dockerfile000066400000000000000000000020051452214637700150030ustar00rootroot00000000000000#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", "--output=gtest"] busted-2.2.0/LICENSE000066400000000000000000000021171452214637700140220ustar00rootroot00000000000000MIT License Terms ================= Copyright (c) 2012-2020 Olivine Labs, LLC. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.busted-2.2.0/README.md000066400000000000000000000134011452214637700142720ustar00rootroot00000000000000busted ====== [![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/actions/workflow/status/lunarmodules/busted/busted.yml?label=Busted&logo=Lua)](https://github.com/lunarmodules/busted/actions?workflow=Busted) [![Luacheck](https://img.shields.io/github/actions/workflow/status/lunarmodules/busted/luacheck.yml?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 use**. Supports Lua >= 5.1, luajit >= 2.0.0, and moonscript. 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 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. An extensible assert library allows you to extend and craft your own assert functions specific to your case with method chaining. A modular output library lets you add on your own output format, along with the default pretty and plain terminal output, JSON with and without streaming, and TAP-compatible output that allows you to run busted specs within most CI servers. ```lua describe('Busted unit testing framework', function() describe('should be awesome', function() it('should be easy to use', function() assert.truthy('Yup.') end) it('should have lots of features', function() -- deep check comparisons! assert.same({ table = 'great'}, { table = 'great' }) -- or check by reference! assert.is_not.equals({ table = 'great'}, { table = 'great'}) assert.falsy(nil) assert.error(function() error('Wat') end) end) it('should provide some shortcuts to common functions', function() assert.unique({{ thing = 1 }, { thing = 2 }, { thing = 3 }}) end) it('should have mocks and spies for functional tests', function() local thing = require('thing_module') spy.on(thing, 'greet') thing.greet('Hi!') assert.spy(thing.greet).was.called() assert.spy(thing.greet).was.called_with('Hi!') end) end) end) ``` Contributing ------------ See [CONTRIBUTING.md](https://github.com/lunarmodules/busted/blob/master/CONTRIBUTING.md). All issues, suggestions, and most importantly pull requests are welcome. Testing ------- Assuming you have luarocks installed: Install these dependencies for core testing: ``` luarocks install moonscript ``` Then to reinstall and run tests: ``` luarocks remove busted --force 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 ------- Copyright 2012-2020 Olivine Labs, LLC. MIT licensed. See [LICENSE for details](https://github.com/lunarmodules/busted/blob/master/LICENSE). busted-2.2.0/TODO.md000066400000000000000000000001241452214637700141000ustar00rootroot00000000000000* Lua Lanes - use to spawn tests in threads, use lindas to share data - busted-2.2.0/action.yml000066400000000000000000000004731452214637700150200ustar00rootroot00000000000000name: Lua Busted description: Busted inputs: args: description: Arguments passed to busted required: false default: "." runs: using: docker image: docker://ghcr.io/lunarmodules/busted:v2.2.0 entrypoint: sh args: - -c - busted ${{ inputs.args }} branding: icon: check color: yellow busted-2.2.0/bin/000077500000000000000000000000001452214637700135645ustar00rootroot00000000000000busted-2.2.0/bin/busted000077500000000000000000000001411452214637700147740ustar00rootroot00000000000000#!/usr/bin/env lua -- Busted command-line runner require 'busted.runner'({ standalone = false }) busted-2.2.0/busted-scm-1.rockspec000066400000000000000000000120371452214637700167560ustar00rootroot00000000000000local package_name = "busted" local package_version = "scm" local rockspec_revision = "1" local github_account_name = "lunarmodules" local github_repo_name = package_name 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" } 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', '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', } test_dependencies = { "busted", } test = { type = "busted", } 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.ko'] = 'busted/languages/ko.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' } } } busted-2.2.0/busted.lua000066400000000000000000000002101452214637700147760ustar00rootroot00000000000000-- This is a dummy file so it can be used in busted's specs -- without adding ./?/init.lua to the lua path return require 'busted.init' busted-2.2.0/busted/000077500000000000000000000000001452214637700143025ustar00rootroot00000000000000busted-2.2.0/busted/block.lua000066400000000000000000000103241452214637700160770ustar00rootroot00000000000000local getfenv = require 'busted.compatibility'.getfenv local unpack = require 'busted.compatibility'.unpack local shuffle = require 'busted.utils'.shuffle local function sort(elements) table.sort(elements, function(t1, t2) if t1.name and t2.name then return t1.name < t2.name end return t2.name ~= nil end) return elements end return function(busted) local block = {} local root = busted.context.get() function block.reject(descriptor, element) element.env[descriptor] = function(...) error("'" .. descriptor .. "' not supported inside current context block", 2) end end function block.rejectAll(element) local env = getfenv(element.run) block.reject('randomize', element) for descriptor, _ in pairs(busted.executors) do if root.env[descriptor] and (env ~= _G and env[descriptor] or rawget(env, descriptor)) then block.reject(descriptor, element) end end end local function exec(descriptor, element) if not element.env then element.env = {} end block.rejectAll(element) local ret = { busted.safe(descriptor, element.run, element) } return unpack(ret) end function block.execAllOnce(descriptor, current, err) local parent = busted.context.parent(current) if parent then local success = block.execAllOnce(descriptor, parent) if not success then return success end end if not current[descriptor] then current[descriptor] = {} end local list = current[descriptor] if list.success ~= nil then return list.success end local success = true for _, v in ipairs(list) do if not exec(descriptor, v):success() then if err then err(descriptor) end success = false end end list.success = success return success end function block.execAll(descriptor, current, propagate, err) local parent = busted.context.parent(current) if propagate and parent then local success, ancestor = block.execAll(descriptor, parent, propagate) if not success then return success, ancestor end end local list = current[descriptor] or {} local success = true for _, v in ipairs(list) do if not exec(descriptor, v):success() then if err then err(descriptor) end success = nil end end return success, current end function block.dexecAll(descriptor, current, propagate, err) local parent = busted.context.parent(current) local list = current[descriptor] or {} local success = true for _, v in ipairs(list) do if not exec(descriptor, v):success() then if err then err(descriptor) end success = nil end end if propagate and parent then if not block.dexecAll(descriptor, parent, propagate) then success = nil end end return success end function block.lazySetup(element, err) return block.execAllOnce('lazy_setup', element, err) end function block.lazyTeardown(element, err) if element.lazy_setup and element.lazy_setup.success ~= nil then block.dexecAll('lazy_teardown', element, nil, err) element.lazy_setup.success = nil end end function block.setup(element, err) return block.execAll('strict_setup', element, nil, err) end function block.teardown(element, err) return block.dexecAll('strict_teardown', element, nil, err) end function block.execute(descriptor, element) if not element.env then element.env = {} end local randomize = busted.randomize local randomseed = busted.randomseed element.env.randomize = function(...) randomize = (select('#', ...) == 0 or ...) if randomize then randomseed = tonumber(({...})[1]) or tonumber(({...})[2]) or randomseed end end if busted.safe(descriptor, element.run, element):success() then if busted.sort then sort(busted.context.children(element)) elseif randomize then element.randomseed = randomseed shuffle(busted.context.children(element), randomseed) end if block.setup(element) then busted.execute(element) end block.lazyTeardown(element) block.teardown(element) end end return block end busted-2.2.0/busted/compatibility.lua000066400000000000000000000034471452214637700176660ustar00rootroot00000000000000return { getfenv = getfenv or function(f) f = (type(f) == 'function' and f or debug.getinfo(f + 1, 'f').func) local name, value local up = 0 repeat up = up + 1 name, value = debug.getupvalue(f, up) until name == '_ENV' or name == nil return name and value or _G end, setfenv = setfenv or function(f, t) f = (type(f) == 'function' and f or debug.getinfo(f + 1, 'f').func) local name local up = 0 repeat up = up + 1 name = debug.getupvalue(f, up) until name == '_ENV' or name == nil if name then debug.upvaluejoin(f, up, function() return name end, 1) debug.setupvalue(f, up, t) end if f ~= 0 then return f end end, loadstring = loadstring or load, unpack = table.unpack or unpack, exit = function(code, force) if not force and code ~= 0 and _VERSION:match('^Lua 5%.[12]$') then error() elseif code ~= 0 then code = 1 end if _VERSION == 'Lua 5.1' and (type(jit) ~= 'table' or not jit.version or jit.version_num < 20000) then -- From Lua 5.1 manual: -- > The userdata itself is freed only in the next -- > garbage-collection cycle. -- Call collectgarbage() while collectgarbage('count') -- changes + 3 times, at least 3 times, -- at max 100 times (to prevent infinite loop). local times_const = 0 for i = 1, 100 do local count_before = collectgarbage("count") collectgarbage() local count_after = collectgarbage("count") if count_after == count_before then times_const = times_const + 1 if times_const > 3 then break end else times_const = 0 end end end os.exit(code, true) end, execute = require 'pl.utils'.execute, } busted-2.2.0/busted/context.lua000066400000000000000000000061711452214637700164760ustar00rootroot00000000000000local tablex = require 'pl.tablex' local function save() local g = {} for k,_ in next, _G, nil do g[k] = rawget(_G, k) end return { gmt = debug.getmetatable(_G), g = g, loaded = tablex.copy(package.loaded) } end local function restore(state) setmetatable(_G, state.gmt) 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 end return function() local context = {} local data = { descriptor = 'suite', attributes = {} } local parents = {} local children = {} local stack = {} local states = {} function context.ref() local ref = {} local ctx = data local function unwrap(element, levels) local levels = levels or 1 local parent = element for i = 1, levels do parent = ref.parent(parent) if not parent then break end end if not element.env then element.env = {} end setmetatable(element.env, { __newindex = function(self, key, value) if not parent then _G[key] = value else if not parent.env then parent.env = {} end parent.env[key] = value end end }) end local function push_state(current) local state = false if current.attributes.envmode == 'insulate' then state = save() elseif current.attributes.envmode == 'unwrap' then unwrap(current) elseif current.attributes.envmode == 'expose' then unwrap(current, 2) end table.insert(states, state) end local function pop_state(current) local state = table.remove(states) if current.attributes.envmode == 'expose' then states[#states] = states[#states] and save() end if state then restore(state) end end function ref.get(key) if not key then return ctx end return ctx[key] end function ref.set(key, value) ctx[key] = value end function ref.clear() data = { descriptor = 'suite', attributes = {} } parents = {} children = {} stack = {} states = {} ctx = data end function ref.attach(child) if not children[ctx] then children[ctx] = {} end parents[child] = ctx table.insert(children[ctx], child) end function ref.children(parent) return children[parent] or {} end function ref.parent(child) return parents[child] end function ref.push(current) if not parents[current] and current ~= data then error('Detached child. Cannot push.') end if ctx ~= current then push_state(current) end table.insert(stack, ctx) ctx = current end function ref.pop() local current = ctx ctx = table.remove(stack) if ctx ~= current then pop_state(current) end if not ctx then error('Context stack empty. Cannot pop.') end end return ref end return context end busted-2.2.0/busted/core.lua000066400000000000000000000217351452214637700157450ustar00rootroot00000000000000local getfenv = require 'busted.compatibility'.getfenv local setfenv = require 'busted.compatibility'.setfenv local unpack = require 'busted.compatibility'.unpack local path = require 'pl.path' local pretty = require 'pl.pretty' local system = require 'system' local throw = error local failureMt = { __index = {}, __tostring = function(e) return tostring(e.message) end, __type = 'failure' } local failureMtNoString = { __index = {}, __type = 'failure' } local pendingMt = { __index = {}, __tostring = function(p) return p.message end, __type = 'pending' } local function errortype(obj) local mt = debug.getmetatable(obj) if mt == failureMt or mt == failureMtNoString then return 'failure' elseif mt == pendingMt then return 'pending' end return 'error' end local function hasToString(obj) return type(obj) == 'string' or (debug.getmetatable(obj) or {}).__tostring end local function isCallable(obj) return type(obj) == 'function' or (debug.getmetatable(obj) or {}).__call end return function() local mediator = require 'mediator'() local busted = {} busted.version = '2.2.0' local root = require 'busted.context'() busted.context = root.ref() local environment = require 'busted.environment'(busted.context) busted.api = {} busted.executors = {} local executors = {} local eattributes = {} busted.gettime = system.gettime busted.monotime = system.monotime busted.sleep = system.sleep busted.status = require 'busted.status' function busted.getTrace(element, level, msg) local function trimTrace(info) local index = info.traceback:find('\n%s*%[C]') info.traceback = info.traceback:sub(1, index) return info end level = level or 3 local thisdir = path.dirname(debug.getinfo(1, 'Sl').source) local info = debug.getinfo(level, 'Sl') while info.what == 'C' or info.short_src:match('luassert[/\\].*%.lua$') or (info.source:sub(1,1) == '@' and thisdir == path.dirname(info.source)) do level = level + 1 info = debug.getinfo(level, 'Sl') end info.traceback = debug.traceback('', level) info.message = tostring(msg) local file = busted.getFile(element) return file and file.getTrace(file.name, info) or trimTrace(info) end function busted.rewriteMessage(element, message, trace) local file = busted.getFile(element) local msg = hasToString(message) and tostring(message) msg = msg or (message ~= nil and pretty.write(message) or 'Nil error') msg = (file and file.rewriteMessage and file.rewriteMessage(file.name, msg) or msg) local hasFileLine = msg:match('^[^\n]-:%d+: .*') if not hasFileLine then local trace = trace or busted.getTrace(element, 3, message) local fileline = trace.short_src .. ':' .. trace.currentline .. ': ' msg = fileline .. msg end return msg end function busted.publish(...) return mediator:publish(...) end function busted.subscribe(...) return mediator:subscribe(...) end function busted.unsubscribe(...) return mediator:removeSubscriber(...) end function busted.getFile(element) local parent = busted.context.parent(element) while parent do if parent.file then local file = parent.file[1] return { name = file.name, getTrace = file.run.getTrace, rewriteMessage = file.run.rewriteMessage } end if parent.descriptor == 'file' then return { name = parent.name, getTrace = parent.run.getTrace, rewriteMessage = parent.run.rewriteMessage } end parent = busted.context.parent(parent) end return parent end function busted.fail(msg, level) local rawlevel = (type(level) ~= 'number' or level <= 0) and level local level = level or 1 local _, emsg = pcall(throw, msg, rawlevel or level+2) local e = { message = emsg } setmetatable(e, hasToString(msg) and failureMt or failureMtNoString) throw(e, rawlevel or level+1) end function busted.pending(msg) local p = { message = msg } setmetatable(p, pendingMt) throw(p) end function busted.bindfenv(callable, var, value) local env = {} local f = (debug.getmetatable(callable) or {}).__call or callable setmetatable(env, { __index = getfenv(f) }) env[var] = value setfenv(f, env) end function busted.wrap(callable) if isCallable(callable) then -- prioritize __call if it exists, like in files environment.wrap((debug.getmetatable(callable) or {}).__call or callable) end end function busted.safe(descriptor, run, element) busted.context.push(element) local trace, message local status = 'success' local ret = { xpcall(run, function(msg) status = errortype(msg) trace = busted.getTrace(element, 3, msg) message = busted.rewriteMessage(element, msg, trace) end) } if not ret[1] then if status == 'success' then status = 'error' trace = busted.getTrace(element, 3, ret[2]) message = busted.rewriteMessage(element, ret[2], trace) elseif status == 'failure' and descriptor ~= 'it' then -- Only 'it' blocks can generate test failures. Failures in all -- other blocks are errors outside the test. status = 'error' end -- Note: descriptor may be different from element.descriptor when -- safe_publish is used (i.e. for test start/end). The safe_publish -- descriptor needs to be different for 'it' blocks so that we can -- detect that a 'failure' in a test start/end handler is not really -- a test failure, but rather an error outside the test, much like a -- failure in a support function (i.e. before_each/after_each or -- setup/teardown). busted.publish({ status, element.descriptor }, element, busted.context.parent(element), message, trace) end ret[1] = busted.status(status) busted.context.pop() return unpack(ret) end function busted.safe_publish(descriptor, channel, element, ...) local args = {...} local n = select('#', ...) if channel[2] == 'start' then element.starttick = busted.monotime() element.starttime = busted.gettime() elseif channel[2] == 'end' then element.endtime = busted.gettime() element.endtick = busted.monotime() element.duration = element.starttick and (element.endtick - element.starttick) end local status = busted.safe(descriptor, function() busted.publish(channel, element, unpack(args, 1, n)) end, element) return status:success() end function busted.exportApi(key, value) busted.api[key] = value end function busted.export(key, value) busted.exportApi(key, value) environment.set(key, value) end function busted.hide(key, value) busted.api[key] = nil environment.set(key, nil) end function busted.register(descriptor, executor, attributes) local alias = nil if type(executor) == 'string' then alias = descriptor descriptor = executor executor = executors[descriptor] attributes = attributes or eattributes[descriptor] executors[alias] = executor eattributes[alias] = attributes else if executor ~= nil and not isCallable(executor) then attributes = executor executor = nil end executors[descriptor] = executor eattributes[descriptor] = attributes end local publisher = function(name, fn) if not fn and type(name) == 'function' then fn = name name = alias elseif not fn then fn = attributes and attributes.default_fn end local trace local ctx = busted.context.get() if busted.context.parent(ctx) then trace = busted.getTrace(ctx, 3, name) end local publish = function(f) busted.publish({ 'register', descriptor }, name, f, trace, attributes) end if fn then publish(fn) else return publish end end local edescriptor = alias or descriptor busted.executors[edescriptor] = publisher busted.export(edescriptor, publisher) busted.subscribe({ 'register', descriptor }, function(name, fn, trace, attributes) local ctx = busted.context.get() local plugin = { descriptor = descriptor, attributes = attributes or {}, name = name, run = fn, trace = trace, starttick = nil, endtick = nil, starttime = nil, endtime = nil, duration = nil, } busted.context.attach(plugin) if not ctx[descriptor] then ctx[descriptor] = { plugin } else ctx[descriptor][#ctx[descriptor]+1] = plugin end end) end function busted.execute(current) if not current then current = busted.context.get() end for _, v in pairs(busted.context.children(current)) do local executor = executors[v.descriptor] if executor and not busted.skipAll then busted.safe(v.descriptor, function() executor(v) end, v) end end end return busted end busted-2.2.0/busted/done.lua000066400000000000000000000056551452214637700157450ustar00rootroot00000000000000local M = {} -- adds tokens to the current wait list, does not change order/unordered M.wait = function(self, ...) local tlist = { ... } for _, token in ipairs(tlist) do if type(token) ~= 'string' then error('Wait tokens must be strings. Got '..type(token), 2) end table.insert(self.tokens, token) end end -- set list as unordered, adds tokens to current wait list M.wait_unordered = function(self, ...) self.ordered = false self:wait(...) end -- set list as ordered, adds tokens to current wait list M.wait_ordered = function(self, ...) self.ordered = true self:wait(...) end -- generates a message listing tokens received/open M.tokenlist = function(self) local list if #self.tokens_done == 0 then list = 'No tokens received.' else list = 'Tokens received ('..tostring(#self.tokens_done)..')' local s = ': ' for _,t in ipairs(self.tokens_done) do list = list .. s .. '\''..t..'\'' s = ', ' end list = list .. '.' end if #self.tokens == 0 then list = list .. ' No more tokens expected.' else list = list .. ' Tokens not received ('..tostring(#self.tokens)..')' local s = ': ' for _, t in ipairs(self.tokens) do list = list .. s .. '\''..t..'\'' s = ', ' end list = list .. '.' end return list end -- marks a token as completed, checks for ordered/unordered, checks for completeness M.done = function(self, ...) self:_done(...) end -- extra wrapper for same error level constant as __call method M._done = function(self, token) if token then if type(token) ~= 'string' then error('Wait tokens must be strings. Got '..type(token), 3) end if self.ordered then if self.tokens[1] == token then table.remove(self.tokens, 1) table.insert(self.tokens_done, token) else if self.tokens[1] then error(('Bad token, expected \'%s\' got \'%s\'. %s'):format(self.tokens[1], token, self:tokenlist()), 3) else error(('Bad token (no more tokens expected) got \'%s\'. %s'):format(token, self:tokenlist()), 3) end end else -- unordered for i, t in ipairs(self.tokens) do if t == token then table.remove(self.tokens, i) table.insert(self.tokens_done, token) token = nil break end end if token then error(('Unknown token \'%s\'. %s'):format(token, self:tokenlist()), 3) end end end if not next(self.tokens) then -- no more tokens, so we're really done... self.done_cb() end end -- wraps a done callback into a done-object supporting tokens to sign-off M.new = function(done_callback) local obj = { tokens = {}, tokens_done = {}, done_cb = done_callback, ordered = true, -- default for sign off of tokens } return setmetatable( obj, { __call = function(self, ...) self:_done(...) end, __index = M, }) end return M busted-2.2.0/busted/environment.lua000066400000000000000000000016341452214637700173550ustar00rootroot00000000000000local setfenv = require 'busted.compatibility'.setfenv return function(context) local environment = {} local function getEnv(self, key) if not self then return nil end return self.env and self.env[key] or getEnv(context.parent(self), key) or _G[key] end local function setEnv(self, key, value) if not self.env then self.env = {} end self.env[key] = value end local function __index(self, key) return getEnv(context.get(), key) end local function __newindex(self, key, value) setEnv(context.get(), key, value) end local env = setmetatable({}, { __index=__index, __newindex=__newindex }) function environment.wrap(fn) return setfenv(fn, env) end function environment.set(key, value) local env = context.get('env') if not env then env = {} context.set('env', env) end env[key] = value end return environment end busted-2.2.0/busted/execute.lua000066400000000000000000000035511452214637700164530ustar00rootroot00000000000000local shuffle = require 'busted.utils'.shuffle local urandom = require 'busted.utils'.urandom local tablex = require 'pl.tablex' local function sort(elements) table.sort(elements, function(t1, t2) if t1.name and t2.name then return t1.name < t2.name end return t2.name ~= nil end) return elements end return function(busted) local block = require 'busted.block'(busted) local function execute(runs, options) local root = busted.context.get() local children = tablex.copy(busted.context.children(root)) local function suite_reset() local oldctx = busted.context.get() busted.context.clear() local ctx = busted.context.get() for k, v in pairs(oldctx) do ctx[k] = v end for _, child in ipairs(children) do for descriptor, _ in pairs(busted.executors) do child[descriptor] = nil end busted.context.attach(child) end busted.randomseed = tonumber(options.seed) or urandom() or os.time() end for i = 1, runs do if i > 1 then suite_reset() root = busted.context.get() busted.safe_publish('suite', { 'suite', 'reset' }, root, i, runs) end if options.sort then sort(busted.context.children(root)) elseif options.shuffle then root.randomseed = busted.randomseed shuffle(busted.context.children(root), busted.randomseed) end local seed = (busted.randomize and busted.randomseed or nil) if busted.safe_publish('suite', { 'suite', 'start' }, root, i, runs, seed) then if block.setup(root) then busted.execute() end block.lazyTeardown(root) block.teardown(root) end busted.safe_publish('suite', { 'suite', 'end' }, root, i, runs) if busted.skipAll then break end end end return execute end busted-2.2.0/busted/fixtures.lua000066400000000000000000000052671452214637700166700ustar00rootroot00000000000000local pl_path = require 'pl.path' local pl_utils = require 'pl.utils' 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 or load)(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 busted-2.2.0/busted/init.lua000066400000000000000000000102141452214637700157460ustar00rootroot00000000000000local function init(busted) local block = require 'busted.block'(busted) local file = function(file) busted.wrap(file.run) if busted.safe_publish('file', { 'file', 'start' }, file) then block.execute('file', file) end busted.safe_publish('file', { 'file', 'end' }, file) end local describe = function(describe) local parent = busted.context.parent(describe) if busted.safe_publish('describe', { 'describe', 'start' }, describe, parent) then block.execute('describe', describe) end busted.safe_publish('describe', { 'describe', 'end' }, describe, parent) end local it = function(element) local parent = busted.context.parent(element) local finally if not block.lazySetup(parent) then -- skip test if any setup failed return end if not element.env then element.env = {} end block.rejectAll(element) element.env.finally = function(fn) finally = fn end element.env.pending = busted.pending local pass, ancestor = block.execAll('before_each', parent, true) if pass then local status = busted.status('success') if busted.safe_publish('test', { 'test', 'start' }, element, parent) then status:update(busted.safe('it', element.run, element)) if finally then block.reject('pending', element) status:update(busted.safe('finally', finally, element)) end else status = busted.status('error') end busted.safe_publish('test', { 'test', 'end' }, element, parent, tostring(status)) end block.dexecAll('after_each', ancestor, true) end local pending = function(element) local parent = busted.context.parent(element) local status = 'pending' if not busted.safe_publish('it', { 'test', 'start' }, element, parent) then status = 'error' end busted.safe_publish('it', { 'test', 'end' }, element, parent, status) end busted.register('file', file, { envmode = 'insulate' }) busted.register('describe', describe) busted.register('insulate', 'describe', { envmode = 'insulate' }) busted.register('expose', 'describe', { envmode = 'expose' }) busted.register('it', it) busted.register('pending', pending, { default_fn = function() end }) busted.register('before_each', { envmode = 'unwrap' }) busted.register('after_each', { envmode = 'unwrap' }) busted.register('lazy_setup', { envmode = 'unwrap' }) busted.register('lazy_teardown', { envmode = 'unwrap' }) busted.register('strict_setup', { envmode = 'unwrap' }) busted.register('strict_teardown', { envmode = 'unwrap' }) busted.register('setup', 'strict_setup') busted.register('teardown', 'strict_teardown') busted.register('context', 'describe') busted.register('spec', 'it') busted.register('test', 'it') busted.hide('file') local assert = require 'luassert' local spy = require 'luassert.spy' local mock = require 'luassert.mock' local stub = require 'luassert.stub' local match = require 'luassert.match' 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.exportApi('publish', busted.publish) busted.exportApi('subscribe', busted.subscribe) busted.exportApi('unsubscribe', busted.unsubscribe) busted.exportApi('bindfenv', busted.bindfenv) busted.exportApi('fail', busted.fail) busted.exportApi('gettime', busted.gettime) busted.exportApi('monotime', busted.monotime) busted.exportApi('sleep', busted.sleep) busted.exportApi('parent', busted.context.parent) busted.exportApi('children', busted.context.children) busted.exportApi('version', busted.version) busted.bindfenv(assert, 'error', busted.fail) busted.bindfenv(assert.is_true, 'error', busted.fail) return busted end return setmetatable({}, { __call = function(self, busted) init(busted) return setmetatable(self, { __index = function(self, key) return busted.api[key] end, __newindex = function(self, key, value) error('Attempt to modify busted') end }) end }) busted-2.2.0/busted/languages/000077500000000000000000000000001452214637700162505ustar00rootroot00000000000000busted-2.2.0/busted/languages/ar.lua000066400000000000000000000033351452214637700173610ustar00rootroot00000000000000local s = require('say') s:set_namespace('ar') -- 'Pending: test.lua @ 12 \n description s:set('output.pending', 'عالِق') s:set('output.failure', 'فَشَل') s:set('output.failure', 'نَجاح') s:set('output.pending_plural', 'عالِق') s:set('output.failure_plural', 'إخْفاقات') s:set('output.success_plural', 'نَجاحات') s:set('output.pending_zero', 'عالِق') s:set('output.failure_zero', 'إخْفاقات') s:set('output.success_zero', 'نَجاحات') s:set('output.pending_single', 'عالِق') s:set('output.failure_single', 'فَشَل') s:set('output.success_single', 'نَجاح') s:set('output.seconds', 'ثَوانٍ') -- definitions following are not used within the 'say' namespace return { failure_messages = { 'فَشِلَت %d مِنْ الإِختِبارات', 'فَشِلَت إخْتِباراتُك', 'برمجيَّتُكَ ضَعيْفة، أنْصَحُكَ بالتَّقاعُد', 'تقع برمجيَّتُكَ في مَنطِقَةِ الخَطَر', 'أقترِحُ ألّا تَتَقَدَّم بالإختِبار، علَّ يبْقى الطابِقُ مَستوراَ', 'جَدَّتي، فِي أَثْناءِ نَومِها، تَكتبُ بَرمَجياتٍ أفْضلُ مِن هذه', 'يَوَدُّ ليْ مُساعَدَتُكْ، لَكِنّْ...' }, success_messages = { 'رائِع! تَمَّ إجْتِيازُ جَميعُ الإختِباراتِ بِنَجاحٍ', 'قُل ما شِئت، لا أكتَرِث: busted شَهِدَ لي!', 'حَقَّ عَليْكَ الإفتِخار', 'نَجاحٌ مُبْهِر!', 'عَليكَ بالإحتِفال؛ نَجَحَت جَميعُ التَجارُب' } } busted-2.2.0/busted/languages/de.lua000066400000000000000000000025731452214637700173520ustar00rootroot00000000000000local s = require('say') s:set_namespace('de') -- 'Pending: test.lua @ 12 \n description s:set('output.pending', 'Noch nicht erledigt') s:set('output.failure', 'Fehlgeschlagen') s:set('output.success', 'Erfolgreich') s:set('output.pending_plural', 'übersprungen') s:set('output.failure_plural', 'fehlgeschlagen') s:set('output.success_plural', 'erfolgreich') s:set('output.pending_zero', 'übersprungen') s:set('output.failure_zero', 'fehlgeschlagen') s:set('output.success_zero', 'erfolgreich') s:set('output.pending_single', 'übersprungen') s:set('output.failure_single', 'fehlgeschlagen') s:set('output.success_single', 'erfolgreich') s:set('output.seconds', 'Sekunden') -- definitions following are not used within the 'say' namespace return { failure_messages = { 'Du hast %d kaputte Tests.', 'Deine Tests sind kaputt.', 'Dein Code ist schlecht; du solltest dich schlecht fühlen.', 'Dein Code befindet sich in der Gefahrenzone.', 'Ein seltsames Spiel. Der einzig gewinnbringende Zug ist nicht zu testen.', 'Meine Großmutter hat auf einem 386er bessere Tests geschrieben.', 'Immer wenn ein Test fehlschlägt, stirbt ein kleines Kätzchen.', 'Das fühlt sich schlecht an, oder?' }, success_messages = { 'Yeah, die Tests laufen durch.', 'Fühlt sich gut an, oder?', 'Großartig!', 'Tests sind durchgelaufen, Zeit für ein Bier.', } } busted-2.2.0/busted/languages/en.lua000066400000000000000000000027621452214637700173640ustar00rootroot00000000000000local s = require('say') s:set_namespace('en') -- 'Pending: test.lua @ 12 \n description s:set('output.pending', 'Pending') s:set('output.failure', 'Failure') s:set('output.error', 'Error') s:set('output.success', 'Success') s:set('output.pending_plural', 'pending') s:set('output.failure_plural', 'failures') s:set('output.error_plural', 'errors') s:set('output.success_plural', 'successes') s:set('output.pending_zero', 'pending') s:set('output.failure_zero', 'failures') s:set('output.error_zero', 'errors') s:set('output.success_zero', 'successes') s:set('output.pending_single', 'pending') s:set('output.failure_single', 'failure') s:set('output.error_single', 'error') 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 { failure_messages = { 'You have %d busted specs', 'Your specs are busted', 'Your code is bad and you should feel bad', 'Your code is in the Danger Zone', 'Strange game. The only way to win is not to test', 'My grandmother wrote better specs on a 3 86', 'Every time there\'s a failure, drink another beer', 'Feels bad man' }, success_messages = { 'Aww yeah, passing specs', 'Doesn\'t matter, had specs', 'Feels good, man', 'Great success', 'Tests pass, drink another beer', } } busted-2.2.0/busted/languages/es.lua000066400000000000000000000031271452214637700173650ustar00rootroot00000000000000local s = require('say') s:set_namespace('es') -- 'Pending: test.lua @ 12 \n description s:set('output.pending', 'Pendiente') s:set('output.failure', 'Fallo') s:set('output.error', 'Error') s:set('output.success', 'Éxito') s:set('output.pending_plural', 'pendientes') s:set('output.failure_plural', 'fallos') s:set('output.error_plural', 'errores') s:set('output.success_plural', 'éxitos') s:set('output.pending_zero', 'pendientes') s:set('output.failure_zero', 'fallos') s:set('output.error_zero', 'errores') s:set('output.success_zero', 'éxitos') s:set('output.pending_single', 'pendiente') s:set('output.failure_single', 'fallo') s:set('output.error_single', 'error') s:set('output.success_single', 'éxito') s:set('output.seconds', 'segundos') s:set('output.no_test_files_match', 'Ningún fichero de prueba fue encontrado para el patrón de Lua: %s') -- definitions following are not used within the 'say' namespace return { failure_messages = { 'Tienes %d especificaciones o pruebas con errores', 'Tus especificaciones o pruebas están dañadas', 'Tu código es malo y deberías sentirte mal', 'Tu código está en la Zona de Peligro', 'Juego extraño. La única forma de ganar es omitiendo las pruebas', 'Mi abuela escribió mejores especificaciones en una 386', 'Cada vez que encuentres un fallo, tómate otra cerveza', 'Esto no está del todo bien amigo' }, success_messages = { 'Ohhh si! Pasando todas las pruebas', 'No importa, tenía especificaciones', 'Esto está bien amigo', 'Un exitazo', 'Pasaron las pruebas, tómate otra cerveza', } } busted-2.2.0/busted/languages/fr.lua000066400000000000000000000027171452214637700173710ustar00rootroot00000000000000local s = require('say') s:set_namespace('fr') -- 'Pending: test.lua @ 12 \n description s:set('output.pending', 'En attente') s:set('output.failure', 'Echec') s:set('output.success', 'Reussite') s:set('output.pending_plural', 'en attente') s:set('output.failure_plural', 'echecs') s:set('output.success_plural', 'reussites') s:set('output.pending_zero', 'en attente') s:set('output.failure_zero', 'echec') s:set('output.success_zero', 'reussite') s:set('output.pending_single', 'en attente') s:set('output.failure_single', 'echec') s:set('output.success_single', 'reussite') s:set('output.seconds', 'secondes') s:set('output.no_test_files_match', 'Aucun test n\'est pourrait trouvé qui corresponde au motif de Lua: %s') -- definitions following are not used within the 'say' namespace return { failure_messages = { 'Vous avez %d test(s) qui a/ont echoue(s)', 'Vos tests ont echoue.', 'Votre code source est mauvais et vous devrez vous sentir mal', 'Vous avez un code source de Destruction Massive', 'Jeu plutot etrange game. Le seul moyen de gagner est de ne pas l\'essayer', 'Meme ma grand-mere ecrivait de meilleurs tests sur un PIII x86', 'A chaque erreur, prenez une biere', 'Ca craint, mon pote' }, success_messages = { 'Oh yeah, tests reussis', 'Pas grave, y\'a eu du succes', 'C\'est du bon, mon pote. Que du bon!', 'Reussi, haut la main!', 'Test reussi. Un de plus. Offre toi une biere, sur mon compte!', } } busted-2.2.0/busted/languages/id.lua000066400000000000000000000031511452214637700173470ustar00rootroot00000000000000local s = require('say') s:set_namespace('id') -- 'Pending: test.lua @ 12 \n description s:set('output.pending', 'Tertunda') s:set('output.failure', 'Gagal') s:set('output.error', 'Salah') s:set('output.success', 'Berhasil') s:set('output.pending_plural', 'tertunda') s:set('output.failure_plural', 'kegagalan') s:set('output.error_plural', 'kesalahan') s:set('output.success_plural', 'berhasil') s:set('output.pending_zero', 'tertunda') s:set('output.failure_zero', 'kegagalan') s:set('output.error_zero', 'kesalahan') s:set('output.success_zero', 'berhasil') s:set('output.pending_single', 'tertunda') s:set('output.failure_single', 'gagal') s:set('output.error_single', 'salah') s:set('output.success_single', 'berhasil') s:set('output.seconds', 'detik') s:set('output.no_test_files_match', 'Tidak ada file uji coba yang cocok dengan pola (lua): %s') s:set('output.file_not_found', 'Tidak dapat menemukan file ataupun direktori: %s') -- definitions following are not used within the 'say' namespace return { failure_messages = { 'Anda memiliki %d spesifikasi yang rusak', 'Spesifikasi anda rusak', 'Kode anda buruk, sebaiknya anda merasa buruk', 'Kode anda ada di zona berbahaya', 'Percobaan yang aneh. Satu-satunya cara untuk menang bukanlah dengan menguji', 'Nenek saya menulis spesifikasi lebih baik dalam 3 86', 'Setiap saat ada kegagalan, minum bajigur lagi', 'Merasa buruklah bung' }, success_messages = { 'Aww yeah, spesifikasi dipenuhi', 'Tidak masalah, memenuhi spesifikasi', 'Spertinya baik, bung', 'Sukses besar', 'Uji coba berhasil, minum bajigur lagi', } } busted-2.2.0/busted/languages/is.lua000066400000000000000000000024421452214637700173700ustar00rootroot00000000000000local 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ð!', } } busted-2.2.0/busted/languages/it.lua000066400000000000000000000032001452214637700173620ustar00rootroot00000000000000local 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" } } busted-2.2.0/busted/languages/ja.lua000066400000000000000000000026701452214637700173520ustar00rootroot00000000000000local s = require('say') s:set_namespace('ja') -- 'Pending: test.lua @ 12 \n description s:set('output.pending', '保留') s:set('output.failure', '失敗') s:set('output.success', '成功') s:set('output.pending_plural', '保留') s:set('output.failure_plural', '失敗') s:set('output.success_plural', '成功') s:set('output.pending_zero', '保留') s:set('output.failure_zero', '失敗') s:set('output.success_zero', '成功') s:set('output.pending_single', '保留') s:set('output.failure_single', '失敗') s:set('output.success_single', '成功') s:set('output.seconds', '秒') -- definitions following are not used within the 'say' namespace return { failure_messages = { '%d個の仕様が破綻しています', '仕様が破綻しています', 'あなたの書くコードは良くないので反省するべきです', 'あなたの書くコードは危険地帯にあります', 'おかしなゲームです。勝利する唯一の方法はテストをしないことです', '私の祖母でもPentium Pentium III x86の上でもっといいコードを書いていましたよ', 'いつも失敗しているのでビールでも飲みましょう', '罪悪感を持ちましょう', }, success_messages = { 'オォーイェー、テストが通った', '問題ない、テストがある', '順調ですね', '大成功', 'テストが通ったし、ビールでも飲もう', } } busted-2.2.0/busted/languages/ko.lua000066400000000000000000000030601452214637700173630ustar00rootroot00000000000000local s = require("say") s:set_namespace("ko") -- 'Pending: test.lua @ 12 \n description s:set("output.pending", "보류") s:set("output.failure", "실패") s:set("output.error", "에러") s:set("output.success", "성공") s:set("output.pending_plural", "보류") s:set("output.failure_plural", "실패") s:set("output.error_plural", "에러") s:set("output.success_plural", "성공") s:set("output.pending_zero", "보류") s:set("output.failure_zero", "실패") s:set("output.error_zero", "에러") s:set("output.success_zero", "성공") s:set("output.pending_single", "보류") s:set("output.failure_single", "실패") s:set("output.error_single", "에러") s:set("output.success_single", "성공") s:set("output.seconds", "초") s:set("output.no_test_files_match", "Lua 패턴과 일치하는 테스트 파일을 찾을 수 없습니다: %s") s:set("output.file_not_found", "파일 또는 디렉토리를 찾을 수 없습니다: %s") -- definitions following are not used within the 'say' namespace return { failure_messages = { "%d 개의 스펙이 엉망이야", "스펙이 엉망이야", "코드가 별로야 반성해", "코드가 위험 구역에 있어", "테스트를 안하는게 나을 수도 있어", "우리 할머니도 386에서 더 나은 테스트를 작성했어", "매번 실패하니까 맥주나 마시자", "유감이야 친구", }, success_messages = { "아싸, 스펙 통과", "괜찮아, 테스트가 있어", "느낌이 좋아", "대성공", "테스트 통과, 맥주나 마시자", }, } busted-2.2.0/busted/languages/nl.lua000066400000000000000000000024051452214637700173650ustar00rootroot00000000000000local s = require('say') s:set_namespace('nl') -- 'Pending: test.lua @ 12 \n description s:set('output.pending', 'Hangend') s:set('output.failure', 'Mislukt') s:set('output.success', 'Succes') s:set('output.pending_plural', 'hangenden') s:set('output.failure_plural', 'mislukkingen') s:set('output.success_plural', 'successen') s:set('output.pending_zero', 'hangend') s:set('output.failure_zero', 'mislukt') s:set('output.success_zero', 'successen') s:set('output.pending_single', 'hangt') s:set('output.failure_single', 'mislukt') s:set('output.success_single', 'succes') s:set('output.seconds', 'seconden') -- definitions following are not used within the 'say' namespace return { failure_messages = { 'Je hebt %d busted specs', 'Je specs zijn busted', 'Je code is slecht en zo zou jij je ook moeten voelen', 'Je code zit in de Gevaren Zone', 'Vreemd spelletje. The enige manier om te winnen is door niet te testen', 'Mijn oma schreef betere specs op een 3 86', 'Elke keer dat iets mislukt, nog een biertje drinken', 'Voelt klote man' }, success_messages = { 'Joeperdepoep, de specs zijn er door', 'Doet er niet toe, had specs', 'Voelt goed, man', 'Fantastisch success', 'Testen geslaagd, neem nog een biertje', } } busted-2.2.0/busted/languages/pt-BR.lua000066400000000000000000000030061452214637700176760ustar00rootroot00000000000000local s = require('say') s:set_namespace('pt-BR') -- 'Pending: test.lua @ 12 \n description s:set('output.pending', 'Pendente') s:set('output.failure', 'Falha') s:set('output.error', 'Erro') s:set('output.success', 'Sucesso') s:set('output.pending_plural', 'pendentes') s:set('output.failure_plural', 'falhas') s:set('output.error_plural', 'erros') s:set('output.success_plural', 'sucessos') s:set('output.pending_zero', 'pendentes') s:set('output.failure_zero', 'falhas') s:set('output.error_zero', 'erros') s:set('output.success_zero', 'sucessos') s:set('output.pending_single', 'pendente') s:set('output.failure_single', 'falha') s:set('output.error_single', 'erro') s:set('output.success_single', 'sucesso') s:set('output.seconds', 'segundos') s:set('output.no_test_files_match', 'Nenhum arquivo de teste encontrado com o padrão do Lua: %s') -- definitions following are not used within the 'say' namespace return { failure_messages = { 'Você tem %d testes quebrados', 'Seus testes estão quebrados', 'Seu código está mal e você deveria sentir-se mal', 'Seu código está na zona de perigo', 'Jogo estranho. A única forma de ganhar é não testar', 'Minha avó escreveu testes melhores em um 386', 'Cada vez que encontrar uma falha, beba outra cerveja', 'Isso não está poético' }, success_messages = { 'Perfeito! Todos os testes estão passando', 'Não se preocupe, tem testes', 'Isso está poético', 'Excelente', 'Os testes passaram, beba outra cerveja', } } busted-2.2.0/busted/languages/ro.lua000066400000000000000000000031211452214637700173700ustar00rootroot00000000000000local 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', } } busted-2.2.0/busted/languages/ru.lua000066400000000000000000000021611452214637700174010ustar00rootroot00000000000000local s = require('say') s:set_namespace('ru') -- 'Pending: test.lua @ 12 \n description s:set('output.pending', 'Ожидает') s:set('output.failure', 'Поломалcя') s:set('output.success', 'Прошeл') s:set('output.pending_plural', 'ожидают') s:set('output.failure_plural', 'поломалиcь') s:set('output.success_plural', 'прошли') s:set('output.pending_zero', 'ожидающих') s:set('output.failure_zero', 'поломанных') s:set('output.success_zero', 'прошедших') s:set('output.pending_single', 'ожидает') s:set('output.failure_single', 'поломался') s:set('output.success_single', 'прошел') s:set('output.seconds', 'секунд') ---- definitions following are not used within the 'say' namespace return { failure_messages = { 'У тебя %d просратых тестов', 'Твои тесты поломаны', 'Твой код говеный - пойди напейся!' }, success_messages = { 'Поехали!', 'Жизнь - хороша!', 'Ффух в этот раз пронесло!', 'Ура!' } } busted-2.2.0/busted/languages/th.lua000066400000000000000000000041021452214637700173630ustar00rootroot00000000000000local s = require('say') s:set_namespace('th') -- 'Pending: test.lua @ 12 \n description s:set('output.pending', 'อยู่ระหว่างดำเนินการ') s:set('output.failure', 'ล้มเหลว') s:set('output.success', 'สำเร็จ') s:set('output.pending_plural', 'อยู่ระหว่างดำเนินการ') s:set('output.failure_plural', 'ล้มเหลว') s:set('output.success_plural', 'สำเร็จ') s:set('output.pending_zero', 'อยู่ระหว่างดำเนินการ') s:set('output.failure_zero', 'ล้มเหลว') s:set('output.success_zero', 'สำเร็จ') s:set('output.pending_single', 'อยู่ระหว่างดำเนินการ') s:set('output.failure_single', 'ล้มเหลว') s:set('output.success_single', 'สำเร็จ') s:set('output.seconds', 'วินาที') -- definitions following are not used within the 'say' namespace return { failure_messages = { 'คุณมี %d บัสเต็ดสเปค', 'สเปคของคุณคือ บัสเต็ด', 'โค้ดของคุณไม่ดีเลย คุณควรรู้สึกแย่น่ะ', 'โค้ดของคุณอยู่ในเขตอันตราย!', 'มันแปลกๆน่ะ วิธีที่จะชนะไม่ได้มีแค่เทสอย่างเดียว', 'ยายผมเขียนสเปคดีกว่านี้อีก บนเครื่อง 386', 'ทุกๆครั้งที่ล้มเหลว, ดื่มเบียร์แก้วใหม่', 'แย่จัง นายท่าน' }, success_messages = { 'อุ๊ตะ!!!, สเปคผ่าน!', 'ไม่สำคัญ, มีสเปค', 'ฟินเลยดิ นายท่าน', 'สำเร็จ ยอดเยี่ยม', 'เทสผ่าน, ดื่มเบียร์ๆๆๆ', } } busted-2.2.0/busted/languages/ua.lua000066400000000000000000000021431452214637700173600ustar00rootroot00000000000000local s = require('say') s:set_namespace('ua') -- 'Pending: test.lua @ 12 \n description s:set('output.pending', 'Очікує') s:set('output.failure', 'Зламався') s:set('output.success', 'Пройшов') s:set('output.pending_plural', 'очікують') s:set('output.failure_plural', 'зламались') s:set('output.success_plural', 'пройшли') s:set('output.pending_zero', 'очікуючих') s:set('output.failure_zero', 'зламаних') s:set('output.success_zero', 'пройдених') s:set('output.pending_single', 'очікує') s:set('output.failure_single', 'зламався') s:set('output.success_single', 'пройшов') s:set('output.seconds', 'секунд') ---- definitions following are not used within the 'say' namespace return { failure_messages = { 'Ти зрадив %d тестів!', 'Ой йо..', 'Вороги поламали наші тести!' }, success_messages = { 'Слава Україні! Героям Слава!', 'Тестування успішно пройдено!', 'Всі баги знищено!' } } busted-2.2.0/busted/languages/zh.lua000066400000000000000000000023211452214637700173720ustar00rootroot00000000000000local s = require('say') s:set_namespace('zh') -- 'Pending: test.lua @ 12 \n description s:set('output.pending', '开发中') s:set('output.failure', '失败') s:set('output.success', '成功') s:set('output.pending_plural', '开发中') s:set('output.failure_plural', '失败') s:set('output.success_plural', '成功') s:set('output.pending_zero', '开发中') s:set('output.failure_zero', '失败') s:set('output.success_zero', '成功') s:set('output.pending_single', '开发中') s:set('output.failure_single', '失败') s:set('output.success_single', '成功') s:set('output.seconds', '秒') -- definitions following are not used within the 'say' namespace return { failure_messages = { '你一共提交了[%d]个测试用例', '又出错了!', '到底哪里不对呢?', '出错了,又要加班了!', '囧,出Bug了!', '据说比尔盖兹也写了一堆Bug,别灰心!', '又出错了,休息一下吧', 'Bug好多,心情好坏!' }, success_messages = { '牛X,测试通过了!', '测试通过了,感觉不错吧,兄弟!', '哥们,干得漂亮!', '终于通过了!干一杯先!', '阿弥陀佛~,菩萨显灵了!', } } busted-2.2.0/busted/luajit.lua000066400000000000000000000031671452214637700163040ustar00rootroot00000000000000local isJit = (tostring(assert):match('builtin') ~= nil) if not isJit then return function() end end -- pre-load the ffi module, such that it becomes part of the environment -- and Busted will not try to GC and reload it. The ffi is not suited -- for that and will occasionally segfault if done so. local ffi = require "ffi" -- patching assumes; -- * first parameter to be a unique key to identify repeated calls -- * only a single return value local function patch_with_return_value(func_name) local original = ffi[func_name] local original_store = {} ffi[func_name] = function (primary, ...) if original_store[primary] then return original_store[primary] end local success, result, err = pcall(original, primary, ...) if not success then -- hard error was thrown error(result, 2) end if not result then -- soft error was returned return result, err end -- it worked, store and return original_store[primary] = result return result end end local function patch_without_return_value(func_name) local original = ffi[func_name] local original_store = {} ffi[func_name] = function (primary, ...) if original_store[primary] then return end local success, result = pcall(original, primary, ...) if not success then -- hard error was thrown error(result, 2) end -- store and return original_store[primary] = true return result end end return function() patch_without_return_value("cdef") patch_with_return_value("typeof") patch_with_return_value("metatype") patch_with_return_value("load") end busted-2.2.0/busted/modules/000077500000000000000000000000001452214637700157525ustar00rootroot00000000000000busted-2.2.0/busted/modules/cli.lua000066400000000000000000000266151452214637700172360ustar00rootroot00000000000000local utils = require 'busted.utils' local path = require 'pl.path' local tablex = require 'pl.tablex' local exit = require 'busted.compatibility'.exit local execute = require 'busted.compatibility'.execute return function(options) local appName = '' local options = options or {} local cli = require 'cliargs.core'() local configLoader = require 'busted.modules.configuration_loader'() -- Default cli arg values local defaultOutput = options.output or 'utfTerminal' local defaultLoaders = 'lua,moonscript' local defaultPattern = '_spec' local defaultSeed = '/dev/urandom or os.time()' local lpathprefix = './src/?.lua;./src/?/?.lua;./src/?/init.lua' local cpathprefix = path.is_windows and './csrc/?.dll;./csrc/?/?.dll;' or './csrc/?.so;./csrc/?/?.so;' local cliArgsParsed = {} local function makeList(values) return type(values) == 'table' and values or { values } end local function fixupList(values, sep) local sep = sep or ',' local list = type(values) == 'table' and values or { values } local olist = {} for _, v in ipairs(list) do tablex.insertvalues(olist, utils.split(v, sep)) end return olist end local function processOption(key, value, altkey, opt) if altkey then cliArgsParsed[altkey] = value end cliArgsParsed[key] = value return true end local function processArg(key, value) cliArgsParsed[key] = value return true end local function processArgList(key, value) local list = cliArgsParsed[key] or {} tablex.insertvalues(list, utils.split(value, ',')) processArg(key, list) return true end local function processNumber(key, value, altkey, opt) local number = tonumber(value) if not number then return nil, 'argument to ' .. opt:gsub('=.*', '') .. ' must be a number' end if altkey then cliArgsParsed[altkey] = number end cliArgsParsed[key] = number return true end local function processList(key, value, altkey, opt) local list = cliArgsParsed[key] or {} tablex.insertvalues(list, utils.split(value, ',')) processOption(key, list, altkey, opt) return true end local function processMultiOption(key, value, altkey, opt) local list = cliArgsParsed[key] or {} table.insert(list, value) processOption(key, list, altkey, opt) return true end local function append(s1, s2, sep) local sep = sep or '' if not s1 then return s2 end return s1 .. sep .. s2 end local function processLoaders(key, value, altkey, opt) local loaders = append(cliArgsParsed[key], value, ',') processOption(key, loaders, altkey, opt) return true end local function processPath(key, value, altkey, opt) local lpath = append(cliArgsParsed[key], value, ';') processOption(key, lpath, altkey, opt) return true end local function processDir(key, value, altkey, opt) local dpath = path.normpath(path.join(cliArgsParsed[key] or '', value)) processOption(key, dpath, altkey, opt) return true end local function processShuffle(key, value, altkey, opt) processOption('shuffle-files', value, nil, opt) processOption('shuffle-tests', value, nil, opt) end local function processSort(key, value, altkey, opt) processOption('sort-files', value, nil, opt) processOption('sort-tests', value, nil, opt) end -- Load up the command-line interface options cli:flag('--version', 'prints the program version and exits', false, processOption) if not options.standalone then cli:splat('ROOT', 'test script file/folder. Folders will be traversed for any file that matches the --pattern option.', 'spec', 999, processArgList) cli:option('-p, --pattern=PATTERN', 'only run test files matching the Lua pattern', defaultPattern, processMultiOption) cli:option('--exclude-pattern=PATTERN', 'do not run test files matching the Lua pattern, takes precedence over --pattern', nil, processMultiOption) end 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, 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) cli:option('--name=NAME', 'run test with the given full name', {}, processMultiOption) cli:option('--filter-out=PATTERN', 'do not run test names matching the Lua pattern, takes precedence over --filter', {}, processMultiOption) cli:option('--exclude-names-file=FILE', 'do not run the tests with names listed in the given file, takes precedence over --filter', nil, processOption) cli:option('--log-success=FILE', 'append the name of each successful test to the given file', nil, processOption) cli:option('-m, --lpath=PATH', 'optional path to be prefixed to the Lua module search path', lpathprefix, processPath) cli:option('--cpath=PATH', 'optional path to be prefixed to the Lua C module search path', cpathprefix, processPath) cli:option('-r, --run=RUN', 'config to run from .busted file', nil, processOption) cli:option('--repeat=COUNT', 'run the tests repeatedly', '1', processNumber) cli:option('--seed=SEED', 'random seed value to use for shuffling test order', defaultSeed, processNumber) cli:option('--lang=LANG', 'language for error messages', 'en', processOption) cli:option('--loaders=NAME', 'test file loaders', defaultLoaders, processLoaders) cli:option('--helper=PATH', 'A helper script that is run before tests', nil, processOption) cli:option('--lua=LUA', 'The path to the lua interpreter busted should run under', nil, processOption) cli:option('-Xoutput OPTION', 'pass `OPTION` as an option to the output handler. If `OPTION` contains commas, it is split into multiple options at the commas.', {}, processList) cli:option('-Xhelper OPTION', 'pass `OPTION` as an option to the helper script. If `OPTION` contains commas, it is split into multiple options at the commas.', {}, processList) cli:flag('-c, --[no-]coverage', 'do code coverage analysis (requires `LuaCov` to be installed)', false, processOption) cli:flag('-v, --[no-]verbose', 'verbose output of errors', false, processOption) cli:flag('-s, --[no-]enable-sound', 'executes `say` command if available', false, processOption) cli:flag('-l, --list', 'list the names of all tests instead of running them', false, processOption) cli:flag('--ignore-lua', 'Whether or not to ignore the lua directive', false, processOption) cli:flag('--[no-]lazy', 'use lazy setup/teardown as the default', false, processOption) cli:flag('--[no-]auto-insulate', 'enable file insulation', true, processOption) cli:flag('-k, --[no-]keep-going', 'continue as much as possible after an error or failure', true, processOption) cli:flag('-R, --[no-]recursive', 'recurse into subdirectories', true, processOption) cli:flag('--[no-]shuffle', 'randomize file and test order, takes precedence over --sort (--shuffle-test and --shuffle-files)', processShuffle) cli:flag('--[no-]shuffle-files', 'randomize file execution order, takes precedence over --sort-files', processOption) cli:flag('--[no-]shuffle-tests', 'randomize test order within a file, takes precedence over --sort-tests', processOption) cli:flag('--[no-]sort', 'sort file and test order (--sort-tests and --sort-files)', processSort) cli:flag('--[no-]sort-files', 'sort file execution order', processOption) cli:flag('--[no-]sort-tests', 'sort test order within a file', processOption) cli:flag('--[no-]suppress-pending', 'suppress `pending` test output', false, processOption) cli:flag('--[no-]defer-print', 'defer print to when test suite is complete', false, processOption) local function parse(args) -- Parse the cli arguments local cliArgs, cliErr = cli:parse(args) if not cliArgs then return nil, appName .. ': error: ' .. cliErr .. '; re-run with --help for usage.' end -- Load busted config file if available 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 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) end -- Switch lua, we should rebuild this feature once luarocks changes how it -- handles executeable lua files. if cliArgs['lua'] and not cliArgs['ignore-lua'] then local _, code = execute( cliArgs['lua']..' '..args[0]..' --ignore-lua '..table.concat(args, ' ') ) exit(code) end -- Ensure multi-options are in a list cliArgs.e = makeList(cliArgs.e) cliArgs.pattern = makeList(cliArgs.pattern) cliArgs.p = cliArgs.pattern cliArgs['exclude-pattern'] = makeList(cliArgs['exclude-pattern']) cliArgs.filter = makeList(cliArgs.filter) cliArgs['filter-out'] = makeList(cliArgs['filter-out']) -- Fixup options in case options from config file are not of the right form cliArgs.tags = fixupList(cliArgs.tags) cliArgs.t = cliArgs.tags cliArgs['exclude-tags'] = fixupList(cliArgs['exclude-tags']) cliArgs.loaders = fixupList(cliArgs.loaders) cliArgs.Xoutput = fixupList(cliArgs.Xoutput) cliArgs.Xhelper = fixupList(cliArgs.Xhelper) -- We report an error if the same tag appears in both `options.tags` -- and `options.excluded_tags` because it does not make sense for the -- user to tell Busted to include and exclude the same tests at the -- same time. for _, excluded in pairs(cliArgs['exclude-tags']) do for _, included in pairs(cliArgs.tags) do if excluded == included then return nil, appName .. ': error: Cannot use --tags and --exclude-tags for the same tags' end end end cliArgs['repeat'] = tonumber(cliArgs['repeat']) return cliArgs end return { set_name = function(self, name) appName = name return cli:set_name(name) end, set_silent = function(self, name) appName = name return cli:set_silent(name) end, parse = function(self, args) return parse(args) end } end busted-2.2.0/busted/modules/configuration_loader.lua000066400000000000000000000017351452214637700226600ustar00rootroot00000000000000local tablex = require 'pl.tablex' return function() -- Function to load the .busted configuration file if available local loadBustedConfigurationFile = function(configFile, config, defaults) if type(configFile) ~= 'table' then return nil, '.busted file does not return a table.' end defaults = defaults or {} local run = config.run or defaults.run if run and run ~= '' then local runConfig = configFile[run] if type(runConfig) == 'table' then config = tablex.merge(runConfig, config, true) else return nil, 'Task `' .. run .. '` not found, or not a table.' end elseif type(configFile.default) == 'table' then config = tablex.merge(configFile.default, config, true) end if type(configFile._all) == 'table' then config = tablex.merge(configFile._all, config, true) end config = tablex.merge(defaults, config, true) return config end return loadBustedConfigurationFile end busted-2.2.0/busted/modules/files/000077500000000000000000000000001452214637700170545ustar00rootroot00000000000000busted-2.2.0/busted/modules/files/lua.lua000066400000000000000000000010241452214637700203350ustar00rootroot00000000000000local path = require 'pl.path' local ret = {} local getTrace = function(filename, info) local index = info.traceback:find('\n%s*%[C]') info.traceback = info.traceback:sub(1, index) return info end ret.match = function(busted, filename) return path.extension(filename) == '.lua' end ret.load = function(busted, filename) local file, err = loadfile(filename) if not file then busted.publish({ 'error', 'file' }, { descriptor = 'file', name = filename }, nil, err, {}) end return file, getTrace end return ret busted-2.2.0/busted/modules/files/moonscript.lua000066400000000000000000000053741452214637700217650ustar00rootroot00000000000000local path = require 'pl.path' local ok, moonscript, line_tables, util = pcall(function() return require 'moonscript', require 'moonscript.line_tables', require 'moonscript.util' end) local _cache = {} -- find the line number of `pos` chars into fname local lookup_line = function(fname, pos) if not _cache[fname] then local f = io.open(fname) _cache[fname] = f:read('*a') f:close() end return util.pos_to_line(_cache[fname], pos) end local rewrite_linenumber = function(fname, lineno) local tbl = line_tables['@' .. fname] if fname and tbl then for i = lineno, 0 ,-1 do if tbl[i] then return lookup_line(fname, tbl[i]) end end end return lineno end local rewrite_filename = function(filename) -- sometimes moonscript gives files like [string "./filename.moon"], so -- we'll chop it up to only get the filename. return filename:match('string "(.+)"') or filename end local rewrite_traceback = function(fname, trace) local rewrite_one = function(line, pattern, sub) if line == nil then return '' end local fname, lineno = line:match(pattern) if fname and lineno then fname = rewrite_filename(fname) local new_lineno = rewrite_linenumber(fname, tonumber(lineno)) if new_lineno then line = line:gsub(sub:format(tonumber(lineno)), sub:format(tonumber(new_lineno))) end end return line end local lines = {} local j = 0 for line in trace:gmatch('[^\r\n]+') do j = j + 1 line = rewrite_one(line, '%s*(.-):(%d+): ', ':%d:') line = rewrite_one(line, '<(.*):(%d+)>', ':%d>') lines[j] = line end return '\n' .. table.concat(lines, trace:match('[\r\n]+')) .. '\n' end local ret = {} local getTrace = function(filename, info) local index = info.traceback:find('\n%s*%[C]') info.traceback = info.traceback:sub(1, index) info.short_src = rewrite_filename(info.short_src) info.traceback = rewrite_traceback(filename, info.traceback) info.linedefined = rewrite_linenumber(filename, info.linedefined) info.currentline = rewrite_linenumber(filename, info.currentline) return info end local rewriteMessage = function(filename, message) local fname, line, msg = message:match('^([^\n]-):(%d+): (.*)') if not fname then return message end fname = rewrite_filename(fname) line = rewrite_linenumber(fname, tonumber(line)) return fname .. ':' .. tostring(line) .. ': ' .. msg end ret.match = function(busted, filename) return ok and path.extension(filename) == '.moon' end ret.load = function(busted, filename) local file, err = moonscript.loadfile(filename) if not file then busted.publish({ 'error', 'file' }, { descriptor = 'file', name = filename }, nil, err, {}) end return file, getTrace, rewriteMessage end return ret busted-2.2.0/busted/modules/files/terra.lua000066400000000000000000000016271452214637700207020ustar00rootroot00000000000000local path = require 'pl.path' local ret = {} local terra_available, terralib = not not terralib, terralib --luacheck: ignore if not terra_available then terra_available, terralib = pcall(require, 'terra') --otherwise, attempt to load terra as a shared library end local getTrace = function(filename, info) local index = info.traceback:find('\n%s*%[C]') info.traceback = info.traceback:sub(1, index) return info end ret.match = function(busted, filename) return path.extension(filename) == '.t' end ret.load = function(busted, filename) if not terra_available then error "unable to load terra, try running without terra language support enabled or installing terra." else local file, err = terralib.loadfile(filename) if not file then busted.publish({ 'error', 'file' }, { descriptor = 'file', name = filename }, nil, err, {}) end return file, getTrace end end return ret busted-2.2.0/busted/modules/filter_loader.lua000066400000000000000000000125401452214637700212720ustar00rootroot00000000000000return function() local function filter(busted, options) local getFullName = function(name) local parent = busted.context.get() local names = { name } while parent and (parent.name or parent.descriptor) and parent.descriptor ~= 'file' do table.insert(names, 1, parent.name or parent.descriptor) parent = busted.context.parent(parent) end return table.concat(names, ' ') end local hasTag = function(name, tag) local found = name:find('#' .. tag) return (found ~= nil) end local filterExcludeTags = function(name) for i, tag in pairs(options.excludeTags) do if hasTag(name, tag) then return nil, false end end return nil, true end local filterTags = function(name) local fullname = getFullName(name) for i, tag in pairs(options.tags) do if hasTag(fullname, tag) then return nil, true end end return nil, (#options.tags == 0) end local filterOutNames = function(name) for _, filter in pairs(options.filterOut) do if getFullName(name):find(filter) ~= nil then return nil, false end end return nil, true end local excludeNames = {} if options.excludeNamesFile then for name in io.lines(options.excludeNamesFile) do table.insert(excludeNames, name) end end local excludeNamesFile = function(name) for _, filter in ipairs(excludeNames) do if getFullName(name) == filter then return nil, false end end return nil, true end local name = function(name) for _, candidate in pairs(options.name) do if string.find(candidate, getFullName(name), 1, true) then return nil, true end end return nil, (#options.name == 0) end local filterNames = function(name) for _, filter in pairs(options.filter) do if getFullName(name):find(filter) ~= nil then return nil, true end end return nil, (#options.filter == 0) end 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 end local ignoreAll = 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 local applyFilter = function(descriptors, name, fn) if options[name] and options[name] ~= '' then for _, descriptor in ipairs(descriptors) do busted.subscribe({ 'register', descriptor }, fn, { priority = 1 }) end 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 }) 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) applyFilter({ 'strict_setup', 'strict_teardown' }, 'nokeepgoing', skipOnError) applyFilter({ 'setup', 'teardown', 'before_each', 'after_each' }, 'nokeepgoing', skipOnError) applyFilter({ 'file', 'describe', 'it', 'pending' }, 'nokeepgoing', skipOnError) -- The following filters are applied in reverse order applyFilter({ 'it', 'pending' } , 'filter' , filterNames ) applyFilter({ 'describe', 'it', 'pending' }, 'name' , name ) applyFilter({ 'describe', 'it', 'pending' }, 'filterOut' , filterOutNames ) applyFilter({ 'describe', 'it', 'pending' }, 'excludeNamesFile', excludeNamesFile ) applyFilter({ 'it', 'pending' } , 'tags' , filterTags ) applyFilter({ 'describe', 'it', 'pending' }, 'excludeTags' , filterExcludeTags ) end return filter end busted-2.2.0/busted/modules/helper_loader.lua000066400000000000000000000015241452214637700212640ustar00rootroot00000000000000local 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 = _G.arg local success, err = pcall(function() local fn utils.copy_interpreter_args(options.arguments) _G.arg = options.arguments if helper:match('%.lua$') then fn = dofile(path.normpath(helper)) elseif hasMoon and helper:match('%.moon$') then fn = moonscript.dofile(path.normpath(helper)) else fn = require(helper) end if type(fn) == 'function' then assert(fn(busted, helper, options)) end end) arg = old_arg --luacheck: ignore if not success then return nil, err end return true end return loadHelper end busted-2.2.0/busted/modules/luacov.lua000066400000000000000000000013311452214637700177440ustar00rootroot00000000000000return function() -- Function to initialize luacov if available local loadLuaCov = function(config) local result, luacov = pcall(require, 'luacov.runner') if not result then return nil, 'LuaCov not found on the system, try running without --coverage option, or install LuaCov first' end -- call it to start luacov(config) -- exclude busted files table.insert(luacov.configuration.exclude, 'busted_bootstrap$') table.insert(luacov.configuration.exclude, 'busted%.') table.insert(luacov.configuration.exclude, 'luassert%.') table.insert(luacov.configuration.exclude, 'say%.') table.insert(luacov.configuration.exclude, 'pl%.') return true end return loadLuaCov end busted-2.2.0/busted/modules/output_handler_loader.lua000066400000000000000000000021531452214637700230410ustar00rootroot00000000000000local path = require 'pl.path' local hasMoon, moonscript = pcall(require, 'moonscript') local utils = require 'busted.utils' return function() local loadOutputHandler = function(busted, output, options) local handler utils.copy_interpreter_args(options.arguments) local success, err = pcall(function() if output:match('%.lua$') then handler = dofile(path.normpath(output)) elseif hasMoon and output:match('%.moon$') then handler = moonscript.dofile(path.normpath(output)) else handler = require('busted.outputHandlers.' .. output) end end) if not success and err:match("module '.-' not found:") then success, err = pcall(function() handler = require(output) end) end if not success then busted.publish({ 'error', 'output' }, { descriptor = 'output', name = output }, nil, err, {}) handler = require('busted.outputHandlers.' .. options.defaultOutput) end if options.enableSound then require 'busted.outputHandlers.sound'(options) end handler(options):subscribe(options) end return loadOutputHandler end busted-2.2.0/busted/modules/standalone_loader.lua000066400000000000000000000012551452214637700221360ustar00rootroot00000000000000local 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 busted-2.2.0/busted/modules/test_file_loader.lua000066400000000000000000000053711452214637700217670ustar00rootroot00000000000000local s = require 'say' return function(busted, loaders) local path = require 'pl.path' local dir = require 'pl.dir' local tablex = require 'pl.tablex' local fileLoaders = {} for _, v in pairs(loaders) do local loader = require('busted.modules.files.'..v) fileLoaders[#fileLoaders+1] = loader end local getTestFiles = function(rootFile, patterns, options) local fileList if path.isfile(rootFile) then fileList = { rootFile } elseif path.isdir(rootFile) then local getfiles = options.recursive and dir.getallfiles or dir.getfiles fileList = getfiles(rootFile) fileList = tablex.filter(fileList, function(filename) local basename = path.basename(filename) for _, patt in ipairs(options.excludes) do if patt ~= '' and basename:find(patt) then return nil end end for _, patt in ipairs(patterns) do if basename:find(patt) then return true end end return #patterns == 0 end) fileList = tablex.filter(fileList, function(filename) if path.is_windows then return not filename:find('%\\%.%w+.%w+', #rootFile) else return not filename:find('/%.%w+.%w+', #rootFile) end end) else busted.publish({ 'error' }, {}, nil, s('output.file_not_found'):format(rootFile), {}) fileList = {} end table.sort(fileList) return fileList end local getAllTestFiles = function(rootFiles, patterns, options) local fileList = {} for _, root in ipairs(rootFiles) do tablex.insertvalues(fileList, getTestFiles(root, patterns, options)) end return fileList end -- runs a testfile, loading its tests local loadTestFile = function(busted, filename) for _, v in pairs(fileLoaders) do if v.match(busted, filename) then return v.load(busted, filename) end end end local loadTestFiles = function(rootFiles, patterns, options) local fileList = getAllTestFiles(rootFiles, patterns, options) for i, fileName in ipairs(fileList) do local testFile, getTrace, rewriteMessage = loadTestFile(busted, fileName) if testFile then local file = setmetatable({ getTrace = getTrace, rewriteMessage = rewriteMessage }, { __call = testFile }) busted.executors.file(fileName, file) end end if #fileList == 0 then local pattern = patterns[1] if #patterns > 1 then pattern = '\n\t' .. table.concat(patterns, '\n\t') end busted.publish({ 'error' }, {}, nil, s('output.no_test_files_match'):format(pattern), {}) end return fileList end return loadTestFiles, loadTestFile, getAllTestFiles end busted-2.2.0/busted/options.lua000066400000000000000000000000601452214637700164740ustar00rootroot00000000000000return { standalone = true, output = nil, } busted-2.2.0/busted/outputHandlers/000077500000000000000000000000001452214637700173235ustar00rootroot00000000000000busted-2.2.0/busted/outputHandlers/TAP.lua000066400000000000000000000056361452214637700204640ustar00rootroot00000000000000local pretty = require 'pl.pretty' local io = io local type = type local string_format = string.format local string_gsub = string.gsub local io_write = io.write local io_flush = io.flush local function print(msg) io_write(msg .. '\n') end return function(options) local busted = require 'busted' local handler = require 'busted.outputHandlers.base'() local success = 'ok %u - %s' local failure = 'not ' .. success local skip = 'ok %u - # SKIP %s' local counter = 0 handler.suiteReset = function() counter = 0 return nil, true end handler.suiteEnd = function() print('1..' .. counter) io_flush() return nil, true end local function showFailure(t) local message = t.message local trace = t.trace or {} if message == nil then message = 'Nil error' elseif type(message) ~= 'string' then message = pretty.write(message) end print(string_format(failure, counter, t.name)) if t.element.trace.short_src then print('# ' .. t.element.trace.short_src .. ' @ ' .. t.element.trace.currentline) end if t.randomseed then print('# Random seed: ' .. t.randomseed) end print('# Failure message: ' .. string_gsub(message, '\n', '\n# ')) if options.verbose and trace.traceback then print('# ' .. string_gsub(string_gsub(trace.traceback, '^\n', '', 1), '\n', '\n# ')) end end handler.testStart = function(element, parent) local trace = element.trace if options.verbose and trace and trace.short_src then local fileline = trace.short_src .. ' @ ' .. trace.currentline .. ': ' local testName = fileline .. handler.getFullName(element) print('# ' .. testName) end io.flush() return nil, true end handler.testEnd = function(element, parent, status, trace) counter = counter + 1 if status == 'success' then local t = handler.successes[#handler.successes] print(string_format(success, counter, t.name)) elseif status == 'pending' then local t = handler.pendings[#handler.pendings] print(string_format(skip, counter, (t.message or t.name))) elseif status == 'failure' then showFailure(handler.failures[#handler.failures]) elseif status == 'error' then showFailure(handler.errors[#handler.errors]) end io.flush() return nil, true end handler.error = function(element, parent, message, debug) if element.descriptor ~= 'it' then counter = counter + 1 showFailure(handler.errors[#handler.errors]) end io.flush() return nil, true end busted.subscribe({ 'suite', 'reset' }, handler.suiteReset) busted.subscribe({ 'suite', 'end' }, handler.suiteEnd) busted.subscribe({ 'test', 'start' }, handler.testStart, { predicate = handler.cancelOnPending }) busted.subscribe({ 'test', 'end' }, handler.testEnd, { predicate = handler.cancelOnPending }) busted.subscribe({ 'error' }, handler.error) return handler end busted-2.2.0/busted/outputHandlers/base.lua000066400000000000000000000125461452214637700207500ustar00rootroot00000000000000local table_concat = table.concat local table_insert = table.insert return function() local busted = require 'busted' local handler = { successes = {}, successesCount = 0, pendings = {}, pendingsCount = 0, failures = {}, failuresCount = 0, errors = {}, errorsCount = 0, inProgress = {} } handler.cancelOnPending = function(element, parent, status) return not ((element.descriptor == 'pending' or status == 'pending') and handler.options.suppressPending) end handler.subscribe = function(handler, options) require('busted.languages.en') handler.options = options if options.language ~= 'en' then require('busted.languages.' .. options.language) end busted.subscribe({ 'suite', 'reset' }, handler.baseSuiteReset, { priority = 1 }) busted.subscribe({ 'suite', 'start' }, handler.baseSuiteStart, { priority = 1 }) busted.subscribe({ 'suite', 'end' }, handler.baseSuiteEnd, { priority = 1 }) busted.subscribe({ 'test', 'start' }, handler.baseTestStart, { priority = 1, predicate = handler.cancelOnPending }) busted.subscribe({ 'test', 'end' }, handler.baseTestEnd, { priority = 1, predicate = handler.cancelOnPending }) busted.subscribe({ 'pending' }, handler.basePending, { priority = 1, predicate = handler.cancelOnPending }) busted.subscribe({ 'failure', 'it' }, handler.baseTestFailure, { priority = 1 }) busted.subscribe({ 'error', 'it' }, handler.baseTestError, { priority = 1 }) busted.subscribe({ 'failure' }, handler.baseError, { priority = 1 }) busted.subscribe({ 'error' }, handler.baseError, { priority = 1 }) end handler.getFullName = function(context) local parent = busted.parent(context) local names = { (context.name or context.descriptor) } while parent and (parent.name or parent.descriptor) and parent.descriptor ~= 'file' do table_insert(names, 1, parent.name or parent.descriptor) parent = busted.parent(parent) end return table_concat(names, ' ') end handler.format = function(element, parent, message, debug, isError) local function copyElement(e) local copy = {} for k,v in next, e do if type(v) ~= 'function' and k ~= 'env' then copy[k] = v end end return copy end local formatted = { trace = debug or element.trace, element = copyElement(element), name = handler.getFullName(element), message = message, randomseed = parent and parent.randomseed, isError = isError } formatted.element.trace = element.trace or debug return formatted end handler.getDuration = function() if not handler.endTick or not handler.startTick then return 0 end return handler.endTick - handler.startTick end handler.baseSuiteStart = function(suite) handler.startTick = suite.starttick handler.startTime = suite.starttime return nil, true end handler.baseSuiteReset = function() handler.successes = {} handler.successesCount = 0 handler.pendings = {} handler.pendingsCount = 0 handler.failures = {} handler.failuresCount = 0 handler.errors = {} handler.errorsCount = 0 handler.inProgress = {} return nil, true end handler.baseSuiteEnd = function(suite) handler.endTick = suite.endtick handler.endTime = suite.endtime return nil, true end handler.baseTestStart = function(element, parent) handler.inProgress[tostring(element)] = {} return nil, true end handler.baseTestEnd = function(element, parent, status, debug) local insertTable if status == 'success' then insertTable = handler.successes handler.successesCount = handler.successesCount + 1 elseif status == 'pending' then insertTable = handler.pendings handler.pendingsCount = handler.pendingsCount + 1 elseif status == 'failure' then -- failure already saved in failure handler handler.failuresCount = handler.failuresCount + 1 return nil, true elseif status == 'error' then -- error count already incremented and saved in error handler return nil, true end local formatted = handler.format(element, parent, element.message, debug) local id = tostring(element) if handler.inProgress[id] then for k, v in pairs(handler.inProgress[id]) do formatted[k] = v end handler.inProgress[id] = nil end table_insert(insertTable, formatted) return nil, true end handler.basePending = function(element, parent, message, debug) local id = tostring(element) handler.inProgress[id].message = message handler.inProgress[id].trace = debug return nil, true end handler.baseTestFailure = function(element, parent, message, debug) table_insert(handler.failures, handler.format(element, parent, message, debug)) return nil, true end handler.baseTestError = function(element, parent, message, debug) handler.errorsCount = handler.errorsCount + 1 table_insert(handler.errors, handler.format(element, parent, message, debug, true)) return nil, true end handler.baseError = function(element, parent, message, debug) if element.descriptor ~= 'it' then handler.errorsCount = handler.errorsCount + 1 table_insert(handler.errors, handler.format(element, parent, message, debug, true)) end return nil, true end return handler end busted-2.2.0/busted/outputHandlers/gtest.lua000066400000000000000000000244511452214637700211620ustar00rootroot00000000000000local pretty = require 'pl.pretty' local term = require 'term' local luassert = require 'luassert' local io = io local type = type 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) 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}) luassert:set_parameter("TableErrorHighlightColor", "none") elseif cliArgs.color then colors = require 'term.colors' 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}) luassert:set_parameter("TableErrorHighlightColor", "none") else colors = require 'term.colors' luassert:set_parameter("TableErrorHighlightColor", "red") 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' local globalSetup = colors.green ('[----------]') .. ' Global test environment setup.\n' local fileStartString = colors.green ('[----------]') .. ' Running tests from %s\n' local runString = colors.green ('[ RUN ]') .. ' %s\n' local successString = colors.green ('[ OK ]') .. ' %s (%.2f ms)\n' local skippedString = colors.yellow ('[ SKIPPED ]') .. ' %s (%.2f ms)\n' local failureString = colors.red ('[ FAILED ]') .. ' %s (%.2f ms)\n' local errorString = colors.magenta('[ ERROR ]') .. ' %s (%.2f ms)\n' local fileEndString = colors.green ('[----------]') .. ' %u %s from %s (%.2f ms total)\n\n' local globalTeardown = colors.green ('[----------]') .. ' Global test environment teardown.\n' local suiteEndString = colors.green ('[==========]') .. ' %u %s from %u test %s ran. (%.2f ms total)\n' local successStatus = colors.green ('[ PASSED ]') .. ' %u %s.\n' local summaryStrings = { skipped = { header = colors.yellow ('[ SKIPPED ]') .. ' %u %s, listed below:\n', test = colors.yellow ('[ SKIPPED ]') .. ' %s\n', footer = ' %u SKIPPED %s\n', }, failure = { header = colors.red ('[ FAILED ]') .. ' %u %s, listed below:\n', test = colors.red ('[ FAILED ]') .. ' %s\n', footer = ' %u FAILED %s\n', }, error = { header = colors.magenta('[ ERROR ]') .. ' %u %s, listed below:\n', test = colors.magenta('[ ERROR ]') .. ' %s\n', footer = ' %u %s\n', }, } local fileCount = 0 local fileTestCount = 0 local testCount = 0 local successCount = 0 local skippedCount = 0 local failureCount = 0 local errorCount = 0 local pendingDescription = function(pending) local string = '' if type(pending.message) == 'string' then string = string .. pending.message .. '\n' elseif pending.message ~= nil then string = string .. pretty.write(pending.message) .. '\n' end return string end local failureDescription = function(failure) local string = failure.randomseed and ('Random seed: ' .. failure.randomseed .. '\n') or '' if type(failure.message) == 'string' then string = string .. failure.message elseif failure.message == nil then string = string .. 'Nil error' else string = string .. pretty.write(failure.message) end string = string .. '\n' if options.verbose and failure.trace and failure.trace.traceback then string = string .. failure.trace.traceback .. '\n' end return string end local getFileLine = function(element) local fileline = '' if element.trace or element.trace.short_src then fileline = colors.cyan(element.trace.short_src) .. ':' .. colors.cyan(element.trace.currentline) .. ': ' end return fileline end local getTestList = function(status, count, list, getDescription) local string = '' local header = summaryStrings[status].header if count > 0 and header then local tests = (count == 1 and 'test' or 'tests') local errors = (count == 1 and 'error' or 'errors') string = string_format(header, count, status == 'error' and errors or tests) local testString = summaryStrings[status].test if testString then for _, t in ipairs(list) do local fullname = getFileLine(t.element) .. colors.bright(t.name) string = string .. string_format(testString, fullname) if options.deferPrint then string = string .. getDescription(t) end end end end return string end local getSummary = function(status, count) local string = '' local footer = summaryStrings[status].footer if count > 0 and footer then local tests = (count == 1 and 'TEST' or 'TESTS') local errors = (count == 1 and 'ERROR' or 'ERRORS') string = string_format(footer, count, status == 'error' and errors or tests) end return string end local getSummaryString = function() local tests = (successCount == 1 and 'test' or 'tests') local string = string_format(successStatus, successCount, tests) string = string .. getTestList('skipped', skippedCount, handler.pendings, pendingDescription) string = string .. getTestList('failure', failureCount, handler.failures, failureDescription) string = string .. getTestList('error', errorCount, handler.errors, failureDescription) string = string .. ((skippedCount + failureCount + errorCount) > 0 and '\n' or '') string = string .. getSummary('skipped', skippedCount) string = string .. getSummary('failure', failureCount) string = string .. getSummary('error', errorCount) return string end local getFullName = function(element) return getFileLine(element) .. colors.bright(handler.getFullName(element)) end handler.suiteReset = function() fileCount = 0 fileTestCount = 0 testCount = 0 successCount = 0 skippedCount = 0 failureCount = 0 errorCount = 0 return nil, true end handler.suiteStart = function(suite, count, total, randomseed) if total > 1 then io_write(string_format(repeatSuiteString, count, total)) end if randomseed then io_write(string_format(randomizeString, randomseed)) end io_write(suiteStartString) io_write(globalSetup) io_flush() return nil, true end handler.suiteEnd = function(suite, count, total) local elapsedTime_ms = suite.duration * 1000 local tests = (testCount == 1 and 'test' or 'tests') local files = (fileCount == 1 and 'file' or 'files') io_write(globalTeardown) io_write(string_format(suiteEndString, testCount, tests, fileCount, files, elapsedTime_ms)) io_write(getSummaryString()) io_flush() return nil, true end handler.fileStart = function(file) fileTestCount = 0 io_write(string_format(fileStartString, file.name)) io_flush() return nil, true end handler.fileEnd = function(file) local elapsedTime_ms = file.duration * 1000 local tests = (fileTestCount == 1 and 'test' or 'tests') fileCount = fileCount + 1 io_write(string_format(fileEndString, fileTestCount, tests, file.name, elapsedTime_ms)) io_flush() return nil, true end handler.testStart = function(element, parent) io_write(string_format(runString, getFullName(element))) io_flush() return nil, true end handler.testEnd = function(element, parent, status, debug) local elapsedTime_ms = element.duration * 1000 local string fileTestCount = fileTestCount + 1 testCount = testCount + 1 if status == 'success' then successCount = successCount + 1 string = successString elseif status == 'pending' then skippedCount = skippedCount + 1 string = skippedString elseif status == 'failure' then failureCount = failureCount + 1 string = failureString elseif status == 'error' then errorCount = errorCount + 1 string = errorString end io_write(string_format(string, getFullName(element), elapsedTime_ms)) io_flush() return nil, true end handler.testFailure = function(element, parent, message, debug) if not options.deferPrint then io_write(failureDescription(handler.failures[#handler.failures])) io_flush() end return nil, true end handler.testError = function(element, parent, message, debug) if not options.deferPrint then io_write(failureDescription(handler.errors[#handler.errors])) io_flush() end return nil, true end handler.error = function(element, parent, message, debug) if element.descriptor ~= 'it' then if not options.deferPrint then io_write(failureDescription(handler.errors[#handler.errors])) io_flush() end errorCount = errorCount + 1 end return nil, true end busted.subscribe({ 'suite', 'reset' }, handler.suiteReset) busted.subscribe({ 'suite', 'start' }, handler.suiteStart) busted.subscribe({ 'suite', 'end' }, handler.suiteEnd) busted.subscribe({ 'file', 'start' }, handler.fileStart) busted.subscribe({ 'file', 'end' }, handler.fileEnd) busted.subscribe({ 'test', 'start' }, handler.testStart, { predicate = handler.cancelOnPending }) busted.subscribe({ 'test', 'end' }, handler.testEnd, { predicate = handler.cancelOnPending }) busted.subscribe({ 'failure', 'it' }, handler.testFailure) busted.subscribe({ 'error', 'it' }, handler.testError) busted.subscribe({ 'failure' }, handler.error) busted.subscribe({ 'error' }, handler.error) return handler end busted-2.2.0/busted/outputHandlers/json.lua000066400000000000000000000013711452214637700210010ustar00rootroot00000000000000local json = require 'dkjson' local io_write = io.write local io_flush = io.flush return function(options) local busted = require 'busted' local handler = require 'busted.outputHandlers.base'() handler.suiteEnd = function() local error_info = { pendings = handler.pendings, successes = handler.successes, failures = handler.failures, errors = handler.errors, duration = handler.getDuration() } local ok, result = pcall(json.encode, error_info) if ok then io_write(result) else io_write("Failed to encode test results to json: " .. result) end io_write("\n") io_flush() return nil, true end busted.subscribe({ 'suite', 'end' }, handler.suiteEnd) return handler end busted-2.2.0/busted/outputHandlers/junit.lua000066400000000000000000000121771452214637700211670ustar00rootroot00000000000000local xml = require 'pl.xml' local string = require("string") local io = io local type = type local string_format = string.format local io_open = io.open local io_write = io.write local io_flush = io.flush local os_date = os.date local table_insert = table.insert local table_remove = table.remove return function(options) local busted = require 'busted' local handler = require 'busted.outputHandlers.base'() local top = { start_tick = busted.monotime(), xml_doc = xml.new('testsuites', { tests = 0, errors = 0, failures = 0, skip = 0, }) } local output_file_name local stack = {} local testcase_node if 'table' == type(options.arguments) then --the first argument should be the name of the xml file. output_file_name = options.arguments[1] end handler.suiteStart = function(suite, count, total) local suite_xml = { start_tick = suite.starttick, xml_doc = xml.new('testsuite', { name = 'Run ' .. count .. ' of ' .. total, tests = 0, errors = 0, failures = 0, skip = 0, timestamp = os_date('!%Y-%m-%dT%H:%M:%S'), }) } top.xml_doc:add_direct_child(suite_xml.xml_doc) table_insert(stack, top) top = suite_xml return nil, true end local function formatDuration(duration) return string_format("%.2f", duration) end local function elapsed(start_time) return formatDuration(busted.monotime() - start_time) end handler.suiteEnd = function(suite, count, total) local suite_xml = top suite_xml.xml_doc.attr.time = formatDuration(suite.duration) top = table_remove(stack) top.xml_doc.attr.tests = top.xml_doc.attr.tests + suite_xml.xml_doc.attr.tests top.xml_doc.attr.errors = top.xml_doc.attr.errors + suite_xml.xml_doc.attr.errors top.xml_doc.attr.failures = top.xml_doc.attr.failures + suite_xml.xml_doc.attr.failures top.xml_doc.attr.skip = top.xml_doc.attr.skip + suite_xml.xml_doc.attr.skip return nil, true end handler.exit = function() top.xml_doc.attr.time = elapsed(top.start_tick) local output_string = xml.tostring(top.xml_doc, '', '\t', nil, false) local file if 'string' == type(output_file_name) then file = io_open(output_file_name, 'w+b' ) end if file then file:write(output_string) file:write('\n') file:close() else io_write(output_string) io_write("\n") io_flush() end return nil, true end local function testStatus(element, parent, message, status, trace) if status ~= 'success' then testcase_node:addtag(status) if status ~= 'pending' and parent and parent.randomseed then testcase_node:text('Random seed: ' .. parent.randomseed .. '\n') end if message then testcase_node:text(message) end if trace and trace.traceback then testcase_node:text(trace.traceback) end testcase_node:up() end end handler.testStart = function(element, parent) testcase_node = xml.new('testcase', { classname = element.trace.short_src .. ':' .. element.trace.currentline, name = handler.getFullName(element), }) top.xml_doc:add_direct_child(testcase_node) return nil, true end handler.testEnd = function(element, parent, status) top.xml_doc.attr.tests = top.xml_doc.attr.tests + 1 testcase_node:set_attrib("time", formatDuration(element.duration)) if status == 'success' then testStatus(element, parent, nil, 'success') elseif status == 'pending' then top.xml_doc.attr.skip = top.xml_doc.attr.skip + 1 local formatted = handler.pendings[#handler.pendings] local trace = element.trace ~= formatted.trace and formatted.trace testStatus(element, parent, formatted.message, 'skipped', trace) end return nil, true end handler.failureTest = function(element, parent, message, trace) top.xml_doc.attr.failures = top.xml_doc.attr.failures + 1 testStatus(element, parent, message, 'failure', trace) return nil, true end handler.errorTest = function(element, parent, message, trace) top.xml_doc.attr.errors = top.xml_doc.attr.errors + 1 testStatus(element, parent, message, 'error', trace) return nil, true end handler.error = function(element, parent, message, trace) if element.descriptor ~= 'it' then top.xml_doc.attr.errors = top.xml_doc.attr.errors + 1 top.xml_doc:addtag('error') top.xml_doc:text(message) if trace and trace.traceback then top.xml_doc:text(trace.traceback) end top.xml_doc:up() end return nil, true end busted.subscribe({ 'exit' }, handler.exit) busted.subscribe({ 'suite', 'start' }, handler.suiteStart) busted.subscribe({ 'suite', 'end' }, handler.suiteEnd) busted.subscribe({ 'test', 'start' }, handler.testStart, { predicate = handler.cancelOnPending }) busted.subscribe({ 'test', 'end' }, handler.testEnd, { predicate = handler.cancelOnPending }) busted.subscribe({ 'error', 'it' }, handler.errorTest) busted.subscribe({ 'failure', 'it' }, handler.failureTest) busted.subscribe({ 'error' }, handler.error) busted.subscribe({ 'failure' }, handler.error) return handler end busted-2.2.0/busted/outputHandlers/plainTerminal.lua000066400000000000000000000121211452214637700226220ustar00rootroot00000000000000local s = require 'say' local pretty = require 'pl.pretty' local io = io local type = type local string_format = string.format local string_gsub = string.gsub local io_write = io.write local io_flush = io.flush local pairs = pairs return function(options) local busted = require 'busted' local handler = require 'busted.outputHandlers.base'() local successDot = '+' local failureDot = '-' local errorDot = '*' local pendingDot = '.' local pendingDescription = function(pending) local name = pending.name local string = s('output.pending') .. ' -> ' .. pending.trace.short_src .. ' @ ' .. pending.trace.currentline .. '\n' .. name if type(pending.message) == 'string' then string = string .. '\n' .. pending.message elseif pending.message ~= nil then string = string .. '\n' .. pretty.write(pending.message) end return string end local failureMessage = function(failure) local string = failure.randomseed and ('Random seed: ' .. failure.randomseed .. '\n') or '' if type(failure.message) == 'string' then string = string .. failure.message elseif failure.message == nil then string = string .. 'Nil error' else string = string .. pretty.write(failure.message) end return string end local failureDescription = function(failure, isError) local string = s('output.failure') .. ' -> ' if isError then string = s('output.error') .. ' -> ' end if not failure.element.trace or not failure.element.trace.short_src then string = string .. failureMessage(failure) .. '\n' .. failure.name else string = string .. failure.element.trace.short_src .. ' @ ' .. failure.element.trace.currentline .. '\n' .. failure.name .. '\n' .. failureMessage(failure) end if options.verbose and failure.trace and failure.trace.traceback then string = string .. '\n' .. failure.trace.traceback end return string end local statusString = function() local successString = s('output.success_plural') local failureString = s('output.failure_plural') local pendingString = s('output.pending_plural') local errorString = s('output.error_plural') local sec = handler.getDuration() local successes = handler.successesCount local pendings = handler.pendingsCount local failures = handler.failuresCount local errors = handler.errorsCount if successes == 0 then successString = s('output.success_zero') elseif successes == 1 then successString = s('output.success_single') end if failures == 0 then failureString = s('output.failure_zero') elseif failures == 1 then failureString = s('output.failure_single') end if pendings == 0 then pendingString = s('output.pending_zero') elseif pendings == 1 then pendingString = s('output.pending_single') end if errors == 0 then errorString = s('output.error_zero') elseif errors == 1 then errorString = s('output.error_single') end local formattedTime = string_gsub(string_format('%.6f', sec), '([0-9])0+$', '%1') return successes .. ' ' .. successString .. ' / ' .. failures .. ' ' .. failureString .. ' / ' .. errors .. ' ' .. errorString .. ' / ' .. pendings .. ' ' .. pendingString .. ' : ' .. formattedTime .. ' ' .. s('output.seconds') end handler.testEnd = function(element, parent, status, debug) if not options.deferPrint then local string = successDot if status == 'pending' then string = pendingDot elseif status == 'failure' then string = failureDot elseif status == 'error' then string = errorDot end io_write(string) io_flush() end return nil, true end handler.suiteStart = function(suite, count, total) local runString = (total > 1 and '\nRepeating all tests (run %u of %u) . . .\n\n' or '') io_write(string_format(runString, count, total)) io_flush() return nil, true end handler.suiteEnd = function() io_write('\n') io_write(statusString()..'\n') for i, pending in pairs(handler.pendings) do io_write('\n') io_write(pendingDescription(pending)..'\n') end for i, err in pairs(handler.failures) do io_write('\n') io_write(failureDescription(err)..'\n') end for i, err in pairs(handler.errors) do io_write('\n') io_write(failureDescription(err, true)..'\n') end return nil, true end handler.error = function(element, parent, message, debug) io_write(errorDot) io_flush() return nil, true end busted.subscribe({ 'test', 'end' }, handler.testEnd, { predicate = handler.cancelOnPending }) busted.subscribe({ 'suite', 'start' }, handler.suiteStart) busted.subscribe({ 'suite', 'end' }, handler.suiteEnd) busted.subscribe({ 'error', 'file' }, handler.error) busted.subscribe({ 'failure', 'file' }, handler.error) busted.subscribe({ 'error', 'describe' }, handler.error) busted.subscribe({ 'failure', 'describe' }, handler.error) return handler end busted-2.2.0/busted/outputHandlers/sound.lua000066400000000000000000000017761452214637700211710ustar00rootroot00000000000000local app = require 'pl.app' local io = io local io_popen = io.popen local math_random = math.random return function(options) local busted = require 'busted' local handler = require 'busted.outputHandlers.base'() local language = require('busted.languages.' .. options.language) handler.suiteEnd = function() local system = app.platform() local sayer_pre, sayer_post local messages if system == 'Linux' then sayer_pre = 'espeak -s 160 ' sayer_post = ' > /dev/null 2>&1' elseif system and system:match('^Windows') then sayer_pre = 'echo ' sayer_post = ' | ptts' else sayer_pre = 'say ' sayer_post = '' end if handler.failuresCount > 0 then messages = language.failure_messages else messages = language.success_messages end io_popen(sayer_pre .. '"' .. messages[math_random(1, #messages)] .. '"' .. sayer_post) return nil, true end busted.subscribe({ 'suite', 'end' }, handler.suiteEnd) return handler end busted-2.2.0/busted/outputHandlers/utfTerminal.lua000066400000000000000000000157171452214637700223330ustar00rootroot00000000000000local 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 local string_gsub = string.gsub local io_write = io.write local io_flush = io.flush local pairs = pairs local colors 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}) luassert:set_parameter("TableErrorHighlightColor", "none") elseif cliArgs.color then colors = require 'term.colors' 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}) luassert:set_parameter("TableErrorHighlightColor", "none") else colors = require 'term.colors' luassert:set_parameter("TableErrorHighlightColor", "red") end end local successDot = colors.green('\226\151\143') -- '\226\151\143' = '●' = utf8.char(9679) local failureDot = colors.red('\226\151\188') -- '\226\151\188' = '◼' = utf8.char(9724) local errorDot = colors.magenta('\226\156\177') -- '\226\156\177' = '✱' = utf8.char(10033) local pendingDot = colors.yellow('\226\151\140') -- '\226\151\140' = '◌' = utf8.char(9676) local pendingDescription = function(pending) local name = pending.name -- '\226\134\146' = '→' = utf8.char('8594') local string = colors.yellow(s('output.pending')) .. ' \226\134\146 ' .. colors.cyan(pending.trace.short_src) .. ' @ ' .. colors.cyan(pending.trace.currentline) .. '\n' .. colors.bright(name) if type(pending.message) == 'string' then string = string .. '\n' .. pending.message elseif pending.message ~= nil then string = string .. '\n' .. pretty.write(pending.message) end return string end local failureMessage = function(failure) local string = failure.randomseed and ('Random seed: ' .. failure.randomseed .. '\n') or '' if type(failure.message) == 'string' then string = string .. failure.message elseif failure.message == nil then string = string .. 'Nil error' else string = string .. pretty.write(failure.message) end return string end local failureDescription = function(failure, isError) -- '\226\134\146' = '→' = utf8.char(8594) local string = colors.red(s('output.failure')) .. ' \226\134\146 ' if isError then string = colors.magenta(s('output.error')) .. ' \226\134\146 ' end if not failure.element.trace or not failure.element.trace.short_src then string = string .. colors.cyan(failureMessage(failure)) .. '\n' .. colors.bright(failure.name) else string = string .. colors.cyan(failure.element.trace.short_src) .. ' @ ' .. colors.cyan(failure.element.trace.currentline) .. '\n' .. colors.bright(failure.name) .. '\n' .. failureMessage(failure) end if options.verbose and failure.trace and failure.trace.traceback then string = string .. '\n' .. failure.trace.traceback end return string end local statusString = function() local successString = s('output.success_plural') local failureString = s('output.failure_plural') local pendingString = s('output.pending_plural') local errorString = s('output.error_plural') local sec = handler.getDuration() local successes = handler.successesCount local pendings = handler.pendingsCount local failures = handler.failuresCount local errors = handler.errorsCount if successes == 0 then successString = s('output.success_zero') elseif successes == 1 then successString = s('output.success_single') end if failures == 0 then failureString = s('output.failure_zero') elseif failures == 1 then failureString = s('output.failure_single') end if pendings == 0 then pendingString = s('output.pending_zero') elseif pendings == 1 then pendingString = s('output.pending_single') end if errors == 0 then errorString = s('output.error_zero') elseif errors == 1 then errorString = s('output.error_single') end local formattedTime = string_gsub(string_format('%.6f', sec), '([0-9])0+$', '%1') return colors.green(successes) .. ' ' .. successString .. ' / ' .. colors.red(failures) .. ' ' .. failureString .. ' / ' .. colors.magenta(errors) .. ' ' .. errorString .. ' / ' .. colors.yellow(pendings) .. ' ' .. pendingString .. ' : ' .. colors.bright(formattedTime) .. ' ' .. s('output.seconds') end handler.testEnd = function(element, parent, status, debug) if not options.deferPrint then local string = successDot if status == 'pending' then string = pendingDot elseif status == 'failure' then string = failureDot elseif status == 'error' then string = errorDot end io_write(string) io_flush() end return nil, true end handler.suiteStart = function(suite, count, total) local runString = (total > 1 and '\nRepeating all tests (run %u of %u) . . .\n\n' or '') io_write(string_format(runString, count, total)) io_flush() return nil, true end handler.suiteEnd = function() io_write('\n') io_write(statusString()..'\n') for i, pending in pairs(handler.pendings) do io_write('\n') io_write(pendingDescription(pending)..'\n') end for i, err in pairs(handler.failures) do io_write('\n') io_write(failureDescription(err)..'\n') end for i, err in pairs(handler.errors) do io_write('\n') io_write(failureDescription(err, true)..'\n') end return nil, true end handler.error = function(element, parent, message, debug) io_write(errorDot) io_flush() return nil, true end busted.subscribe({ 'test', 'end' }, handler.testEnd, { predicate = handler.cancelOnPending }) busted.subscribe({ 'suite', 'start' }, handler.suiteStart) busted.subscribe({ 'suite', 'end' }, handler.suiteEnd) busted.subscribe({ 'error', 'file' }, handler.error) busted.subscribe({ 'failure', 'file' }, handler.error) busted.subscribe({ 'error', 'describe' }, handler.error) busted.subscribe({ 'failure', 'describe' }, handler.error) return handler end busted-2.2.0/busted/runner.lua000066400000000000000000000152621452214637700163240ustar00rootroot00000000000000-- Busted command-line runner local path = require 'pl.path' local tablex = require 'pl.tablex' local term = require 'term' local utils = require 'busted.utils' local exit = require 'busted.compatibility'.exit local loadstring = require 'busted.compatibility'.loadstring local loaded = false return function(options) if loaded then return function() end else loaded = true end local isatty = io.type(io.stdout) == 'file' and term.isatty(io.stdout) options = tablex.update(require 'busted.options', options or {}) options.output = options.output or (isatty and 'utfTerminal' or 'plainTerminal') local busted = require 'busted.core'() local cli = require 'busted.modules.cli'(options) local filterLoader = require 'busted.modules.filter_loader'() local helperLoader = require 'busted.modules.helper_loader'() local outputHandlerLoader = require 'busted.modules.output_handler_loader'() local luacov = require 'busted.modules.luacov'() require 'busted'(busted) local level = 2 local info = debug.getinfo(level, 'Sf') local source = info.source local fileName = source:sub(1,1) == '@' and source:sub(2) or nil local forceExit = fileName == nil -- Parse the cli arguments local appName = path.basename(fileName or 'busted') cli:set_name(appName) local cliArgs, err = cli:parse(arg) if not cliArgs then io.stderr:write(err .. '\n') exit(1, forceExit) end if cliArgs.version then -- Return early if asked for the version print(busted.version) exit(0, forceExit) end -- Load current working directory local _, err = path.chdir(path.normpath(cliArgs.directory)) if err then io.stderr:write(appName .. ': error: ' .. err .. '\n') exit(1, forceExit) end -- If coverage arg is passed in, load LuaCovsupport if cliArgs.coverage then local ok, err = luacov(cliArgs['coverage-config-file']) if not ok then io.stderr:write(appName .. ': error: ' .. err .. '\n') exit(1, forceExit) end end -- If auto-insulate is disabled, re-register file without insulation if not cliArgs['auto-insulate'] then busted.register('file', 'file', {}) end -- If lazy is enabled, make lazy setup/teardown the default if cliArgs.lazy then busted.register('setup', 'lazy_setup') busted.register('teardown', 'lazy_teardown') end -- Add additional package paths based on lpath and cpath cliArgs if #cliArgs.lpath > 0 then package.path = (cliArgs.lpath .. ';' .. package.path):gsub(';;',';') end if #cliArgs.cpath > 0 then package.cpath = (cliArgs.cpath .. ';' .. package.cpath):gsub(';;',';') end -- Load and execute commands given on the command-line if cliArgs.e then for k,v in ipairs(cliArgs.e) do loadstring(v)() end end -- watch for test errors and failures local failures = 0 local errors = 0 local quitOnError = not cliArgs['keep-going'] busted.subscribe({ 'error', 'output' }, function(element, parent, message) io.stderr:write(appName .. ': error: Cannot load output library: ' .. element.name .. '\n' .. message .. '\n') return nil, true end) busted.subscribe({ 'error', 'helper' }, function(element, parent, message) io.stderr:write(appName .. ': error: Cannot load helper script: ' .. element.name .. '\n' .. message .. '\n') return nil, true end) busted.subscribe({ 'error' }, function(element, parent, message) errors = errors + 1 busted.skipAll = quitOnError return nil, true end) busted.subscribe({ 'failure' }, function(element, parent, message) if element.descriptor == 'it' then failures = failures + 1 else errors = errors + 1 end busted.skipAll = quitOnError return nil, true end) -- Set up randomization options busted.sort = cliArgs['sort-tests'] busted.randomize = cliArgs['shuffle-tests'] busted.randomseed = tonumber(cliArgs.seed) or utils.urandom() or os.time() -- Set up output handler to listen to events outputHandlerLoader(busted, cliArgs.output, { defaultOutput = options.output, enableSound = cliArgs['enable-sound'], verbose = cliArgs.verbose, suppressPending = cliArgs['suppress-pending'], language = cliArgs.lang, deferPrint = cliArgs['defer-print'], arguments = cliArgs.Xoutput, }) -- Pre-load the LuaJIT 'ffi' module if applicable require 'busted.luajit'() -- Set up helper script, must succeed to even start tests if cliArgs.helper and cliArgs.helper ~= '' then local ok, err = helperLoader(busted, cliArgs.helper, { verbose = cliArgs.verbose, language = cliArgs.lang, arguments = cliArgs.Xhelper }) if not ok then io.stderr:write(appName .. ': failed running the specified helper (' .. cliArgs.helper .. '), error: ' .. err .. '\n') exit(1, forceExit) end end local getFullName = function(name) local parent = busted.context.get() local names = { name } while parent and (parent.name or parent.descriptor) and parent.descriptor ~= 'file' do table.insert(names, 1, parent.name or parent.descriptor) parent = busted.context.parent(parent) end return table.concat(names, ' ') end if cliArgs['log-success'] then local logFile = assert(io.open(cliArgs['log-success'], 'a')) busted.subscribe({ 'test', 'end' }, function (test, parent, status) if status == "success" then logFile:write(getFullName() .. "\n") end end) end -- Load tag and test filters filterLoader(busted, { tags = cliArgs.tags, excludeTags = cliArgs['exclude-tags'], filter = cliArgs.filter, name = cliArgs.name, filterOut = cliArgs['filter-out'], excludeNamesFile = cliArgs['exclude-names-file'], list = cliArgs.list, nokeepgoing = not cliArgs['keep-going'], suppressPending = cliArgs['suppress-pending'], }) if cliArgs.ROOT then -- Load test directories/files local rootFiles = cliArgs.ROOT local patterns = cliArgs.pattern local testFileLoader = require 'busted.modules.test_file_loader'(busted, cliArgs.loaders) testFileLoader(rootFiles, patterns, { excludes = cliArgs['exclude-pattern'], verbose = cliArgs.verbose, recursive = cliArgs['recursive'], }) else -- Running standalone, use standalone loader local testFileLoader = require 'busted.modules.standalone_loader'(busted) testFileLoader(info, { verbose = cliArgs.verbose }) end local runs = cliArgs['repeat'] local execute = require 'busted.execute'(busted) execute(runs, { seed = cliArgs.seed, shuffle = cliArgs['shuffle-files'], sort = cliArgs['sort-files'], }) busted.publish({ 'exit' }) if options.standalone or failures > 0 or errors > 0 then exit(failures + errors, forceExit) end end busted-2.2.0/busted/status.lua000066400000000000000000000021661452214637700163350ustar00rootroot00000000000000local function get_status(status) local smap = { ['success'] = 'success', ['pending'] = 'pending', ['failure'] = 'failure', ['error'] = 'error', ['true'] = 'success', ['false'] = 'failure', ['nil'] = 'error', } return smap[tostring(status)] or 'error' end return function(inital_status) local objstat = get_status(inital_status) local obj = { success = function(self) return (objstat == 'success') end, pending = function(self) return (objstat == 'pending') end, failure = function(self) return (objstat == 'failure') end, error = function(self) return (objstat == 'error') end, get = function(self) return objstat end, set = function(self, status) objstat = get_status(status) end, update = function(self, status) -- prefer current failure/error status over new status status = get_status(status) if objstat == 'success' or (objstat == 'pending' and status ~= 'success') then objstat = status end end } return setmetatable(obj, { __index = {}, __tostring = function(self) return objstat end }) end busted-2.2.0/busted/utils.lua000066400000000000000000000014651452214637700161530ustar00rootroot00000000000000return { copy_interpreter_args = function(arguments) -- copy non-positive command-line args auto-inserted by Lua interpreter if arguments and _G.arg then local i = 0 while _G.arg[i] do arguments[i] = _G.arg[i] i = i - 1 end end end, split = require 'pl.utils'.split, shuffle = function(t, seed) if seed then math.randomseed(seed) end local n = #t while n >= 2 do local k = math.random(n) t[n], t[k] = t[k], t[n] n = n - 1 end return t end, urandom = function() local f = io.open('/dev/urandom', 'rb') if not f then return nil end local s = f:read(4) f:close() local bytes = {s:byte(1, 4)} local value = 0 for _, v in ipairs(bytes) do value = value * 256 + v end return value end, } busted-2.2.0/completions/000077500000000000000000000000001452214637700153505ustar00rootroot00000000000000busted-2.2.0/completions/bash/000077500000000000000000000000001452214637700162655ustar00rootroot00000000000000busted-2.2.0/completions/bash/busted.bash000066400000000000000000000121251452214637700204130ustar00rootroot00000000000000# bash completion for busted # _busted_comp() { local opt IFS=' '$'\t'$'\n' for opt in $1; do case $opt in --*=*) printf %s$'\n' "$opt" ;; *.) printf %s$'\n' "$opt" ;; *) printf %s$'\n' "$opt " ;; esac done } _busted() { COMPREPLY=() local cur="${COMP_WORDS[COMP_CWORD]}" local prev="${COMP_WORDS[COMP_CWORD-1]}" if [[ "${cur}" == "=" ]]; then cur= fi if [[ "${prev}" == "=" ]]; then prev="${COMP_WORDS[COMP_CWORD-2]}" fi case "${prev}" in --lang) local langs="ar de en fr ja nl ru th ua zh" COMPREPLY=( $(compgen -W "${langs}" -- ${cur}) ) return 0 ;; -o|--output) local outputs="plainTerminal utfTerminal TAP json junit sound" local -a toks toks=( ${toks[@]-} $(compgen -W "${outputs}" -- ${cur} ) ) toks=( ${toks[@]-} $(compgen -f -X "!*.lua" -- ${cur} ) ) toks=( ${toks[@]-} $(compgen -f -X "!*.moon" -- ${cur} ) ) toks=( ${toks[@]-} $(compgen -d -- ${cur} ) ) if declare -fF _compopt_o_filenames > /dev/null; then _compopt_o_filenames else compopt -o filenames fi COMPREPLY=( "${COMPREPLY[@]}" "${toks[@]}" ) return 0 ;; -r|--run) local d="." local f local i local word for (( i=1; i < ${#COMP_WORDS[@]}-1; i++ )); do case "${COMP_WORDS[i]}" in -C|-f) word="${COMP_WORDS[i+1]}" if [ "${COMP_WORDS[i]}" == "-f" ]; then f="${word}" else if [ "${word:0:1}" == "/" ]; then d="${word}" else d="${d}/${word}" fi fi ;; --directory|--config-file) word="${COMP_WORDS[i+1]}" if [ "${word}" == "=" ]; then word="${COMP_WORDS[i+2]}" fi if [ "${COMP_WORDS[i]}" == "--config-file" ]; then f="${word}" else if [ "${word:0:1}" == "/" ]; then d="${word}" else d="${d}/${word}" fi fi ;; esac done local cfgs=$(lua -e "cfgs=dofile('${f:-${d}/.busted}')" \ -e "for k,_ in pairs(cfgs) do print(k) end" 2> /dev/null) COMPREPLY=( $(compgen -W "${cfgs}" -- ${cur}) ) return 0 ;; --loaders) local prefix=${cur%,*} local cur_=${cur##*,} local loaders="lua moonscript terra" local -a toks toks=( ${toks[@]-} $(compgen -W "${loaders[@]}" -- ${cur} ) ) if [[ "${prefix}" != "${cur}" ]]; then local mloaders="" for l in ${loaders}; do if ! [[ "${prefix}," =~ .*,$l,.* || "${prefix}," =~ ^$l,.* ]]; then mloaders="${mloaders} $l" fi done toks=( ${toks[@]-} $(compgen -P "${prefix}," -W "${mloaders}" -- ${cur_} ) ) fi compopt -o nospace COMPREPLY=( "${COMPREPLY[@]}" "${toks[@]}" ) return 0 ;; -C|--directory) _filedir -d return 0 ;; -f|--config-file) _filedir return 0 ;; --lua) _filedir return 0 ;; --helper) _filedir return 0 ;; -e) # no completion available return 0 ;; -p|--pattern|--exclude-pattern) # no completion available return 0 ;; -t|--tags|--exclude-tags) # no completion available return 0 ;; --filter|--filter-out|--name) # no completion available return 0 ;; --exclude-names-file|--log-success) _filedir return 0 ;; -m|--lpath|--cpath) _filedir -d return 0 ;; -Xoutput|--Xhelper) # no completion available return 0 ;; --repeat) # no completion available return 0 ;; --seed) # no completion available return 0 ;; esac if [[ "${cur}" == -* ]] ; then local opts=" -h --help -v --verbose --no-verbose --version -l --list -o --output= -p --pattern= --exclude-pattern= -C --directory= -f --config-file= -t --tags= --exclude-tags= -m --lpath= --cpath= -r --run= -e --lua= --ignore-lua --filter= --filter-out= --name= --exclude-names-file= --repeat= --seed= --lang= --loaders= --log-success --helper= -c --coverage --no-coverage -s --enable-sound --no-enable-sound -Xoutput -Xhelper --lazy --no-lazy --auto-insulate --no-auto-insulate -k --keep-going --no-keep-going -R --recursive --no-recursive --shuffle --shuffle-tests --shuffle-files --no-shuffle --no-shuffle-tests --no-shuffle-files --sort --sort-tests --sort-files --no-sort --no-sort-tests --no-sort-files --supress-pending --no-supress-pending --defer-print --no-defer-print" compopt -o nospace local IFS=$'\n' COMPREPLY=( $(compgen -W "$(_busted_comp "${opts-}")" -- "${cur}" )) return 0 else _filedir fi } complete -F _busted busted busted-2.2.0/completions/zsh/000077500000000000000000000000001452214637700161545ustar00rootroot00000000000000busted-2.2.0/completions/zsh/_busted000066400000000000000000000155261452214637700175350ustar00rootroot00000000000000#compdef busted #autoload #alias rbu="unfunction _busted; autoload -U _busted" local _busted_args _busted_args=( "--cpath=[Optional path to be prefixed to the Lua C module search path (default: ./csrc/?.so;./csrc/?/?.so;)]:directory:_dirs" "(--defer-print --no-defer-print)--defer-print[Defer print to when test suite is complete]" "(--defer-print --no-defer-print)--no-defer-print[Do not defer print to when test suite is complete]" "--lang=[Language for error messages (default: en)]:languages:(ar de en fr ja nl ru th ua zh)" "--repeat=[Run the tests repeatedly (default: 1)]: :" "--seed=[Random seed value to use for shuffing test order (default: os.time())]: :" "(--sort --shuffle --no-shuffle --no-sort)--shuffle[Randomize file and test order, takes precedence over --sort (--shuffle-test and --shuffle-files)]" "(--sort --shuffle --no-shuffle --no-sort)--no-shuffle[Do not randomize file and test order (--no-shuffle-test and --no-shuffle-files)]" "(--sort-files --shuffle-files --no-sort-files --no-shuffle-files)--shuffle-files[Randomize file execution order, takes precedence over --sort-files]" "(--sort-files --shuffle-files --no-sort-files --no-shuffle-files)--no-shuffle-files[Do not randomize file execution order]" "(--sort-tests --shuffle-tests --no-sort-tests --no-shuffle-tests)--shuffle-tests[Randomize test order within a file, takes precedence over --sort-tests]" "(--sort-tests --shuffle-tests --no-sort-tests --no-shuffle-tests)--no-shuffle-tests[Do not randomize test order within a file]" "(--sort --shuffle --no-shuffle --no-sort)--sort[Sort file and test order (--sort-tests and --sort-files)]" "(--sort --shuffle --no-shuffle --no-sort)--no-sort[Do not sort file and test order (--no-sort-tests and --no-sort-files)]" "(--sort-files --shuffle-files --no-sort-files --no-shuffle-files)--sort-files[Sort file execution order]" "(--sort-files --shuffle-files --no-sort-files --no-shuffle-files)--no-sort-files[Do not sort file execution order]" "(--sort-tests --shuffle-tests --no-sort-tests --no-shuffle-tests)--sort-tests[Sort test order within a file]" "(--sort-tests --shuffle-tests --no-sort-tests --no-shuffle-tests)--no-sort-tests[Do not sort test order within a file]" "(--suppress-pending --no-suppress-pending)--suppress-pending[Suppress 'pending' test output]" "(--suppress-pending --no-suppress-pending)--no-suppress-pending[Do not suppress 'pending' test output]" "--version[Prints the program version and exits]" "(-l --list)"{-l,--list}"[List the names of all tests instead of running them]" "(--lazy --no-lazy)--lazy[Use lazy setup/teardown as the default]" "(--lazy --no-lazy)--no-lazy[Use strict setup/teardown as the default]" "(--auto-insulate --no-auto-insulate)--auto-insulate[Enable file insulation]" "(--auto-insulate --no-auto-insulate)--no-auto-insulate[Disable file insulation]" "(-k --keep-going --no-keep-going)--keep-going[Continue as much as possible after an error or failure]" "(-k --keep-going --no-keep-going)--no-keep-going[Quit after first error or failure]" "(-R --recursive --no-recursive)--recursive[Recurse into subdirectories]" "(-R --recursive --no-recursive)--no-recursive[Do not recurse into subdirectories]" "--ignore-lua[Whether or not to ignore the lua directive]" "--lua[The path to the lua interpreter busted should run under]:files:_files" "--helper[A helper script that is run before tests]:files:_files" "--loaders=[Test file loaders]:loaders:_values -s , loaders lua moonscript terra" "-Xoutput[Pass 'OPTION' as an option to the output handler. If 'OPTION' contains commas, it is split into multiple options at the commas.]: :" "-Xhelper[Pass 'OPTION' as an option to the helper script. If 'OPTION' contains commas, it is split into multiple options at the commas.]: :" "(-c --coverage --no-coverage)"{-c,--coverage}"[Do code coverage analysis (requires 'LuaCov' to be installed)]" "(-c --coverage --no-coverage)--no-coverage[Disable code coverage analysis]" "(-C --directory)"{-C,--directory=}"[Change to directory DIR before running tests. If multiple options are specified, each is interpreted relative to the previous one. (default: ./)]:directory:_dirs" "(-f --config-file)"{-f,--config-file=}"[Load configuration options from FILE]:files:_files" "(-h --help)"{-h,--help}"[Help]" "(-m --lpath)"{-m,--lpath=}"[Optional path to be prefixed to the Lua module search path (default: ./src/?.lua;./src/?/?.lua;./src/?/init.lua)]:directory:_dirs" "(-o --output)"{-o,--output=}"[Output library to load (default: utfTerminal)]:output handlers:->output" "(-p --pattern)"{-p,--pattern=}"[Only run test files matching the Lua pattern (default: _spec)]: :" "--exclude-pattern=[Do not run test files matching the Lua pattern, takes precedence over --pattern]: :" "(-r --run)"{-r,--run=}"[Config to run from .busted file]:run configurations:->run" "(-s --enable-sound)"{-s,--enable-sound}"[Executes 'say' command if available]" "(-t --tags)"{-t,--tags=}"[Only run tests with these #tags]: :" "--exclude-tags=[Do not run tests with these #tags, takes precedence over --tags]: :" "--filter=[Only run test names matching the Lua pattern]: :" "--filter-out=[Do not run test names matching the Lua pattern, takes precedence over --filter]: :" "--exclude-names-file=[Do not run the tests with names listed in the given file, takes precedence over --filter]:files:_files" "--name=[Run test with the given full name]:files:_files" "--log-success=[Append the name of each successful test to the given file]:file:_files" "-e[Execute Lua statement]: :" "(-v --verbose --no-verbose)"{-v,--verbose}"[Verbose output of errors]" "(-v --verbose --no-verbose)--no-verbose[Disable verbose output of errors]" "*:files:_files" ) local curcontext="${curcontext}" state line typeset -A opt_args _arguments -s $_busted_args case "${state}" in run) local d="." local f local i local word for (( i=1; i < ${#words}; i++ )); do case "${words[i]}" in -C|--directory|-f|--config-file) word="${words[i+1]}" if [[ "${words[i]}" == "-f" ]]; then f="${word}" else if [[ "${word[1,1]}" == "/" ]]; then d="${word}" else d="${d}/${word}" fi fi ;; --directory=*|--config-file=*) if [[ "${words[i][1,14]}" == "--config-file=" ]]; then f="${words[i][15,-1]}" else word="${words[i][13,-1]}" if [[ "${word[1,1]}" == "/" ]]; then d="${word}" else d="${d}/${word}" fi fi ;; esac done local cfgs cfgs=$(lua -e "cfgs=dofile('${f:-${d}/.busted}')" \ -e "for k,_ in pairs(cfgs) do print(k) end" 2> /dev/null) _arguments -s "*:run configurations:(${cfgs})" ;; output) _alternative "*:output handlers:(plainTerminal utfTerminal TAP json junit sound)" _arguments -s "*:output handlers:_files -g '*.lua *.moon'" ;; esac busted-2.2.0/rockspecs/000077500000000000000000000000001452214637700150105ustar00rootroot00000000000000busted-2.2.0/rockspecs/busted-2.0.0-0.rockspec000066400000000000000000000103531452214637700206230ustar00rootroot00000000000000package = 'busted' version = '2.0.0-0' source = { url = 'https://github.com/Olivine-Labs/busted/archive/v2.0.0-0.tar.gz', dir = 'busted-2.0.0-0' } 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 = 'http://olivinelabs.com/busted/', license = 'MIT ' } dependencies = { 'lua >= 5.1', 'lua_cliargs = 3.0-1', 'luafilesystem >= 1.5.0', 'luasystem >= 0.2.0-0', 'dkjson >= 2.1.0', 'say >= 1.3-0', 'luassert >= 1.8.0-0', 'lua-term >= 0.1-1', 'penlight >= 1.3.2-2', 'mediator_lua >= 1.1.1-0', } 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.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.en'] = 'busted/languages/en.lua', ['busted.languages.ar'] = 'busted/languages/ar.lua', ['busted.languages.de'] = 'busted/languages/de.lua', ['busted.languages.es'] = 'busted/languages/es.lua', ['busted.languages.fr'] = 'busted/languages/fr.lua', ['busted.languages.ja'] = 'busted/languages/ja.lua', ['busted.languages.nl'] = 'busted/languages/nl.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 = { ['busted'] = 'bin/busted' } } } busted-2.2.0/rockspecs/busted-2.0.0-1.rockspec000066400000000000000000000103311452214637700206200ustar00rootroot00000000000000package = 'busted' version = '2.0.0-1' source = { url = 'https://github.com/Olivine-Labs/busted/archive/v2.0.0.tar.gz', dir = 'busted-2.0.0' } 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 = 'http://olivinelabs.com/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.3', 'luassert >= 1.8.0', '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.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.en'] = 'busted/languages/en.lua', ['busted.languages.ar'] = 'busted/languages/ar.lua', ['busted.languages.de'] = 'busted/languages/de.lua', ['busted.languages.es'] = 'busted/languages/es.lua', ['busted.languages.fr'] = 'busted/languages/fr.lua', ['busted.languages.ja'] = 'busted/languages/ja.lua', ['busted.languages.nl'] = 'busted/languages/nl.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 = { ['busted'] = 'bin/busted' } } } busted-2.2.0/rockspecs/busted-2.1.0-1.rockspec000066400000000000000000000116211452214637700206240ustar00rootroot00000000000000local 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' } } } busted-2.2.0/rockspecs/busted-2.1.1-1.rockspec000066400000000000000000000116211452214637700206250ustar00rootroot00000000000000local 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' } } } busted-2.2.0/rockspecs/busted-2.1.2-1.rockspec000066400000000000000000000117621452214637700206340ustar00rootroot00000000000000local package_name = "busted" local package_version = "2.1.2" local rockspec_revision = "1" local github_account_name = "lunarmodules" local github_repo_name = package_name 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" } 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', } test_dependencies = { "busted", } test = { type = "busted", } 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' } } } busted-2.2.0/rockspecs/busted-2.1.2-2.rockspec000066400000000000000000000117621452214637700206350ustar00rootroot00000000000000local package_name = "busted" local package_version = "2.1.2" local rockspec_revision = "1" local github_account_name = "lunarmodules" local github_repo_name = package_name 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" } 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', } test_dependencies = { "busted", } test = { type = "busted", } 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' } } } busted-2.2.0/rockspecs/busted-2.1.2-3.rockspec000066400000000000000000000116211452214637700206300ustar00rootroot00000000000000local package_name = "busted" local package_version = "2.1.2" local rockspec_revision = "3" 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' } } } busted-2.2.0/rockspecs/busted-2.2.0-1.rockspec000066400000000000000000000117041452214637700206270ustar00rootroot00000000000000local package_name = "busted" local package_version = "2.2.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', '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.ko'] = 'busted/languages/ko.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' } } } busted-2.2.0/spec/000077500000000000000000000000001452214637700137465ustar00rootroot00000000000000busted-2.2.0/spec/.hidden/000077500000000000000000000000001452214637700152575ustar00rootroot00000000000000busted-2.2.0/spec/.hidden/.busted000066400000000000000000000014661452214637700165550ustar00rootroot00000000000000return { _all = { ['ROOT'] = {'tests'}, }, default = { ['ROOT'] = {'specs'}, ['tags'] = {'tag11','tag22','tag33'}, ['exclude-tags'] = {'etag11','etag22','etag33'}, ['pattern'] = '_spec%.lua$', ['exclude-pattern'] = '_exclude', ['filter'] = 'filt', ['filter-out'] = 'filt-out', ['loaders'] = 'terra,moonscript', ['Xoutput'] = '-f,--flag', ['Xhelper'] = '-v,--verbose', }, test = { ['tags'] = 'test1,test2,test3', ['exclude-tags'] = 'etest1,etest2,etest3', ['pattern'] = {'_test1%.lua$', '_test2%.lua$'}, ['exclude-pattern'] = {'_exclude1', '_exclude2'}, ['filter'] = {'filt1', 'filt2'}, ['filter-out'] = {'filt1-out', 'filt2-out'}, ['loaders'] = {'lua','terra'}, ['Xoutput'] = {'-s','--sound'}, ['Xhelper'] = {'-t','--print'}, } } busted-2.2.0/spec/.hidden/.busted_bad000066400000000000000000000004061452214637700173540ustar00rootroot00000000000000return { _all = { ['ROOT'] = {'tests'}, }, default = { ['ROOT'] = {'specs'}, ['pattern'] = '_spec%.lua$', ['loaders'] = doesnotexist.loaders, -- errors when run ['verbose'] = true, }, test = { ['pattern'] = '_test%.lua$', } } busted-2.2.0/spec/.hidden/.busted_bad_syntax000066400000000000000000000004401452214637700207600ustar00rootroot00000000000000return { _all = { ['ROOT'] = {'tests'}, }, default = { ['ROOT'] = {'specs'}, ['pattern'] = '_spec%.lua$', ['loaders'] = doesnotexist.loaders, ['verbose'] = true, }, test = { ['pattern'] = '_test%.lua$', } -- } -- missing bracket, errors when compiled busted-2.2.0/spec/.hidden/.busted_empty000066400000000000000000000000001452214637700177520ustar00rootroot00000000000000busted-2.2.0/spec/.hidden/.luacov000066400000000000000000000023711452214637700165540ustar00rootroot00000000000000--- 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$', 'coxpcall$', 'mediator$', 'moonscript.*$', }, } busted-2.2.0/spec/.hidden/dont_execute_spec.lua000066400000000000000000000000471452214637700214630ustar00rootroot00000000000000assert(false,'should not be executed') busted-2.2.0/spec/.hidden/some_file.lua000066400000000000000000000000251452214637700177210ustar00rootroot00000000000000return "hello world" busted-2.2.0/spec/async_spec.lua000066400000000000000000000050171452214637700166030ustar00rootroot00000000000000pending('testing the done callback with tokens', function() it('Tests done call back ordered', function() async() stub(done, 'done_cb') -- create a stub to prevent actually calling 'done' done:wait_ordered('1', '2', '3') assert.has_no_error(function() done('1') end) assert.has_error(function() done('1') end) -- was already done assert.has_error(function() done('3') end) -- bad order assert.has_no_error(function() done('2') end) assert.has_error(function() done('this is no valid token') end) assert.has_no_error(function() done('3') end) assert.has_error(function() done('3') end) -- tokenlist empty by now assert.stub(done.done_cb).was.called(1) done.done_cb:revert() -- revert so test can complete done() end) it('Tests done call back unordered', function() async() stub(done, 'done_cb') -- create a stub to prevent actually calling 'done' done:wait_unordered('1', '2', '3') assert.has_no_error(function() done('1') end) assert.has_error(function() done('1') end) -- was already done assert.has_no_error(function() done('3') end) -- different order assert.has_no_error(function() done('2') end) assert.has_error(function() done('this is no valid token') end) assert.has_error(function() done('3') end) -- tokenlist empty by now assert.stub(done.done_cb).was.called(1) done.done_cb:revert() -- revert so test can complete done() end) it('Tests done call back defaulting to ordered', function() async() stub(done, 'done_cb') -- create a stub to prevent actually calling 'done' done:wait('1', '2') assert.has_error(function() done('2') end) -- different order assert.has_no_error(function() done('1') end) assert.has_no_error(function() done('2') end) done.done_cb:revert() -- revert so test can complete done() end) end) pending('testing done callbacks being provided for async tests', function() setup(function() async() assert.is_table(done) assert.is_function(done.wait) done() end) before_each(function() async() assert.is_table(done) assert.is_function(done.wait) done() end) after_each(function() async() assert.is_table(done) assert.is_function(done.wait) done() end) teardown(function() async() assert.is_table(done) assert.is_function(done.wait) done() end) it('Tests done callbacks being provided for async tests', function() async() assert.is_table(done) assert.is_function(done.wait) done() end) end) busted-2.2.0/spec/cl_compile_fail.lua000066400000000000000000000001571452214637700175550ustar00rootroot00000000000000-- supporting testfile; belongs to 'cl_spec.lua' nothing here, it should just fail when it is being compiled. busted-2.2.0/spec/cl_error_messages.lua000066400000000000000000000010471452214637700201510ustar00rootroot00000000000000-- supporting testfile; belongs to 'cl_spec.lua' describe('Test error messages show file and line for', function() it('table errors #table', function() error({}) end) it('nil errors #nil', function() error() end) it('string errors #string', function() error('error message') end) it('table errors #tostring', function() error(setmetatable({}, { __tostring = function() return '{}' end})) end) it('table errors #pcall', function() pcall(error, 'error inside pcall') error('error after pcall') end) end) busted-2.2.0/spec/cl_errors.lua000066400000000000000000000005611452214637700164450ustar00rootroot00000000000000-- supporting testfile; belongs to 'cl_spec.lua' describe('Tests the busted error detection through the commandline', function() it('is a test that throws an error #testerr', function() error('force an error') end) it('is a test with a Lua error #luaerr', function() local foo --luacheck: ignore foo.bar = nil --luacheck: ignore end) end) busted-2.2.0/spec/cl_execute_fail.lua000066400000000000000000000001631452214637700175640ustar00rootroot00000000000000-- supporting testfile; belongs to 'cl_spec.lua' error('This compiles fine, but throws an error when being run') busted-2.2.0/spec/cl_failing_support.lua000066400000000000000000000112021452214637700203300ustar00rootroot00000000000000 describe('bad support functions should fail, sync test', function() describe('bad setup should properly fail a test', function() setup(function() error('failing a setup method') end) before_each(function() end) after_each(function() end) teardown(function() end) it('Tests nothing, should always fail due to failing support functions', function() assert(false) end) it('Tests nothing, should always fail due to failing support functions', function() assert(false) end) end) describe('bad before_each should properly fail a test', function() setup(function() end) before_each(function() error('failing a before_each method') end) after_each(function() end) teardown(function() end) it('Tests nothing, should always fail due to failing support functions', function() end) it('Tests nothing, should always fail due to failing support functions', function() end) end) describe('bad after_each should properly fail a test', function() setup(function() end) before_each(function() end) after_each(function() error('failing an after_each method') end) teardown(function() end) it('Tests nothing, should always fail due to failing support functions', function() end) it('Tests nothing, should always fail due to failing support functions', function() end) end) describe('bad teardown should properly fail a test', function() setup(function() end) before_each(function() end) after_each(function() end) teardown(function() error('failing a teardown method') end) it('Tests nothing, should always fail due to failing support functions', function() end) it('Tests nothing, should always fail due to failing support functions', function() end) end) describe('bad setup/teardown should properly fail a test', function() setup(function() error('failing a setup method') end) before_each(function() end) after_each(function() end) teardown(function() error('failing a teardown method') end) it('Tests nothing, should always fail due to failing support functions', function() assert(false) end) end) end) describe('bad support functions should fail, async test', function() describe('bad setup should properly fail a test, async', function() setup(function() async() error('failing a setup method') end) before_each(function() end) after_each(function() end) teardown(function() end) it('Tests nothing, should always fail due to failing support functions', function() end) it('Tests nothing, should always fail due to failing support functions', function() end) end) describe('bad before_each should properly fail a test, async', function() setup(function() end) before_each(function() async() error('failing a before_each method') end) after_each(function() end) teardown(function() end) it('Tests nothing, should always fail due to failing support functions', function() end) it('Tests nothing, should always fail due to failing support functions', function() end) end) describe('bad after_each should properly fail a test, async', function() setup(function() end) before_each(function() end) after_each(function() async() error('failing an after_each method') end) teardown(function() end) it('Tests nothing, should always fail due to failing support functions', function() end) it('Tests nothing, should always fail due to failing support functions', function() end) end) describe('bad teardown should properly fail a test, async', function() setup(function() end) before_each(function() end) after_each(function() end) teardown(function() async() error('failing a teardown method') end) it('Tests nothing, should always fail due to failing support functions', function() end) it('Tests nothing, should always fail due to failing support functions', function() end) end) describe('bad setup/teardown should properly fail a test, async', function() setup(function() async() error('failing a setup method') end) before_each(function() end) after_each(function() end) teardown(function() async() error('failing a teardown method') end) it('Tests nothing, should always fail due to failing support functions', function() assert(false) end) it('Tests nothing, should always fail due to failing support functions', function() assert(false) end) end) end) busted-2.2.0/spec/cl_filter.lua000066400000000000000000000020731452214637700164160ustar00rootroot00000000000000-- supporting testfile; belongs to 'cl_spec.lua' describe('Tests the busted command-line options', function() it('is a test with pattern1', function() -- works by counting failure error('error 1 on pattern1') end) it('is another test with pattern1', function() -- works by counting failure error('error 2 on pattern1') end) it('is a test with pattern2', function() -- works by counting failure error('error on pattern2') end) it('is a test with pattern3', function() -- nothing here, makes it succeed end) it('is a test with two pattern3 and pattern4', function () -- Always succeed end) end) describe('Tests describe with patt1', function() before_each(function() error('error in before_each on patt1') end) after_each(function() error('error in after_each on patt1') end) it('is a test inside describe', function() end) it('is another test inside describe', function() end) end) context('Tests context with patt2', function() setup(function() error('error in setup on patt2') end) end) busted-2.2.0/spec/cl_gc_error.lua000066400000000000000000000004351452214637700167330ustar00rootroot00000000000000-- supporting testfile; belongs to 'cl_spec.lua' describe('Runs test with garbage collection failure', function() it('throws error in __gc metamethod', function() setmetatable({}, { __gc = function() error('gc error') end}) collectgarbage() collectgarbage() end) end) busted-2.2.0/spec/cl_helper_script.lua000066400000000000000000000046221452214637700177760ustar00rootroot00000000000000-- supporting testfile; belongs to 'cl_spec.lua' local setup = require 'busted'.setup local teardown = require 'busted'.teardown local before_each = require 'busted'.before_each local after_each = require 'busted'.after_each local subscribe = require 'busted'.subscribe local assert = require 'busted'.assert local cli = require 'cliargs' cli:set_name('cl_helper_script') cli:flag('--fail-setup', 'force setup to fail') cli:flag('--fail-teardown', 'force teardown to fail') cli:flag('--fail-before-each', 'force before each to fail') cli:flag('--fail-after-each', 'force after each to fail') cli:flag('--fail-suite-reset', 'force suite reset handler to fail') cli:flag('--fail-suite-start', 'force suite start handler to fail') cli:flag('--fail-suite-end', 'force suite end handler to fail') cli:flag('--fail-file-start', 'force file start handler to fail') cli:flag('--fail-file-end', 'force file end handler to fail') cli:flag('--fail-describe-start', 'force describe start handler to fail') cli:flag('--fail-describe-end', 'force describe end handler to fail') cli:flag('--fail-test-start', 'force test start handler to fail') cli:flag('--fail-test-end', 'force test end handler to fail') local cliArgs = cli:parse(arg) setup(function() assert(not cliArgs['fail-setup']) end) teardown(function() assert(not cliArgs['fail-teardown']) end) before_each(function() assert(not cliArgs['fail-before-each']) end) after_each(function() assert(not cliArgs['fail-after-each']) end) subscribe({'suite', 'reset'}, function() assert(not cliArgs['fail-suite-reset']) return nil, true end) subscribe({'suite', 'start'}, function() assert(not cliArgs['fail-suite-start']) return nil, true end) subscribe({'suite', 'end'}, function() assert(not cliArgs['fail-suite-end']) return nil, true end) subscribe({'file', 'start'}, function() assert(not cliArgs['fail-file-start']) return nil, true end) subscribe({'file', 'end'}, function() assert(not cliArgs['fail-file-end']) return nil, true end) subscribe({'describe', 'start'}, function() assert(not cliArgs['fail-describe-start']) return nil, true end) subscribe({'describe', 'end'}, function() assert(not cliArgs['fail-describe-end']) return nil, true end) subscribe({'test', 'start'}, function() assert(not cliArgs['fail-test-start']) return nil, true end) subscribe({'test', 'end'}, function() assert(not cliArgs['fail-test-end']) return nil, true end) busted-2.2.0/spec/cl_list.lua000066400000000000000000000002761452214637700161070ustar00rootroot00000000000000-- supporting testfile; belongs to 'cl_spec.lua' describe('Tests list', function() it('test 1', function() end) it('test 2', function() end) it('test 3', function() end) end) busted-2.2.0/spec/cl_lua_path.lua000066400000000000000000000003651452214637700167300ustar00rootroot00000000000000-- supporting testfile; belongs to 'cl_spec.lua' describe('Tests --lpath prepends to package.path', function() it('require test module', function() local mod = require('cl_test_module') assert.is_equal('test module', mod) end) end) busted-2.2.0/spec/cl_moonscript_error_messages.moon000066400000000000000000000005671452214637700226230ustar00rootroot00000000000000-- supporting testfile; belongs to 'cl_spec.lua' describe 'Test moonscript errors show file and line for', -> it 'failures #fail', -> assert.is_equal true, false return it 'table errors #table', -> error {} return it 'nil errors #nil', -> error! return it 'string errors #string', -> error 'error message' return return return busted-2.2.0/spec/cl_output_handler.lua000066400000000000000000000020601452214637700201620ustar00rootroot00000000000000-- supporting testfile; belongs to 'cl_spec.lua' return function(options) local busted = require 'busted' local handler = require 'busted.outputHandlers.base'() local cli = require 'cliargs' local args = options.arguments cli:set_name('cl_output_handler') cli:flag('--time', 'show timestamps') cli:option('--time-format=FORMAT', 'format string according to strftime', '!%a %b %d %H:%M:%S %Y') 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 local timeFormat = cliArgs['time-format'] local timestamp = showTime and ('[' .. os.date(timeFormat, 123456) .. '] ') or '' print(string.format("%s[%8s] %s", timestamp, status, handler.getFullName(element))) end busted.subscribe({ 'test', 'end' }, handler.testEnd, { predicate = handler.cancelOnPending }) return handler end busted-2.2.0/spec/cl_pending.lua000066400000000000000000000007431452214637700165570ustar00rootroot00000000000000-- supporting testfile; belongs to 'cl_spec.lua' describe('Tests the busted pending functions through the commandline', function() it('is a test with a pending', function() pending('finish this test later') error('should never get here') end) pending('is a pending inside a describe', function() it('this test does not run', function() error('this should not run') end) end) pending('is a pending inside a describe, without func argument') end) busted-2.2.0/spec/cl_random_seed.lua000066400000000000000000000012541452214637700174110ustar00rootroot00000000000000-- supporting testfile; belongs to 'cl_spec.lua' -- executed with --seed=12345 local order = {} describe('Randomizing test order with pre-defined seed', function() randomize() for i = 1, 10 do it('does 10 its', function() table.insert(order, i) end) end end) describe('Order of tests ran', function() randomize() it('randomized with known random seed', function() math.randomseed(12345) local t = {} for i = 1, 10 do table.insert(t, i) end local n = #t while n >= 1 do local k = math.random(n) t[n], t[k] = t[k], t[n] n = n - 1 end local expected = t assert.are.same(expected, order) end) end) busted-2.2.0/spec/cl_randomize.lua000066400000000000000000000006171452214637700171230ustar00rootroot00000000000000-- supporting testfile; belongs to 'cl_spec.lua' local unexpected = {} local order = {} describe('Randomizing test order with --shuffle flag', function() for i = 1, 100 do table.insert(unexpected, i) it('does 100 its', function() table.insert(order, i) end) end teardown('runs tests in randomized order', function() assert.are_not.same(unexpected, order) end) end) busted-2.2.0/spec/cl_sort.lua000066400000000000000000000012131452214637700161130ustar00rootroot00000000000000-- supporting testfile; belongs to 'cl_spec.lua' describe('Randomizing test order with --sort flag', function() local expected = {} local scratch = {} local order = {} for i = 1, 100 do table.insert(expected, i) table.insert(scratch, i) end while #scratch > 0 do local n = #scratch local k = math.random(n) local num = scratch[k] it(string.format('test number %03d', num), function() table.insert(order, num) end) scratch[k], scratch[n] = scratch[n], scratch[k] table.remove(scratch) end teardown('runs tests in sorted order', function() assert.are.same(expected, order) end) end) busted-2.2.0/spec/cl_spec.lua000066400000000000000000001034041452214637700160630ustar00rootroot00000000000000local 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' -- if exitcode >256, then take MSB as exit code local modexit = function(exitcode) if exitcode>255 then return math.floor(exitcode/256), exitcode - math.floor(exitcode/256)*256 else return exitcode end end local execute = function(cmd) local success, exitcode, out, err = utils.executeex(cmd) return not not success, modexit(exitcode), out, err end local executeBusted = function(args) local success, _, out, err = execute(busted_cmd .. ' ' .. args) local count = 0 for failures, errors in out:gmatch('(%d+) failures? / (%d+) errors?') do count = count + failures + errors end return success, count, out, err end local executeLua = function(args) local success, _, out, err = execute('lua ' .. args) local count = 0 for failures, errors in out:gmatch('(%d+) failures? / (%d+) errors?') do count = count + failures + errors end return success, count, out, err end describe('Tests the busted command-line options', function() it('tests running with --tags specified', function() local success, errcnt = executeBusted('--pattern=_tags.lua$') assert.is_false(success) assert.is_equal(8, errcnt) success, errcnt = executeBusted('--pattern=_tags.lua$ --tags=tag1') assert.is_false(success) assert.is_equal(3, errcnt) success, errcnt = executeBusted('--pattern=_tags.lua$ --tags=tag1,tag2') assert.is_false(success) assert.is_equal(4, errcnt) success, errcnt = executeBusted('--pattern=_tags.lua$ --tags=tag1 --tags=tag2') assert.is_false(success) assert.is_equal(4, errcnt) end) it('tests running with --exclude-tags specified', function() local success, errcnt = executeBusted('--pattern=_tags.lua$ --exclude-tags=tag1,tag2,dtag1,dtag2') assert.is_true(success) assert.is_equal(0, errcnt) success, errcnt = executeBusted('--pattern=_tags.lua$ --exclude-tags=tag2,dtag1,dtag2') assert.is_false(success) assert.is_equal(2, errcnt) success, errcnt = executeBusted('--pattern=_tags.lua$ --exclude-tags=tag2 --exclude-tags=dtag1,dtag2') assert.is_false(success) assert.is_equal(2, errcnt) end) it('tests running with --tags and --exclude-tags specified', function () local success, _ = executeBusted('--pattern=_tags.lua$ --tags=tag1 --exclude-tags=tag1') assert.is_false(success) success, _ = executeBusted('--pattern=_tags.lua$ --tags=tag3 --exclude-tags=tag4') assert.is_false(success) end) it('tests running with --tags specified in describe', function () local success, errcnt = executeBusted('--pattern=_tags.lua$ --tags=dtag1') assert.is_false(success) assert.is_equal(5, errcnt) success, errcnt = executeBusted('--pattern=_tags.lua$ --tags=dtag2') assert.is_false(success) assert.is_equal(1, errcnt) end) it('tests running with --exclude-pattern specified', function () local success, errcnt = executeBusted('--pattern="^cl_.*fail.*.lua$" --exclude-pattern="failing"') assert.is_false(success) assert.is_equal(4, errcnt) end) it('tests running with --exclude-pattern="" disables exclude-pattern', function () local success, errcnt = executeBusted('--pattern="cl_two_failures.lua$" --exclude-pattern ""') assert.is_false(success) assert.is_equal(2, errcnt) success = executeBusted('--pattern="cl_success.lua$" --exclude-pattern=') assert.is_true(success) end) it('tests running with the same --pattern and --exclude-pattern specified', function () local success, errcnt = executeBusted('--pattern="^cl_.*fail.*.lua$" --exclude-pattern="fail"') assert.is_false(success) assert.is_equal(1, errcnt) end) it('tests running with --filter specified', function () local success, errcnt = executeBusted('--pattern=_filter.lua$') assert.is_false(success) assert.is_equal(8, errcnt) success, errcnt = executeBusted('--pattern=_filter.lua$ --filter="pattern1"') assert.is_false(success) assert.is_equal(3, errcnt) success, errcnt = executeBusted('--pattern=_filter.lua$ --filter="pattern2"') assert.is_false(success) assert.is_equal(2, errcnt) success, errcnt = executeBusted('--pattern=_filter.lua$ --filter="pattern1" --filter="pattern2"') assert.is_false(success) assert.is_equal(4, errcnt) end) it('tests running with --filter-out specified', function () local success, errcnt = executeBusted('--pattern=_filter.lua$ --filter-out="pattern1"') assert.is_false(success) assert.is_equal(6, errcnt) success, errcnt = executeBusted('--pattern=_filter.lua$ --filter-out="pattern%d"') assert.is_false(success) assert.is_equal(5, errcnt) success, errcnt = executeBusted('--pattern=_filter.lua$ --filter-out="patt1" --filter-out="patt2"') assert.is_false(success) assert.is_equal(3, errcnt) success = executeBusted('--pattern=_filter.lua$ --filter-out="patt.*(%d)"') assert.is_true(success) end) it('tests running with --filter and --filter-out specified', function () local success, _ = executeBusted('--pattern=_filter.lua$ --filter="pattern3" --filter-out="patt.*[12]"') assert.is_true(success) end) local function count_successes(out) local count = 0 for successes in out:gmatch('(%d+) success') do count = count + successes end return count end it('tests running with --log-success and --exclude-names-file specified', function () local logfile = os.tmpname() local success, errcnt, out = executeBusted('--pattern=_filter.lua$ --log-success=' .. logfile .. ' --exclude-names-file=' .. logfile) assert.is_false(success) assert.equals(8, errcnt) assert.equals(2, count_successes(out)) -- re-run tests with previously successful tests skipped success, errcnt, out = executeBusted('--pattern=_filter.lua$ --log-success=' .. logfile .. ' --exclude-names-file=' .. logfile) assert.is_false(success) assert.equals(8, errcnt) assert.equals(0, count_successes(out)) os.remove(logfile) end) it('tests running with --filter specified in describe', function () local success, errcnt = executeBusted('--pattern=_filter.lua$ --filter="patt1"') assert.is_false(success) assert.is_equal(5, errcnt) success, errcnt = executeBusted('--pattern=_filter.lua$ --filter="patt2"') assert.is_false(success) assert.is_equal(1, errcnt) end) it('tests running with --lazy specified', function() local success, errcnt = executeBusted('--lazy --pattern=_tags.lua$') assert.is_false(success) assert.is_equal(7, errcnt) success, errcnt = executeBusted('--lazy --pattern=_tags.lua$ --tags=tag1') assert.is_false(success) assert.is_equal(2, errcnt) success, errcnt = executeBusted('--lazy --pattern=_tags.lua$ --tags=tag1,tag2') assert.is_false(success) assert.is_equal(3, errcnt) success, errcnt = executeBusted('--lazy --pattern=_tags.lua$ --tags=tag1 --tags=tag2') assert.is_false(success) assert.is_equal(3, errcnt) end) it('tests running with -l specified', function() local _, _, result = executeBusted('-l --pattern=cl_list.lua$') local expected = 'spec/cl_list.lua:4: Tests list test 1\n' .. 'spec/cl_list.lua:7: Tests list test 2\n' .. 'spec/cl_list.lua:10: Tests list test 3\n' assert.is_equal(normpath(expected), result) end) it('tests running with --list specified', function() local _, _, result = executeBusted('--list --pattern=cl_list.lua$') local expected = 'spec/cl_list.lua:4: Tests list test 1\n' .. 'spec/cl_list.lua:7: Tests list test 2\n' .. 'spec/cl_list.lua:10: Tests list test 3\n' assert.is_equal(normpath(expected), result) end) it('tests running with --lpath specified', function() local success, errcnt = executeBusted('--lpath="spec/?.lua" spec/cl_lua_path.lua') assert.is_true(success) assert.is_equal(0, errcnt) end) it('tests running with --lang specified', function() local success, errcnt = executeBusted('--pattern=cl_success.lua$ --lang=en') assert.is_true(success) assert.is_equal(0, errcnt) success = executeBusted('--pattern=cl_success --lang=not_found_here') assert.is_false(success) end) it('tests running with --version specified', function() local success, errcnt = executeBusted('--version') assert.is_true(success) assert.is_equal(0, errcnt) end) it('tests running with --help specified', function() local success, _ = executeBusted('--help') assert.is_false(success) end) it('tests running a non-compiling testfile', function() local success, errcnt = executeBusted('--pattern=cl_compile_fail.lua$') assert.is_false(success) assert.is_equal(1, errcnt) end) it('tests running a testfile throwing errors when being run', function() local success, errcnt = executeBusted('--pattern=cl_execute_fail.lua$') assert.is_false(success) assert.is_equal(1, errcnt) end) it('tests running a non-existing configfile', function() local success, errcnt = executeBusted('--config-file=spec/.hidden/.this_one_does_not_exist --pattern=cl_execute_fail.lua$') assert.is_false(success) assert.is_equal(0, errcnt) end) it('tests running a non-compiling configfile', function() local success, errcnt = executeBusted('--config-file=spec/.hidden/.busted_bad_syntax --pattern=cl_execute_fail.lua$') assert.is_false(success) assert.is_equal(0, errcnt) end) it('tests running a configfile throwing errors when being run', function() local success, errcnt, _, _ = executeBusted('--config-file=spec/.hidden/.busted_bad --pattern=cl_execute_fail.lua$') assert.is_false(success) assert.is_equal(0, errcnt) end) it('tests running with --output specified', function() local success, errcnt = executeBusted('--pattern=cl_success.lua$ --output=TAP') assert.is_true(success) assert.is_equal(0, errcnt) success, errcnt = executeBusted('--pattern=cl_two_failures.lua$ --output=not_found_here') assert.is_false(success) assert.is_equal(2, errcnt) end) it('tests running with --output specified with module in lua path', function() local success, errcnt = executeBusted('--pattern=cl_success.lua$ --output=busted.outputHandlers.TAP') assert.is_true(success) assert.is_equal(0, errcnt) end) it('tests no tests to exit with a fail-exitcode', function() local success, exitcode = execute(busted_cmd ..' --pattern=this_filename_does_simply_not_exist$') assert.is_false(success) assert.is_equal(1, exitcode) end) it('can switch interpreters', function() local lua_exe = normpath(path.is_windows and 'spec/lua.bat' or 'spec/lua.lua') local success, errcnt, out = executeBusted('--lua=' .. lua_exe .. ' spec/cl_success.lua') assert.is_true(success) 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() it('tests failing setup/before_each/after_each/teardown functions', function() local success, errcnt = executeBusted('--pattern=cl_failing_support.lua$') assert.is_false(success) assert.is_equal(16, errcnt) end) it('tests failing support functions as errors', function() local _, _, result = executeBusted('--output=plainTerminal --pattern=cl_failing_support.lua$') local _, numErrors = result:gsub('Error %-> .-\n','') assert.is_equal(16, numErrors) end) end) describe('Test busted running standalone', function() it('tests running with --tags specified', function() local success, errcnt = executeLua('spec/cl_standalone.lua') assert.is_false(success) assert.is_equal(3, errcnt) success, errcnt = executeLua('spec/cl_standalone.lua --tags=tag1') assert.is_false(success) assert.is_equal(2, errcnt) success, errcnt = executeLua('spec/cl_standalone.lua --tags=tag1,tag2') assert.is_false(success) assert.is_equal(3, errcnt) end) it('tests running with --exclude-tags specified', function() local success, errcnt = executeLua('spec/cl_standalone.lua --exclude-tags=tag1,tag2') assert.is_true(success) assert.is_equal(0, errcnt) success, errcnt = executeLua('spec/cl_standalone.lua --exclude-tags=tag2') assert.is_false(success) assert.is_equal(2, errcnt) end) it('tests running with --tags and --exclude-tags specified', function () local success, _ = executeLua('spec/cl_standalone.lua --tags=tag1 --exclude-tags=tag1') assert.is_false(success) success, _ = executeLua('spec/cl_standalone.lua --tags=tag3 --exclude-tags=tag4') assert.is_true(success) end) it('tests running with --helper specified', function () local success, errcnt = executeLua('spec/cl_standalone.lua --helper=spec/cl_helper_script.lua -Xhelper "--fail-teardown,--fail-after-each"') assert.is_false(success) assert.is_equal(9, errcnt) end) it('tests running with --version specified', function() local success, errcnt = executeLua('spec/cl_standalone.lua --version') assert.is_true(success) assert.is_equal(0, errcnt) end) it('tests running with --help specified', function() local success = executeLua('spec/cl_standalone.lua --help') assert.is_false(success) end) it('tests running via stdin', function() local success, errcnt = executeLua('< spec/cl_standalone.lua') assert.is_false(success) assert.is_equal(3, errcnt) end) end) describe('Test busted command-line runner', function() it('runs standalone spec', function() local success, errcnt = executeBusted('spec/cl_standalone.lua') assert.is_false(success) assert.is_equal(3, errcnt) success, errcnt = executeBusted('--tags=tag1 spec/cl_standalone.lua') assert.is_false(success) assert.is_equal(2, errcnt) success, errcnt = executeBusted('--tags=tag1,tag2 spec/cl_standalone.lua') assert.is_false(success) assert.is_equal(3, errcnt) end) end) describe('Tests distinguish between errors and failures', function() it('by detecting errors as test errors', function() local _, _, result = executeBusted('--output=plainTerminal --pattern=cl_errors.lua$ --tags=testerr') local errmsg = result:match('(Error %-> .-)\n') assert.is_truthy(errmsg) end) it('by detecting assert failures as test failures', function() local _, _, result = executeBusted('--output=plainTerminal --pattern=cl_two_failures.lua$') local failmsg = result:match('(Failure %-> .-)\n') assert.is_truthy(failmsg) end) it('by detecting Lua runtime errors as test errors', function() local _, _, result = executeBusted('--output=plainTerminal --pattern=cl_errors.lua$ --tags=luaerr') local failmsg = result:match('(Error %-> .-)\n') assert.is_truthy(failmsg) end) end) describe('Tests stack trackback', function() it('when throwing an error', function() local _, _, result = executeBusted('--verbose --pattern=cl_errors.lua$ --tags=testerr') local errmsg = result:match('(stack traceback:.*)\n') local expected = [[stack traceback: spec/cl_errors.lua:6: in function ]] assert.is_equal(normpath(expected), errmsg) end) it('when assertion fails', function() local _, _, result = executeBusted('--verbose --pattern=cl_two_failures.lua$ --tags=err1') local errmsg = result:match('(stack traceback:.*)\n') local expected = [[stack traceback: spec/cl_two_failures.lua:6: in function ]] assert.is_equal(normpath(expected), errmsg) end) it('when Lua runtime error', function() local _, _, result = executeBusted('--verbose --pattern=cl_errors.lua$ --tags=luaerr') local errmsg = result:match('(stack traceback:.*)\n') local expected = [[stack traceback: spec/cl_errors.lua:11: in function ]] assert.is_equal(normpath(expected), errmsg) end) end) describe('Tests error messages through the command line', function() it('when throwing errors in a test', function() local _, _, result = executeBusted('--output=plainTerminal --pattern=cl_errors.lua$ --tags=testerr') local err = result:match('(Error %-> .-)\n') local errmsg = result:match('\n(spec[/\\].-)\n') local expectedErr = "Error -> spec/cl_errors.lua @ 5" local expectedMsg = "spec/cl_errors.lua:6: force an error" assert.is_equal(normpath(expectedErr), err) assert.is_equal(normpath(expectedMsg), errmsg) end) it('when throwing an error table', function() local _, _, result = executeBusted('--output=plainTerminal --tags=table --pattern=cl_error_messages.lua$') local errmsg = result:match('\n(spec[/\\].-)\n') local expected = 'spec/cl_error_messages.lua:5: {' assert.is_equal(normpath(expected), errmsg) end) it('when throwing a nil error', function() local _, _, result = executeBusted('--output=plainTerminal --tags=nil --pattern=cl_error_messages.lua$') local errmsg = result:match('\n(spec[/\\].-)\n') local expected = 'spec/cl_error_messages.lua:9: Nil error' assert.is_equal(normpath(expected), errmsg) end) it('when throwing an error table with __tostring', function() local _, _, result = executeBusted('--output=plainTerminal --tags=tostring --pattern=cl_error_messages.lua$') local errmsg = result:match('\n(spec[/\\].-)\n') local expected = 'spec/cl_error_messages.lua:17: {}' assert.is_equal(normpath(expected), errmsg) end) it('when throwing after a pcall', function() local _, _, result = executeBusted('--output=plainTerminal --tags=pcall --pattern=cl_error_messages.lua$') local errmsg = result:match('\n(spec[/\\].-)\n') local expected = 'spec/cl_error_messages.lua:22: error after pcall' assert.is_equal(normpath(expected), errmsg) end) it('when running a non-compiling testfile', function() local _, _, result = executeBusted('--output=plainTerminal --pattern=cl_compile_fail.lua$') local errmsg = result:match('(Error %-> .-:%d+:) ') local expected = "Error -> spec/cl_compile_fail.lua:3:" assert.is_equal(normpath(expected), errmsg) end) it('when a testfile throws errors', function() local _, _, result = executeBusted('--output=plainTerminal --pattern=cl_execute_fail.lua$') local err = result:match('(Error %-> .-)\n') local errmsg = result:match('\n(spec[/\\]cl_execute_fail%.lua:%d+:.-)\n') local expectedErr = 'Error -> spec/cl_execute_fail.lua @ 4' local expectedMsg = 'spec/cl_execute_fail.lua:4: This compiles fine, but throws an error when being run' assert.is_equal(normpath(expectedErr), err) assert.is_equal(normpath(expectedMsg), errmsg) end) it('when output library not found', function() local _, _, _, rerr = executeBusted('--pattern=cl_two_failures.lua$ --output=not_found_here 2>&1') local errmsg = rerr:match('(.-)\n') local expected = 'busted: error: Cannot load output library: not_found_here' assert.is_equal(expected, errmsg) end) it('when helper script not found', function() local success, _, _, rerr = executeBusted('--output=plainTerminal --pattern=cl_two_failures.lua$ --helper=not_found_here 2>&1') assert.is.False(success) local err = rerr:match('error: .-:%d+: (.-)\n') local errmsg = rerr:match('(.-), error:') local expectedErr = "module 'not_found_here' not found:" local expectedMsg = 'busted: failed running the specified helper (not_found_here)' assert.is_equal(expectedErr, err) assert.is_equal(expectedMsg, errmsg) end) it('when helper lua script not found', function() local success, _, _, rerr = executeBusted('--output=plainTerminal --pattern=cl_two_failures.lua$ --helper=not_found_here.lua 2>&1') assert.is.False(success) local err = rerr:match('error: (.-)\n') local errmsg = rerr:match('(.-)\n') local expectedErr = 'cannot open not_found_here.lua: No such file or directory' local expectedMsg = 'busted: failed running the specified helper (not_found_here.lua), error: cannot open not_found_here.lua: No such file or directory' assert.is_equal(expectedErr, err) assert.is_equal(expectedMsg, errmsg) end) it('when test file not found', function() local _, _, result = executeBusted('--output=plainTerminal does_not_exist.lua') local errmsg = result:match('Error %-> (.-)\n') local expected = 'Cannot find file or directory: does_not_exist.lua' assert.is_equal(expected, errmsg) end) it('when test directory not found', function() local _, _, result = executeBusted('--output=plainTerminal does_not_exist') local errmsg = result:match('Error %-> (.-)\n') local expected = 'Cannot find file or directory: does_not_exist' assert.is_equal(expected, errmsg) end) it('when no test files matching Lua pattern', function() local _, _, result = executeBusted('--output=plainTerminal --pattern=this_filename_does_simply_not_exist$') local errmsg = result:match('Error %-> (.-)\n') local expected = 'No test files found matching Lua pattern: this_filename_does_simply_not_exist$' assert.is_equal(expected, errmsg) end) it('when __gc metamethod throws error', function() local noGC = xpcall(function() setmetatable({}, { __gc = function() error('gc error') end}) collectgarbage() collectgarbage() end, function() end) if noGC then pending('no __gc metamethod support') end local success, errcnt, result = executeBusted('--pattern=cl_gc_error.lua$') local err = result:match('Error %-> (.-)\n') local errmsg = result:match('\n([^\n]-%(spec[/\\].-%))\n') local expected = 'error in __gc metamethod (spec/cl_gc_error.lua:5: gc error)' assert.is_false(success) assert.is_equal(1, errcnt) assert.is_truthy(err) assert.is_equal(normpath(expected), errmsg) end) end) local has_moon = pcall(require, 'moonscript') local describe_moon = (has_moon and describe or pending) describe_moon('Tests moonscript error messages through the command line', function() it('when assertion fails', function() local _, _, result = executeBusted('--output=plainTerminal --pattern=cl_moonscript_error_messages.moon$ --tags=fail') local err = result:match('(Failure %-> .-)\n') local errmsg = result:match('\n(spec[/\\].-)\n') local expectedErr = "Failure -> spec/cl_moonscript_error_messages.moon @ 4" local expectedMsg = "spec/cl_moonscript_error_messages.moon:5: Expected objects to be equal." assert.is_equal(normpath(expectedErr), err) assert.is_equal(normpath(expectedMsg), errmsg) end) it('when throwing string errors', function() local _, _, result = executeBusted('--output=plainTerminal --pattern=cl_moonscript_error_messages.moon$ --tags=string') local err = result:match('(Error %-> .-)\n') local errmsg = result:match('\n(spec[/\\].-)\n') local expectedErr = "Error -> spec/cl_moonscript_error_messages.moon @ 16" local expectedMsg = "spec/cl_moonscript_error_messages.moon:17: error message" assert.is_equal(normpath(expectedErr), err) assert.is_equal(normpath(expectedMsg), errmsg) end) it('when throwing an error table', function() local _, _, result = executeBusted('--output=plainTerminal --tags=table --pattern=cl_moonscript_error_messages.moon$') local errmsg = result:match('\n(spec[/\\].-)\n') local expected = 'spec/cl_moonscript_error_messages.moon:9: {' assert.is_equal(normpath(expected), errmsg) end) it('when throwing a nil error', function() local _, _, result = executeBusted('--output=plainTerminal --tags=nil --pattern=cl_moonscript_error_messages.moon$') local errmsg = result:match('\n(spec[/\\].-)\n') local expected = 'spec/cl_moonscript_error_messages.moon:13: Nil error' assert.is_equal(normpath(expected), errmsg) end) end) describe('Tests pending through the commandline', function() it('skips tests inside pending scope', function() local success, errcnt success, errcnt = executeBusted('--pattern=cl_pending.lua$') assert.is_true(success) assert.is_equal(0, errcnt) end) it('detects tests as pending', function() local _, _, result = executeBusted('--output=plainTerminal --pattern=cl_pending.lua$') local line1 = result:match('.-\n') local _, pendingDots = line1:gsub('%.', '') local _, numPending = result:gsub('Pending %-> .-\n', '') assert.is_equal(3, pendingDots) assert.is_equal(3, numPending) end) it('--suppress-pending option is honored', function() local _, _, result = executeBusted('--output=plainTerminal --suppress-pending --pattern=cl_pending.lua$') local line1 = result:match('.-\n') local _, pendingDots = line1:gsub('%.', '') local _, numPending = result:gsub('Pending %-> .-\n', '') assert.is_equal(0, pendingDots) assert.is_equal(0, numPending) end) end) describe('Tests random seed through the commandline', function() it('test seed value', function() local success, errcnt success, errcnt = executeBusted('--seed=12345 --pattern=cl_random_seed.lua$') assert.is_true(success) assert.is_equal(0, errcnt) end) it('test invalid seed value exits with error', function() local success, _ = executeBusted('--seed=abcd --pattern=cl_random_seed.lua$') assert.is_false(success) end) it('test failure outputs random seed value', function() local _, _, result = executeBusted('--seed=789 --pattern=cl_random_seed.lua$') local seed = result:match('Random seed: (%d+)\n') assert.is_equal(789, tonumber(seed)) end) it('test non-randomized failure does not output seed value', function() local _, _, result = executeBusted('--seed=789 --pattern=cl_two_failures.lua$') local seed = result:match('Random seed:') assert.is_equal(nil, seed) end) end) describe('Tests shuffle commandline option', function() for _, opt in ipairs({ '--shuffle', '--shuffle-tests' }) do it('forces test shuffling for non-randomized tests, ' .. opt, function() local success, errcnt = executeBusted(opt .. ' --pattern=cl_randomize.lua$') assert.is_true(success) assert.is_equal(0, errcnt) end) end end) describe('Tests sort commandline option', function() for _, opt in ipairs({ '--sort', '--sort-tests' }) do it('sorts tests by name, ' .. opt, function() local success, errcnt = executeBusted(opt .. ' --pattern=cl_sort.lua$') assert.is_true(success) assert.is_equal(0, errcnt) end) end end) describe('Tests repeat commandline option', function() it('forces tests to repeat n times', function() local success, errcnt = executeBusted('--repeat=2 --pattern=cl_two_failures.lua$') assert.is_false(success) assert.is_equal(4, errcnt) end) it('exits with error when repeat is invalid', function() local success, _ = executeBusted('--repeat=abc --pattern=cl_success.lua$') assert.is_false(success) end) end) describe('Tests no-keep-going commandline option', function() it('skips all tests after first error', function() local success, errcnt = executeBusted('--no-keep-going --pattern=cl_two_failures.lua$') assert.is_false(success) assert.is_equal(1, errcnt) end) end) describe('Tests no-recursive commandline option', function() it('does not run any tests in subdirectories', function() local success, errcnt = executeBusted('--no-recursive --pattern=cl_two_failures.lua$ .') assert.is_false(success) assert.is_equal(1, errcnt) end) end) describe('Tests no-auto-insulate commandline option', function() it('does not insulate test files', function() local success, errcnt = executeBusted('--no-auto-insulate --pattern=insulate_file.*.lua$') assert.is_false(success) assert.is_equal(1, errcnt) end) end) describe('Tests Xoutput commandline option', function() it('forwards no options to output handler when no options specified', function() local _, _, result = executeBusted('--output=spec/cl_output_handler.lua --pattern=cl_success.lua$') local status = result:match('^%[(.-)]') assert.is_equal(' success', status) end) it('forwards single option to output handler', function() local _, _, result = executeBusted('--output=spec/cl_output_handler.lua -Xoutput "--time" --pattern=cl_success.lua$') local timestamp = result:match('^%[(.-)]') assert.is_equal('Fri Jan 02 10:17:36 1970', timestamp) end) it('forwards multiple options to output handler', function() local _, _, result = executeBusted('--output=spec/cl_output_handler.lua -Xoutput "--time,--time-format=!%H:%M:%S" --pattern=cl_success.lua$') local timestamp = result:match('^%[(.-)]') assert.is_equal('10:17:36', timestamp) end) it('forwards multiple options to output handler using multiple -Xoutput', function() local _, _, result = executeBusted('--output=spec/cl_output_handler.lua -Xoutput "--time" -Xoutput "--time-format=!%H:%M:%S" --pattern=cl_success.lua$') local timestamp = result:match('^%[(.-)]') assert.is_equal('10:17:36', timestamp) end) end) describe('Tests Xhelper commandline option', function() it('forwards no options to helper script when no options specified', function() local success = executeBusted('--helper=spec/cl_helper_script.lua --pattern=cl_success.lua$') assert.is_true(success) end) it('forwards single option to helper script', function() local success, errcnt = executeBusted('--helper=spec/cl_helper_script.lua -Xhelper "--fail-before-each" --pattern=cl_success.lua$') assert.is_false(success) assert.is_equal(1, errcnt) end) it('forwards multiple options to helper script', function() local success, errcnt = executeBusted('--helper=spec/cl_helper_script.lua -Xhelper "--fail-before-each,--fail-after-each" --pattern=cl_success.lua$') assert.is_false(success) assert.is_equal(2, errcnt) end) it('forwards multiple options to helper script using multiple -Xhelper', function() local success, errcnt = executeBusted('--helper=spec/cl_helper_script.lua -Xhelper "--fail-before-each" -Xhelper "--fail-after-each" --pattern=cl_success.lua$') assert.is_false(success) assert.is_equal(2, errcnt) end) end) describe('Tests helper script', function() it('can add setup to test suite', function() local success, errcnt = executeBusted('--helper=spec/cl_helper_script.lua -Xhelper "--fail-setup" --pattern=cl_two_failures.lua$') assert.is_false(success) assert.is_equal(1, errcnt) end) it('can add teardown to test suite', function() local success, errcnt = executeBusted('--helper=spec/cl_helper_script.lua -Xhelper "--fail-teardown" --pattern=cl_two_failures.lua$') assert.is_false(success) assert.is_equal(3, errcnt) end) it('runs setup/teardown for mutiple runs', function() local success, errcnt = executeBusted('--helper=spec/cl_helper_script.lua -Xhelper "--fail-setup,--fail-teardown" --pattern=cl_success.lua$ --repeat=2') assert.is_false(success) assert.is_equal(4, errcnt) end) it('runs setup/teardown for mutiple runs with --lazy', function() local success, errcnt = executeBusted('--lazy --helper=spec/cl_helper_script.lua -Xhelper "--fail-setup,--fail-teardown" --pattern=cl_success.lua$ --repeat=2') assert.is_false(success) assert.is_equal(4, errcnt) end) it('can subscribe to suite start/reset', function() local success, errcnt = executeBusted('--helper=spec/cl_helper_script.lua -Xhelper "--fail-suite-start,--fail-suite-reset" --pattern=cl_success.lua$ --repeat=2') assert.is_false(success) assert.is_equal(3, errcnt) end) it('can subscribe to suite end', function() local success, errcnt = executeBusted('--helper=spec/cl_helper_script.lua -Xhelper "--fail-suite-end" --pattern=cl_success.lua$') assert.is_false(success) assert.is_equal(0, errcnt) end) it('can subscribe to file start/end', function() local success, errcnt = executeBusted('--helper=spec/cl_helper_script.lua -Xhelper "--fail-file-start,--fail-file-end" --pattern=cl_success.lua$') assert.is_false(success) assert.is_equal(2, errcnt) end) it('can subscribe to describe start/end', function() local success, errcnt = executeBusted('--helper=spec/cl_helper_script.lua -Xhelper "--fail-describe-start,--fail-describe-end" --pattern=cl_success.lua$') assert.is_false(success) assert.is_equal(2, errcnt) end) it('can subscribe to test start/end', function() local success, errcnt = executeBusted('--helper=spec/cl_helper_script.lua -Xhelper "--fail-test-start,--fail-test-end" --pattern=cl_two_failures.lua$') assert.is_false(success) assert.is_equal(4, errcnt) end) end) describe('Tests strict with helper script', function() it('does not detect any errors', function() local success = executeBusted('--helper=spec/cl_helper_script.lua --pattern=strict_spec.lua$') assert.is_true(success) end) end) describe('Tests execute option', function() it('will run the specified statement', function() local success, errcnt, result = executeBusted('-e "print(\\\"hello world\\\")" --pattern=cl_success.lua$') assert.is_true(success) assert.is_equal(0, errcnt) assert.is_equal('hello world', result:match('(.-)\n')) end) end) describe('Tests root specification', function() it('allows hidden directories in root path', function() local success, errcnt, result = executeBusted('spec/.hidden') assert.is_false(success) assert.is_equal(1, errcnt) assert.is_truthy(result:find('should not be executed')) end) end) busted-2.2.0/spec/cl_standalone.lua000066400000000000000000000012471452214637700172630ustar00rootroot00000000000000-- supporting testfile; belongs to 'cl_spec.lua' require 'busted.runner'() describe('Tests busted standalone with command-line options', function() it('is a test with a tag #tag1', function() -- works by counting failure error('error 1 on tag1') end) it('is a test with a tag #tag1', function() -- works by counting failure error('error 2 on tag1') end) it('is a test with a tag #tag2', function() -- works by counting failure error('error on tag2') end) it('is a test with a tag #tag3', function() -- nothing here, makes it succeed end) it('is a test with two tags #tag3 #tag4', function () -- Always succeed end) end) busted-2.2.0/spec/cl_success.lua000066400000000000000000000003021452214637700165720ustar00rootroot00000000000000-- supporting testfile; belongs to 'cl_spec.lua' describe('runs a single successful test', function() it('is a succesful test', function() -- nothing here, makes it succeed end) end) busted-2.2.0/spec/cl_tags.lua000066400000000000000000000021021452214637700160600ustar00rootroot00000000000000-- supporting testfile; belongs to 'cl_spec.lua' describe('Tests the busted command-line options', function() it('is a test with a tag #tag1', function() -- works by counting failure error('error 1 on tag1') end) spec('is a test with a tag #tag1', function() -- works by counting failure error('error 2 on tag1') end) test('is a test with a tag #tag2', function() -- works by counting failure error('error on tag2') end) it('is a test with a tag #tag3', function() -- nothing here, makes it succeed end) it('is a test with two tags #tag3 #tag4', function () -- Always succeed end) end) describe('Tests describe with a tag #dtag1', function() before_each(function() error('error in before_each on dtag1') end) after_each(function() error('error in after_each on dtag1') end) it('is a test inside describe', function() end) it('is another test inside describe', function() end) end) context('Tests context with a tag #dtag2', function() setup(function() error('error in setup on dtag2') end) end) busted-2.2.0/spec/cl_test_module.lua000066400000000000000000000000251452214637700174500ustar00rootroot00000000000000return 'test module' busted-2.2.0/spec/cl_two_failures.lua000066400000000000000000000004261452214637700176340ustar00rootroot00000000000000-- supporting testfile; belongs to 'cl_spec.lua' describe('Runs 2 failing tests', function() it('is failing test 1 #err1', function() assert(false, 'failed on test 1') end) it('is failing test 2 #err2', function() assert(false, 'failed on test 2') end) end) busted-2.2.0/spec/core_spec.lua000066400000000000000000000341731452214637700164230ustar00rootroot00000000000000--ensure environment is set up assert(type(file) == 'nil') --luacheck: ignore assert(type(describe) == 'function') assert(type(context) == 'function') assert(type(it) == 'function') assert(type(spec) == 'function') assert(type(test) == 'function') assert(type(before_each) == 'function') assert(type(after_each) == 'function') assert(type(spy) == 'table') assert(type(stub) == 'table') assert(type(mock) == 'table') assert(type(match) == 'table') assert(type(assert) == 'table') describe('Before each', function() local test_val = false before_each(function() test_val = true end) it('is called', function() assert(test_val) end) end) describe('After each', function() local test_val = false after_each(function() test_val = true end) it('runs once to fire an after_each and then', function() end) it('checks if after_each was called', function() assert(test_val) end) end) describe('Both before and after each', function() local test_val = 0 before_each(function() test_val = test_val + 1 end) after_each(function() test_val = test_val + 1 end) it('checks if both were called', function() end) it('runs again just to be sure', function() end) it('checks the value', function() assert(test_val == 5) end) end) describe('Before_each on describe blocks', function() local test_val = 0 before_each(function() test_val = test_val + 1 end) describe('A block', function() it('derps', function() assert(test_val == 1) end) it('herps', function() assert(test_val == 2) end) end) end) describe('Before_each on describe blocks, part II', function() local test_val = 0 before_each(function() test_val = test_val + 1 end) it('checks the value', function() assert.are.equal(1, test_val) end) describe('A block', function() before_each(function() test_val = test_val + 1 end) it('derps', function() end) --add two: two before-eaches it('herps', function() end) it('checks the value', function() assert.equal(7, test_val) end) end) end) describe('A failing test', function() it('explodes', function() assert.has.error(function() assert(false, 'this should fail') end) end) end) describe('tagged tests #test', function() it('runs', function() assert(true) end) end) describe('Testing test order', function() local testorder, level = '', 0 local function report_level(desc) testorder = testorder .. string.rep(' ', level * 2) .. desc .. '\n' end describe('describe, level A', function() setup(function() report_level('setup A') level = level + 1 end) teardown(function() level = level - 1 report_level('teardown A') end) before_each(function() report_level('before_each A') level = level + 1 end) after_each(function() level = level - 1 report_level('after_each A') end) it('tests A one', function() report_level('test A one') end) it('tests A two', function() report_level('test A two') end) describe('describe level B', function() setup(function() report_level('setup B') level = level + 1 end) teardown(function() level = level - 1 report_level('teardown B') end) before_each(function() report_level('before_each B') level = level + 1 end) after_each(function() level = level - 1 report_level('after_each B') end) it('tests B one', function() report_level('test B one') end) it('tests B two', function() report_level('test B two') end) end) it('tests A three', function() report_level('test A three') end) end) describe('Test testorder', function() it('verifies order of execution', function() local expected = [[setup A before_each A test A one after_each A before_each A test A two after_each A setup B before_each A before_each B test B one after_each B after_each A before_each A before_each B test B two after_each B after_each A teardown B before_each A test A three after_each A teardown A ]] assert.is.equal(expected, testorder) end) end) end) describe('finally callback is called in case of success', function() local f = spy.new(function() end) it('write variable in finally', function() finally(f) assert.is_true(true) end) it('ensures finally was called', function() assert.spy(f).was_called(1) end) end) describe('tests environment', function() global = 'global' --luacheck: ignore setup(function() globalsetup = 'globalsetup' --luacheck: ignore end) teardown(function() globalteardown = 'globalteardown' --luacheck: ignore end) before_each(function() globalbefore = 'globalbefore' --luacheck: ignore end) after_each(function() globalafter = 'globalafter' --luacheck: ignore end) it('cannot access globals which have not been created yet', function() assert.equal(nil, globalafter) --luacheck: ignore assert.equal(nil, globalteardown) --luacheck: ignore notglobal = 'notglobal' --luacheck: ignore end) it('can access globals', function() assert.equal('global', global) --luacheck: ignore assert.equal('globalsetup', globalsetup) --luacheck: ignore assert.equal('globalbefore', globalbefore) --luacheck: ignore assert.equal('globalafter', globalafter) --luacheck: ignore notglobal = 'notglobal' --luacheck: ignore end) it('cannot access globals set in siblings', function() assert.equal(nil, notglobal) --luacheck: ignore end) describe('can access parent globals', function() it('from child', function() assert.equal('global', global) --luacheck: ignore assert.equal('globalsetup', globalsetup) --luacheck: ignore assert.equal('globalbefore', globalbefore) --luacheck: ignore assert.equal('globalafter', globalafter) --luacheck: ignore end) end) describe('cannot access globals set in children', function() it('has a global', function() notglobal = 'notglobal' --luacheck: ignore end) assert.are.equal(notglobal, nil) --luacheck: ignore end) end) describe('tests clean environment', function() it('globals in previous describe are not available', function() assert.is_nil(global) --luacheck: ignore assert.is_nil(globalsetup) --luacheck: ignore assert.is_nil(globalbefore) --luacheck: ignore assert.is_nil(globalafter) --luacheck: ignore assert.is_nil(globalteardown) --luacheck: ignore end) end) describe 'tests syntactic sugar' (function() it 'works' (function() assert(true) end) end) describe('tests aliases', function() local test_val = 0 context('runs context alias', function() setup(function() test_val = test_val + 1 end) before_each(function() test_val = test_val + 1 end) after_each(function() test_val = test_val + 1 end) teardown(function() test_val = test_val + 1 end) spec('runs spec alias', function() test_val = test_val + 1 end) test('runs test alias', function() test_val = test_val + 1 end) end) it('checks aliases were executed', function() assert.is_equal(8, test_val) end) end) describe('tests unsupported functions', function() it('it block does not have file executor', function() assert.is_nil(file) --luacheck: ignore end) it('it block throws error on describe/context', function() assert.has_error(describe, "'describe' not supported inside current context block") assert.has_error(context, "'context' not supported inside current context block") end) it('it block throws error on insulate/expose', function() assert.has_error(insulate, "'insulate' not supported inside current context block") assert.has_error(expose, "'expose' not supported inside current context block") end) it('it block throws error on it/spec/test', function() assert.has_error(it, "'it' not supported inside current context block") assert.has_error(spec, "'spec' not supported inside current context block") assert.has_error(test, "'test' not supported inside current context block") end) it('it block throws error on setup/before_each/after_each/teardown', function() assert.has_error(setup, "'setup' not supported inside current context block") assert.has_error(before_each, "'before_each' not supported inside current context block") assert.has_error(after_each, "'after_each' not supported inside current context block") assert.has_error(teardown, "'teardown' not supported inside current context block") end) it('it block throws error on lazy/strict setup/teardown', function() assert.has_error(lazy_setup, "'lazy_setup' not supported inside current context block") assert.has_error(lazy_teardown, "'lazy_teardown' not supported inside current context block") assert.has_error(strict_setup, "'strict_setup' not supported inside current context block") assert.has_error(strict_teardown, "'strict_teardown' not supported inside current context block") end) it('it block throws error on randomize', function() assert.has_error(randomize, "'randomize' not supported inside current context block") end) it('finaly block throws error on pending', function() finally(function() assert.has_error(pending, "'pending' not supported inside current context block") end) end) end) describe('tests unsupported functions in setup/before_each/after_each/teardown', function() local function testUnsupported() assert.is_nil(file) --luacheck: ignore assert.is_nil(finally) assert.has_error(randomize, "'randomize' not supported inside current context block") assert.has_error(describe, "'describe' not supported inside current context block") assert.has_error(context, "'context' not supported inside current context block") assert.has_error(insulate, "'insulate' not supported inside current context block") assert.has_error(expose, "'expose' not supported inside current context block") assert.has_error(pending, "'pending' not supported inside current context block") assert.has_error(it, "'it' not supported inside current context block") assert.has_error(spec, "'spec' not supported inside current context block") assert.has_error(test, "'test' not supported inside current context block") assert.has_error(setup, "'setup' not supported inside current context block") assert.has_error(before_each, "'before_each' not supported inside current context block") assert.has_error(after_each, "'after_each' not supported inside current context block") assert.has_error(teardown, "'teardown' not supported inside current context block") assert.has_error(lazy_setup, "'lazy_setup' not supported inside current context block") assert.has_error(lazy_teardown, "'lazy_teardown' not supported inside current context block") assert.has_error(strict_setup, "'strict_setup' not supported inside current context block") assert.has_error(strict_teardown, "'strict_teardown' not supported inside current context block") end setup(testUnsupported) teardown(testUnsupported) before_each(testUnsupported) after_each(testUnsupported) it('tests nothing, all tests performed by support functions', function() end) end) describe('tests strict setup/teardown', function() local setup_count = 0 local teardown_count = 0 describe('in describe with no tests', function() strict_setup(function() setup_count = setup_count + 1 end) strict_teardown(function() teardown_count = teardown_count + 1 end) end) it('executes setup/teardown in previous block with no tests', function() assert.is_equal(1, setup_count) assert.is_equal(1, teardown_count) end) end) describe('tests lazy setup/teardown not run if no tests found in block', function() lazy_setup(function() assert(false, 'setup should not execute since no tests') end) lazy_teardown(function() assert(false, 'teardown should not execute since no tests') end) end) describe('tests lazy setup/teardown in describe with no tests', function() local setup_count = 0 local teardown_count = 0 describe('with nested describe with no tests', function() lazy_setup(function() setup_count = setup_count + 1 end) lazy_teardown(function() teardown_count = teardown_count + 1 end) describe('with inner nested describe with no tests', function() lazy_setup(function() setup_count = setup_count + 1 end) lazy_teardown(function() teardown_count = teardown_count + 1 end) end) end) it('does not run setup/teardown', function() assert.is_equal(0, setup_count) assert.is_equal(0, teardown_count) end) end) describe('tests lazy setup/teardown with nested tests', function() local setup_count = 0 local teardown_count = 0 lazy_setup(function() setup_count = setup_count + 1 end) lazy_teardown(function() teardown_count = teardown_count + 1 end) describe('nested describe with tests', function() lazy_setup(function() setup_count = setup_count + 1 end) lazy_teardown(function() teardown_count = teardown_count + 1 end) it('runs all setups', function() assert.is_equal(2, setup_count) end) it('runs setups only once', function() assert.is_equal(2, setup_count) end) it('runs teardown after all tests complete', function() assert.is_equal(0, teardown_count) end) end) describe('second nested describe', function() lazy_teardown(function() teardown_count = teardown_count + 1 end) it('verify teardown ran after previous describe completes', function() assert.is_equal(1, teardown_count) end) end) describe('another nested describe with tests', function() lazy_setup(function() setup_count = setup_count + 1 end) it('runs setup for new describe', function() assert.is_equal(3, setup_count) end) it('verify teardown ran after previous describe completes', function() assert.is_equal(2, teardown_count) end) end) end) busted-2.2.0/spec/execution_order_sync_spec.lua000066400000000000000000000022021452214637700217110ustar00rootroot00000000000000local egg = '' describe('before_each after_each egg test', function() setup(function() egg = egg..'S' end) teardown(function() egg = egg..'T' end) before_each(function() egg = egg..'b' end) after_each(function() egg = egg..'a' end) describe('asd', function() before_each(function() egg = egg..'B' end) after_each(function() egg = egg..'A' end) it('1', function() assert.equal(egg,'SbB') egg = egg..'1' end) it('2', function() assert.equal(egg,'SbB1AabB') egg = egg..'2' end) describe('jkl', function() setup(function() egg = egg..'s' end) teardown(function() egg = egg..'t' end) before_each(function() egg = egg..'E' end) after_each(function() egg = egg..'F' end) it('3', function() assert.equal(egg,'SbB1AabB2AasbBE') egg = egg..'3' end) end) end) it('4', function() assert.equal(egg,'SbB1AabB2AasbBE3FAatb') egg = egg..'4' end) end) it('5', function() assert.equal(egg,'SbB1AabB2AasbBE3FAatb4aT') end) busted-2.2.0/spec/export_spec.lua000066400000000000000000000065301452214637700170100ustar00rootroot00000000000000 describe('tests require "busted"', function() local describe = describe local context = context local insulate = insulate local expose = expose local it = it local pending = pending local spec = spec local test = test local setup = setup local teardown = teardown local before_each = before_each local after_each = after_each local lazy_setup = lazy_setup local lazy_teardown = lazy_teardown local strict_setup = strict_setup local strict_teardown = strict_teardown it('does not export init', function() assert.is_nil(require 'busted'.init) end) it('does not export file executor', function() assert.is_nil(require 'busted'.file) end) it('exports describe/it/pending', function() assert.is_equal(describe, require 'busted'.describe) assert.is_equal(it, require 'busted'.it) assert.is_equal(pending, require 'busted'.pending) end) it('exports aliases', function() assert.is_equal(context, require 'busted'.context) assert.is_equal(insulate, require 'busted'.insulate) assert.is_equal(expose, require 'busted'.expose) assert.is_equal(spec, require 'busted'.spec) assert.is_equal(test, require 'busted'.test) end) it('exports support functions', function() assert.is_equal(setup, require 'busted'.setup) assert.is_equal(teardown, require 'busted'.teardown) assert.is_equal(lazy_setup, require 'busted'.lazy_setup) assert.is_equal(lazy_teardown, require 'busted'.lazy_teardown) assert.is_equal(strict_setup, require 'busted'.strict_setup) assert.is_equal(strict_teardown, require 'busted'.strict_teardown) assert.is_equal(before_each, require 'busted'.before_each) assert.is_equal(after_each, require 'busted'.after_each) end) it('exports assert, mocks, and matchers', function() assert.is_equal(assert, require 'busted'.assert) assert.is_equal(spy, require 'busted'.spy) assert.is_equal(mock, require 'busted'.mock) assert.is_equal(stub, require 'busted'.stub) assert.is_equal(match, require 'busted'.match) end) it('exports publish/subscribe', function() local foo local publish = require 'busted'.publish local subscribe = require 'busted'.subscribe local unsubscribe = require 'busted'.unsubscribe local sub = subscribe({'export_test'}, function(...) foo = {...} end) publish({'export_test'}, 'value1', 'value2' ) local unsub = unsubscribe(sub.id, {'export_test'}) publish({'export_test'}, 'new_value1', 'new_value2') assert.is_same({'value1', 'value2'}, foo) assert.is_equal(sub, unsub) end) it('exports other functions/variables', function() assert.is_function(require 'busted'.bindfenv) assert.is_function(require 'busted'.fail) assert.is_function(require 'busted'.gettime) assert.is_function(require 'busted'.monotime) assert.is_function(require 'busted'.sleep) assert.is_function(require 'busted'.parent) assert.is_function(require 'busted'.children) assert.is_string(require 'busted'.version) end) it('functions cannot be overwritten', function() local foo = function() assert(false) end assert.has_error(function() require 'busted'.it = foo end) assert.is_equal(it, require 'busted'.it) end) it('cannot add new fields', function() local bar = function() assert(false) end assert.has_error(function() require 'busted'.foo = bar end) end) end) busted-2.2.0/spec/expose_file1.lua000066400000000000000000000004501452214637700170330ustar00rootroot00000000000000expose('Tests expose from file root', function() pl = require 'pl' --luacheck: ignore _G.global_var = 'this global is in _G' it('loads global environment with "List"', function() assert.is_not_nil(pl) --luacheck: ignore assert.is_not_nil(List) --luacheck: ignore end) end) busted-2.2.0/spec/expose_file2.lua000066400000000000000000000007431452214637700170410ustar00rootroot00000000000000describe('Tests environment exposed from previous file', function() it('global environment still has "List"', function() assert.is_nil(_G.pl) assert.is_not_nil(pl) --luacheck: ignore assert.is_equal('this global is in _G', _G.global_var) assert.is_not_nil(List) --luacheck: ignore end) it('global environment still has "pl" packages loaded', function() assert.is_not_nil(package.loaded['pl']) assert.is_not_nil(package.loaded['pl.List']) end) end) busted-2.2.0/spec/file_context_support_spec.lua000066400000000000000000000007021452214637700217410ustar00rootroot00000000000000local egg = '' setup(function() egg = egg..'S' end) teardown(function() egg = egg..'T' assert.equal('Sb1ab2aT', egg) end) before_each(function() egg = egg..'b' end) after_each(function() egg = egg..'a' end) it('file context before_each after_each egg test 1', function() assert.equal('Sb', egg) egg = egg..'1' end) it('file context before_each after_each egg test 2', function() assert.equal('Sb1ab', egg) egg = egg..'2' end) busted-2.2.0/spec/file_randomize_spec.lua000066400000000000000000000003571452214637700204570ustar00rootroot00000000000000local unexpected = {} local order = {} randomize() for i = 1, 100 do table.insert(unexpected, i) it('does 100 its', function() table.insert(order, i) end) end teardown(function() assert.are_not.same(unexpected, order) end) busted-2.2.0/spec/fixtures_spec.lua000066400000000000000000000045751452214637700173470ustar00rootroot00000000000000local fixtures = require 'busted.fixtures' describe("fixtures:", function() describe("path()", function() it("returns the absolute fixture path", function() 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 = 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) busted-2.2.0/spec/insulate-expose_spec.lua000066400000000000000000000121761452214637700206170ustar00rootroot00000000000000assert.is_nil(package.loaded.pl) assert.is_nil(package.loaded['pl.file']) describe('Tests insulation', function() insulate('environment inside insulate', function() pl = require 'pl' _G.insuated_global = true it('updates insuated global table _G', function() assert.is_not_nil(insuated_global) assert.is_not_nil(_G.insuated_global) end) it('updates package.loaded', function() assert.is_not_nil(pl) assert.is_not_nil(Date) assert.is_not_nil(package.loaded.pl) assert.is_not_nil(package.loaded['pl.Date']) end) end) describe('environment after insulate', function() it('restores insuated global table _G', function() assert.is_nil(insuated_global) assert.is_nil(_G.insuated_global) end) it('restores package.loaded', function() assert.is_nil(pl) assert.is_nil(Date) assert.is_nil(package.loaded.pl) assert.is_nil(package.loaded['pl.Date']) end) 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() expose('tests environment inside expose block', function() pl = require 'pl' exposed_global = true _G.global = true it('creates exposed global', function() assert.is_not_nil(exposed_global) assert.is_nil(_G.exposed_global) end) it('updates global table _G', function() assert.is_not_nil(global) assert.is_not_nil(_G.global) end) it('updates package.loaded', function() assert.is_not_nil(pl) assert.is_not_nil(Date) assert.is_not_nil(package.loaded.pl) assert.is_not_nil(package.loaded['pl.Date']) end) end) end) describe('neutralizes insulation', function() it('creates exposed global in outer block', function() assert.is_not_nil(exposed_global) assert.is_nil(_G.exposed_global) end) it('does not restore global table _G', function() assert.is_not_nil(global) assert.is_not_nil(_G.global) end) it('does not restore package.loaded', function() assert.is_not_nil(pl) assert.is_not_nil(Date) assert.is_not_nil(package.loaded.pl) assert.is_not_nil(package.loaded['pl.Date']) end) end) end) it('Tests exposed globals does not exist in outer most block', function() assert.is_nil(pl) assert.is_nil(exposed_global) assert.is_nil(_G.exposed_global) end) it('Tests global table _G persists without insulate', function() assert.is_not_nil(global) assert.is_not_nil(_G.global) end) it('Tests package.loaded persists without insulate', function() assert.is_not_nil(Date) assert.is_not_nil(package.loaded.pl) assert.is_not_nil(package.loaded['pl.Date']) end) end) describe('Tests after insulating an expose block', function() it('restores global table _G', function() assert.is_nil(global) assert.is_nil(_G.global) end) it('restores package.loaded', function() assert.is_nil(pl) assert.is_nil(Date) assert.is_nil(package.loaded.pl) assert.is_nil(package.loaded['pl.Date']) end) end) describe('Tests insulate/expose', function() local path = require 'pl.path' local utils = require 'pl.utils' local busted_cmd = path.is_windows and 'lua bin/busted' or 'bin/busted' local executeBusted = function(args) local success, exitcode, out, err = utils.executeex(busted_cmd .. ' ' .. args) if exitcode > 255 then exitcode = math.floor(exitcode/256), exitcode - math.floor(exitcode/256)*256 end return not not success, exitcode, out, err end describe('file insulation', function() it('works between files', function() local success, exitcode = executeBusted('spec/insulate_file1.lua spec/insulate_file2.lua') assert.is_true(success) assert.is_equal(0, exitcode) end) it('works between files independent of order', function() local success, exitcode = executeBusted('spec/insulate_file2.lua spec/insulate_file1.lua') assert.is_true(success) assert.is_equal(0, exitcode) end) end) describe('expose from file context', function() it('works between files', function() local success, exitcode = executeBusted('spec/expose_file1.lua spec/expose_file2.lua') assert.is_true(success) assert.is_equal(0, exitcode) end) end) end) busted-2.2.0/spec/insulate_file1.lua000066400000000000000000000006651452214637700173640ustar00rootroot00000000000000require 'pl' describe('Tests require "pl" in this file', function() it('loads global environment with "List"', function() assert.is_not_nil(List) --luacheck: ignore end) end) describe('Tests require "cl_test_module" in another file', function() it('does not keep test_module in environment', function() assert.is_nil(test_module) --luacheck: ignore assert.is_nil(package.loaded['spec.cl_test_module']) end) end) busted-2.2.0/spec/insulate_file2.lua000066400000000000000000000010321452214637700173520ustar00rootroot00000000000000test_module = require 'spec.cl_test_module' --luacheck: ignore describe('Tests require "cl_test_module" in this file', function() it('loads environment with "cl_test_module"', function() assert.is_not_nil(test_module) --luacheck: ignore assert.is_not_nil(package.loaded['spec.cl_test_module']) end) end) describe('Tests require "pl" in another file', function() it('does not keep "List" in environment', function() assert.is_nil(List) --luacheck: ignore assert.is_nil(package.loaded['pl.List']) end) end) busted-2.2.0/spec/lua.bat000066400000000000000000000000411452214637700152120ustar00rootroot00000000000000@echo off lua "%~dp0\lua.lua" %* busted-2.2.0/spec/lua.lua000077500000000000000000000001521452214637700152330ustar00rootroot00000000000000#!/usr/bin/env lua local exit = require 'busted.compatibility'.exit print(table.concat(arg, ' ')) exit(0) busted-2.2.0/spec/luajit_spec.lua000066400000000000000000000017061452214637700167570ustar00rootroot00000000000000local isJit = (tostring(getmetatable):match('builtin') ~= nil) local it = it if not isJit then it = pending end describe("LuaJIT FFI patching:", function() local _, ffi = pcall(require, "ffi") it("ffi.cdef", function() local def =[[ typedef struct foo { int a, b; } foo_t; // Declare a struct and typedef. int dofoo(foo_t *f, int n); /* Declare an external C function. */ ]] ffi.cdef(def) assert.has.no.error(function() ffi.cdef(def) end) end) it("ffi.typeof", function() local ct = "struct { int top, max; }" ffi.typeof(ct) assert.has.no.error(function() ffi.typeof(ct) end) end) it("ffi.metatype", function() local name = "brinevector" local mt = {} ffi.cdef([[ typedef struct { double x; double y; } ]] .. name .. [[; ]]) ffi.metatype(name, mt) assert.has.no.error(function() ffi.metatype(name, mt) end) end) end)busted-2.2.0/spec/modules/000077500000000000000000000000001452214637700154165ustar00rootroot00000000000000busted-2.2.0/spec/modules/cli_spec.lua000066400000000000000000000514331452214637700177100ustar00rootroot00000000000000local path = require 'pl.path' local normpath = path.normpath local defaultOutput = 'default_output_handler' describe('Tests command-line interface', function() it('default options', function() local lpath = './src/?.lua;./src/?/?.lua;./src/?/init.lua' local cpath = path.is_windows and './csrc/?.dll;./csrc/?/?.dll;' or './csrc/?.so;./csrc/?/?.so;' local cli = require 'busted.modules.cli'({ standalone = false, output = defaultOutput }) local args = cli:parse({}) assert.is_equal(defaultOutput, args.o) assert.is_equal(defaultOutput, args.output) assert.is_same({'spec'}, args.ROOT) assert.is_equal('./', args.C) assert.is_equal('./', args.directory) assert.is_equal('/dev/urandom or os.time()', args.seed) assert.is_equal('en', args.lang) assert.is_equal(1, args['repeat']) assert.is_equal(lpath, args.m) assert.is_equal(lpath, args.lpath) assert.is_equal(cpath, args.cpath) assert.is_true(args['auto-insulate']) assert.is_true(args.k) assert.is_true(args['keep-going']) assert.is_true(args.R) assert.is_true(args['recursive']) assert.is_false(args.c) assert.is_false(args.coverage) assert.is_false(args.version) assert.is_false(args.v) assert.is_false(args.verbose) assert.is_false(args.l) assert.is_false(args.list) assert.is_false(args.lazy) assert.is_false(args.s) assert.is_false(args['enable-sound']) assert.is_false(args['suppress-pending']) 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']) assert.is_nil(args.sort) assert.is_nil(args['sort-files']) assert.is_nil(args['sort-tests']) assert.is_nil(args.r) assert.is_nil(args.run) assert.is_nil(args.helper) assert.is_same({}, args.e) assert.is_same({'_spec'}, args.p) assert.is_same({'_spec'}, args.pattern) assert.is_same({}, args['exclude-pattern']) assert.is_same({}, args.t) assert.is_same({}, args.tags) assert.is_same({}, args['exclude-tags']) assert.is_same({}, args.filter) assert.is_same({}, args['filter-out']) assert.is_same({}, args.Xoutput) assert.is_same({}, args.Xhelper) assert.is_same({'lua', 'moonscript'}, args.loaders) end) it('standalone options disables ROOT and --pattern', function() local cli = require 'busted.modules.cli'({ standalone = true }) local args = cli:parse({}) assert.is_nil(args.ROOT) assert.is_same({}, args.p) assert.is_same({}, args.pattern) assert.is_same({}, args['exclude-pattern']) end) it('specify flags', function() local cli = require 'busted.modules.cli'() local args = cli:parse({ '-v', '--version', '--coverage', '--defer-print', '--suppress-pending' }) assert.is_true(args.v) assert.is_true(args.verbose) assert.is_true(args.version) assert.is_true(args.coverage) assert.is_true(args['defer-print']) assert.is_true(args['suppress-pending']) end) it('specify more flags', function() local cli = require 'busted.modules.cli'() local args = cli:parse({ '-s', '--list', '-k', '--no-keep-going', '-R', '--no-recursive' }) assert.is_true(args.s) assert.is_true(args['enable-sound']) assert.is_true(args.l) assert.is_true(args.list) assert.is_false(args['keep-going']) assert.is_false(args['recursive']) end) it('specify even more flags', function() local cli = require 'busted.modules.cli'() local args = cli:parse({ '--lazy', '--no-auto-insulate', '-k', '-R' }) assert.is_true(args.lazy) assert.is_false(args['auto-insulate']) assert.is_true(args.k) assert.is_true(args['keep-going']) assert.is_true(args.R) assert.is_true(args.recursive) end) it('specify no-flags', function() local cli = require 'busted.modules.cli'() local args = cli:parse({ '--no-lazy', '--no-auto-insulate', '--no-coverage', '--no-verbose' }) assert.is_false(args.lazy) assert.is_false(args['auto-insulate']) assert.is_false(args.coverage) assert.is_false(args.verbose) end) it('specify more no-flags', function() local cli = require 'busted.modules.cli'() local args = cli:parse({ '--no-enable-sound', '--no-suppress-pending', '--no-defer-print' }) assert.is_false(args['enable-sound']) assert.is_false(args['suppress-pending']) assert.is_false(args['defer-print']) end) it('specify shuffle flags', function() local cli = require 'busted.modules.cli'() local args = cli:parse({ '--shuffle-files', '--shuffle-tests' }) assert.is_nil(args.shuffle) assert.is_true(args['shuffle-files']) assert.is_true(args['shuffle-tests']) end) it('specify shuffle flag only', function() local cli = require 'busted.modules.cli'() local args = cli:parse({ '--shuffle', }) assert.is_true(args.shuffle) assert.is_true(args['shuffle-files']) assert.is_true(args['shuffle-tests']) end) it('specify shuffle no-flags', function() local cli = require 'busted.modules.cli'() local args = cli:parse({ '--no-shuffle', '--no-shuffle-files', '--no-shuffle-tests' }) assert.is_false(args.shuffle) assert.is_false(args['shuffle-files']) assert.is_false(args['shuffle-tests']) end) it('specify no-shuffle flag only', function() local cli = require 'busted.modules.cli'() local args = cli:parse({ '--no-shuffle', }) assert.is_false(args.shuffle) assert.is_false(args['shuffle-files']) assert.is_false(args['shuffle-tests']) end) it('specify shuffle and no-shuffle flags', function() local cli = require 'busted.modules.cli'() local args = cli:parse({ '--shuffle', '--no-shuffle-files' }) assert.is_true(args.shuffle) assert.is_false(args['shuffle-files']) assert.is_true(args['shuffle-tests']) end) it('specify sort flags', function() local cli = require 'busted.modules.cli'() local args = cli:parse({ '--sort-files', '--sort-tests' }) assert.is_nil(args.sort) assert.is_true(args['sort-files']) assert.is_true(args['sort-tests']) end) it('specify sort flag only', function() local cli = require 'busted.modules.cli'() local args = cli:parse({ '--sort', }) assert.is_true(args.sort) assert.is_true(args['sort-files']) assert.is_true(args['sort-tests']) end) it('specify sort no-flags', function() local cli = require 'busted.modules.cli'() local args = cli:parse({ '--no-sort', '--no-sort-files', '--no-sort-tests' }) assert.is_false(args.sort) assert.is_false(args['sort-files']) assert.is_false(args['sort-tests']) end) it('specify no-sort flag only', function() local cli = require 'busted.modules.cli'() local args = cli:parse({ '--no-sort', }) assert.is_false(args.sort) assert.is_false(args['sort-files']) assert.is_false(args['sort-tests']) end) it('specify sort and no-sort flags', function() local cli = require 'busted.modules.cli'() local args = cli:parse({ '--sort', '--no-sort-files' }) assert.is_true(args.sort) assert.is_false(args['sort-files']) assert.is_true(args['sort-tests']) end) it('specify ROOT arg and --pattern', function() local cli = require 'busted.modules.cli'({ standalone = false }) local args = cli:parse({ '-p', 'match_files', 'root_is_here' }) assert.is_same({'root_is_here'}, args.ROOT) assert.is_same({'match_files'}, args.p) assert.is_same({'match_files'}, args.pattern) end) it('specify ROOT arg and --exclude-pattern', function() local cli = require 'busted.modules.cli'({ standalone = false }) local args = cli:parse({ '--exclude-pattern', 'exclude_files', 'root_is_here' }) assert.is_same({'root_is_here'}, args.ROOT) assert.is_same({'exclude_files'}, args['exclude-pattern']) end) it('specify multiple root paths', function() local cli = require 'busted.modules.cli'({ standalone = false }) local args = cli:parse({'root1_path', 'root2_path', 'root3_path'}) assert.is_same({'root1_path', 'root2_path', 'root3_path'}, args.ROOT) end) it('specify --directory', function() local cli = require 'busted.modules.cli'() local args = cli:parse({ '--directory=/path/to/dir' }) assert.is_equal(normpath('/path/to/dir'), args.C) assert.is_equal(normpath('/path/to/dir'), args.directory) end) it('specify --directory multiple times', function() local cli = require 'busted.modules.cli'() local args = cli:parse({ '--directory=/path/to', '-C', 'dir', '--directory=subdir' }) assert.is_equal(normpath('/path/to/dir/subdir'), args.C) assert.is_equal(normpath('/path/to/dir/subdir'), args.directory) end) it('specify --directory multiple times with multiple roots', function() local cli = require 'busted.modules.cli'() local args = cli:parse({ '--directory=/path/to', '-C', 'dir', '--directory=/new/path' }) assert.is_equal(normpath('/new/path'), args.C) assert.is_equal(normpath('/new/path'), args.directory) end) it('specify --run', function() local cli = require 'busted.modules.cli'() local args = cli:parse({ '--run=task' }) assert.is_equal('task', args.r) assert.is_equal('task', args.run) end) it('specify --lang', function() local cli = require 'busted.modules.cli'() local args = cli:parse({ '--lang=fr' }) assert.is_equal('fr', args.lang) end) it('specify --repeat', function() local cli = require 'busted.modules.cli'() local args = cli:parse({ '--repeat=23' }) assert.is_equal(23, args['repeat']) end) it('specify output library', function() local cli = require 'busted.modules.cli'() local args = cli:parse({ '-o', 'output_handler', '-Xoutput', '--flag,-f', '-Xoutput', '--opt=val' }) assert.is_equal('output_handler', args.o) assert.is_equal('output_handler', args.output) assert.is_same({'--flag', '-f', '--opt=val'}, args.Xoutput) end) it('specify helper script', function() local cli = require 'busted.modules.cli'() local args = cli:parse({ '--helper=helper_script', '-Xhelper', '--flag,-f', '-Xhelper', '--opt=val' }) assert.is_equal('helper_script', args.helper) assert.is_same({'--flag', '-f', '--opt=val'}, args.Xhelper) end) it('specify --tags and --exclude-tags', function() local cli = require 'busted.modules.cli'() local args = cli:parse({ '--tags=tag1,tag2', '-t', 'tag3', '--exclude-tags=etag1', '--exclude-tags=etag2,etag3' }) assert.is_same({'tag1', 'tag2', 'tag3'}, args.t) assert.is_same({'tag1', 'tag2', 'tag3'}, args.tags) assert.is_same({'etag1', 'etag2', 'etag3'}, args['exclude-tags']) end) it('specify --filter and --filter-out', function() local cli = require 'busted.modules.cli'() local args = cli:parse({ '--filter=_filt', '--filter-out=_filterout' }) assert.is_same({'_filt'}, args.filter) assert.is_same({'_filterout'}, args['filter-out']) end) it('specify --filter and --filter-out multiple times', function() local cli = require 'busted.modules.cli'() local args = cli:parse({ '--filter=_filt1', '--filter=_filt2', '--filter-out=_filterout1', '--filter-out=_filterout2' }) assert.is_same({'_filt1', '_filt2'}, args.filter) assert.is_same({'_filterout1', '_filterout2'}, args['filter-out']) end) it('specify --loaders', function() local cli = require 'busted.modules.cli'() local args = cli:parse({ '--loaders=load1,load2', '--loaders=load3' }) assert.is_same({'load1', 'load2', 'load3'}, args.loaders) end) it('specify --lpath', function() local cli = require 'busted.modules.cli'() local args = cli:parse({ '-C', '/root', '--lpath=./path1/?.lua', '-m', './path2/?.lua' }) assert.is_equal('./path1/?.lua;./path2/?.lua', args.m) assert.is_equal('./path1/?.lua;./path2/?.lua', args.lpath) end) it('specify --cpath', function() local cli = require 'busted.modules.cli'() local args = cli:parse({ '-C', '/croot', '--lpath=./path1/?.so', '-m', './path2/?.so' }) assert.is_equal('./path1/?.so;./path2/?.so', args.m) assert.is_equal('./path1/?.so;./path2/?.so', args.lpath) end) it('specify -e statement', function() local cli = require 'busted.modules.cli'() local args = cli:parse({ '-e', 'statement1', '-e', 'statement2' }) assert.is_same({'statement1', 'statement2'}, args.e) end) end) describe('Tests using .busted tasks', function() it('default options', function() local defaultOutput = 'default_output_handler' local lpath = './src/?.lua;./src/?/?.lua;./src/?/init.lua' local cpath = path.is_windows and './csrc/?.dll;./csrc/?/?.dll;' or './csrc/?.so;./csrc/?/?.so;' local cli = require 'busted.modules.cli'({ standalone = false, output = defaultOutput }) local args = cli:parse({ '--directory=spec/.hidden' }) assert.is_equal(defaultOutput, args.o) assert.is_equal(defaultOutput, args.output) assert.is_same({'specs'}, args.ROOT) assert.is_equal(normpath('spec/.hidden'), args.C) assert.is_equal(normpath('spec/.hidden'), args.directory) assert.is_equal('/dev/urandom or os.time()', args.seed) assert.is_equal('en', args.lang) assert.is_equal(1, args['repeat']) assert.is_equal(lpath, args.m) assert.is_equal(lpath, args.lpath) assert.is_equal(cpath, args.cpath) assert.is_true(args['auto-insulate']) assert.is_true(args.k) assert.is_true(args['keep-going']) assert.is_true(args.R) assert.is_true(args['recursive']) assert.is_false(args.c) assert.is_false(args.coverage) assert.is_false(args.version) assert.is_false(args.v) assert.is_false(args.verbose) assert.is_false(args.l) assert.is_false(args.list) assert.is_false(args.lazy) assert.is_false(args.s) assert.is_false(args['enable-sound']) assert.is_false(args['suppress-pending']) 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']) assert.is_nil(args.sort) assert.is_nil(args['sort-files']) assert.is_nil(args['sort-tests']) assert.is_nil(args.r) assert.is_nil(args.run) assert.is_nil(args.helper) assert.is_same({}, args.e) assert.is_same({'_spec%.lua$'}, args.p) assert.is_same({'_spec%.lua$'}, args.pattern) assert.is_same({'_exclude'}, args['exclude-pattern']) assert.is_same({'tag11', 'tag22', 'tag33'}, args.t) assert.is_same({'tag11', 'tag22', 'tag33'}, args.tags) assert.is_same({'etag11', 'etag22', 'etag33'}, args['exclude-tags']) assert.is_same({'filt'}, args.filter) assert.is_same({'filt-out'}, args['filter-out']) assert.is_same({'-f', '--flag'}, args.Xoutput) assert.is_same({'-v', '--verbose'}, args.Xhelper) assert.is_same({'terra', 'moonscript'}, args.loaders) end) it('default options with --config-file option', function() local defaultOutput = 'default_output_handler' local lpath = './src/?.lua;./src/?/?.lua;./src/?/init.lua' local cpath = path.is_windows and './csrc/?.dll;./csrc/?/?.dll;' or './csrc/?.so;./csrc/?/?.so;' local cli = require 'busted.modules.cli'({ standalone = false, output = defaultOutput }) local args = cli:parse({ '--config-file', 'spec/.hidden/.busted' }) assert.is_equal(defaultOutput, args.o) assert.is_equal(defaultOutput, args.output) assert.is_same({'specs'}, args.ROOT) assert.is_equal('./', args.C) assert.is_equal('./', args.directory) assert.is_equal('spec/.hidden/.busted', args.f) assert.is_equal('spec/.hidden/.busted', args['config-file']) assert.is_equal('/dev/urandom or os.time()', args.seed) assert.is_equal('en', args.lang) assert.is_equal(1, args['repeat']) assert.is_equal(lpath, args.m) assert.is_equal(lpath, args.lpath) assert.is_equal(cpath, args.cpath) assert.is_true(args['auto-insulate']) assert.is_true(args.k) assert.is_true(args['keep-going']) assert.is_true(args.R) assert.is_true(args['recursive']) assert.is_false(args.c) assert.is_false(args.coverage) assert.is_false(args.version) assert.is_false(args.v) assert.is_false(args.verbose) assert.is_false(args.l) assert.is_false(args.list) assert.is_false(args.lazy) assert.is_false(args.s) 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']) assert.is_nil(args.sort) assert.is_nil(args['sort-files']) assert.is_nil(args['sort-tests']) assert.is_nil(args.r) assert.is_nil(args.run) assert.is_nil(args.helper) assert.is_same({'_spec%.lua$'}, args.p) assert.is_same({'_spec%.lua$'}, args.pattern) assert.is_same({'_exclude'}, args['exclude-pattern']) assert.is_same({'tag11', 'tag22', 'tag33'}, args.t) assert.is_same({'tag11', 'tag22', 'tag33'}, args.tags) assert.is_same({'etag11', 'etag22', 'etag33'}, args['exclude-tags']) assert.is_same({'filt'}, args.filter) assert.is_same({'filt-out'}, args['filter-out']) assert.is_same({'-f', '--flag'}, args.Xoutput) assert.is_same({'-v', '--verbose'}, args.Xhelper) assert.is_same({'terra', 'moonscript'}, args.loaders) end) it('load configuration options', function() local cli = require 'busted.modules.cli'({ standalone = false, output = defaultOutput }) local args = cli:parse({ '--directory=spec/.hidden', '--run=test' }) assert.is_same({'_test1%.lua$', '_test2%.lua$'}, args.pattern) assert.is_same({'_exclude1', '_exclude2'}, args['exclude-pattern']) assert.is_same({'filt1', 'filt2'}, args.filter) assert.is_same({'filt1-out', 'filt2-out'}, args['filter-out']) assert.is_same({'tests'}, args.ROOT) assert.is_same({'test1', 'test2', 'test3'}, args.tags) assert.is_same({'etest1', 'etest2', 'etest3'}, args['exclude-tags']) assert.is_same({'-s','--sound'}, args.Xoutput) assert.is_same({'-t', '--print'}, args.Xhelper) assert.is_same({'lua', 'terra'}, args.loaders) end) it('load configuration options and override with command-line', function() local cli = require 'busted.modules.cli'({ standalone = false, output = defaultOutput }) local args = cli:parse({ '--directory=spec/.hidden', '--run=test', '-t', 'tag1', '-p', 'patt', '--filter=fin', '--filter-out=fout', '--exclude-pattern', '', '--loaders=moonscript' }) assert.is_same({'patt'}, args.pattern) assert.is_same({''}, args['exclude-pattern']) assert.is_same({'fin'}, args.filter) assert.is_same({'fout'}, args['filter-out']) assert.is_same({'tag1'}, args.tags) assert.is_same({'etest1', 'etest2', 'etest3'}, args['exclude-tags']) assert.is_same({'-s','--sound'}, args.Xoutput) assert.is_same({'-t', '--print'}, args.Xhelper) assert.is_same({'moonscript'}, args.loaders) end) it('detects error in configuration file', function() local cli = require 'busted.modules.cli'({ standalone = false, output = defaultOutput }) cli:set_name('app') local args, err = cli:parse({ '--config-file=spec/.hidden/.busted_bad', '--run=test' }) assert.is_nil(args) assert.has_match('^app: error: spec/.hidden/.busted_bad:8: ', err) assert.has_match("'doesnotexist'", err) assert.has_match("a nil value", err) end) it('detects invalid configuration file', function() local cli = require 'busted.modules.cli'({ standalone = false, output = defaultOutput }) cli:set_name('myapp') local args, err = cli:parse({ '--config-file=spec/.hidden/.busted_empty' }) assert.is_nil(args) assert.is_equal('myapp: error: .busted file does not return a table.', err) end) it('detects unknown/invalid task', function() local cli = require 'busted.modules.cli'({ standalone = false, output = defaultOutput }) cli:set_name('appname') local args, err = cli:parse({ '--config-file=spec/.hidden/.busted', '--run=invalid' }) assert.is_nil(args) assert.is_equal('appname: error: Task `invalid` not found, or not a table.', err) end) end) describe('Tests command-line parse errors', function() before_each(function() package.loaded['cliargs'] = nil end) it('with invalid --repeat value', function() local cli = require 'busted.modules.cli'() cli:set_name('myapp') local args, err = cli:parse({ '--repeat=abc'}) assert.is_nil(args) assert.is_equal('myapp: error: argument to --repeat must be a number; re-run with --help for usage.', err) end) it('with same tag for --tags and --exclude-tags', function() local cli = require 'busted.modules.cli'() cli:set_name('myapp') local args, err = cli:parse({ '--tags=tag1', '--exclude-tags=tag1' }) assert.is_nil(args) assert.is_equal('myapp: error: Cannot use --tags and --exclude-tags for the same tags', err) end) end) busted-2.2.0/spec/modules/configuration_loader_spec.lua000066400000000000000000000051101452214637700233250ustar00rootroot00000000000000describe('Config Loader', function() local configLoader = require 'busted.modules.configuration_loader'() local testConfig, cliArgs, defaults before_each(function() testConfig = { _all = { other = 'stuff', }, default = { output = 'utfTerminal' }, windows = { output = 'plainTerminal' } } cliArgs = { } defaults = { } end) it('returns a valid config with no config file', function() local testConfig = { } local config, err = configLoader(testConfig, cliArgs) assert.are.same({}, config) assert.are.equal(nil, err) end) it('returns a valid config with default config', function() local config, err = configLoader(testConfig, cliArgs) assert.are.same(testConfig.default.output, config.output) assert.are.same(testConfig._all.other, config.other) assert.are.equal(nil, err) end) it('returns a valid config with specified config', function() cliArgs.run = 'windows' local config, err = configLoader(testConfig, cliArgs) assert.are.same(testConfig.windows.output, config.output) assert.are.same(testConfig._all.other, config.other) assert.are.equal(nil, err) end) it('returns a valid config with specified config and defaults specified', function() defaults = { output = 'TAP' } cliArgs.run = 'windows' local config, err = configLoader(testConfig, cliArgs, defaults) assert.are.same(testConfig.windows.output, config.output) assert.are.same(testConfig._all.other, config.other) assert.are.equal(nil, err) end) it('returns a valid config with cliArgs and defaults specified', function() cliArgs = { output = 'TAP' } local config, err = configLoader(testConfig, cliArgs, defaults) assert.are.same(cliArgs.output, config.output) assert.are.same(testConfig._all.other, config.other) assert.are.equal(nil, err) end) it('returns a valid config with defaults if no configs present', function() defaults = { output = 'TAP' } local config, err = configLoader({}, {}, defaults) assert.are.same(defaults, config) assert.are.equal(nil, err) end) it('returns an error with an invalid config', function() local config, err = configLoader('invalid', cliArgs) assert.is_nil(config) assert.are.equal('.busted file does not return a table.', err) end) it('returns an error with an invalid run', function() cliArgs.run = 'invalid' local config, err = configLoader(testConfig, cliArgs) assert.is_nil(config) assert.are.equal('Task `invalid` not found, or not a table.', err) end) end) busted-2.2.0/spec/modules/file_loader_spec.lua000066400000000000000000000000741452214637700214010ustar00rootroot00000000000000require 'busted.modules.test_file_loader'(busted, {'lua'}) busted-2.2.0/spec/modules/luacov_spec.lua000066400000000000000000000000431452214637700204210ustar00rootroot00000000000000require 'busted.modules.luacov'() busted-2.2.0/spec/modules/output_handler_loader_spec.lua000066400000000000000000000000621452214637700235140ustar00rootroot00000000000000require 'busted.modules.output_handler_loader'() busted-2.2.0/spec/moonscript_spec.moon000066400000000000000000000001541452214637700200470ustar00rootroot00000000000000describe 'moonscript tests', -> it 'works', -> assert.are.equal true, true return return return busted-2.2.0/spec/randomize_spec.lua000066400000000000000000000040471452214637700174600ustar00rootroot00000000000000local unexpected = {} local order = {} local orderfixed1 = {} local orderfixed2 = {} describe('Randomizing test order', function() randomize() for i = 1, 100 do table.insert(unexpected, i) it('does 100 its', function() table.insert(order, i) end) end end) describe('Randomizing test order with fixed seed as first arg', function() randomize(3210) for i = 1, 10 do it('does 10 its', function() table.insert(orderfixed1, i) end) end end) describe('Randomizing test order with fixed seed as second arg', function() randomize(true, 56789) for i = 1, 10 do it('does 10 its', function() table.insert(orderfixed2, i) end) end end) describe('Order of tests ran', function() local function shuffle(t, seed) math.randomseed(seed) local n = #t while n >= 1 do local k = math.random(n) t[n], t[k] = t[k], t[n] n = n - 1 end return t end it('randomized', function() assert.are_not.same(unexpected, order) end) it('randomized with known random seed: 3210', function() local t = {1,2,3,4,5,6,7,8,9,10} assert.are.same(shuffle(t, 3210), orderfixed1) end) it('randomized with known random seed: 56789', function() local t = {1,2,3,4,5,6,7,8,9,10} assert.are.same(shuffle(t, 56789), orderfixed2) end) end) describe('Disabling randomized test order with randomize(false)', function() randomize() randomize(false) local expected = {} local order = {} for i = 1, 100 do table.insert(expected, i) it('does 100 its', function() table.insert(order, i) end) end it('does not randomize tests', function() assert.are.same(expected, order) end) end) describe('Disabling randomized test order with randomize(nil)', function() randomize() randomize(nil) local expected = {} local order = {} for i = 1, 100 do table.insert(expected, i) it('does 100 its', function() table.insert(order, i) end) end it('does not randomize tests', function() assert.are.same(expected, order) end) end) busted-2.2.0/spec/strict.lua000066400000000000000000000017351452214637700157670ustar00rootroot00000000000000-- strict.lua -- checks uses of undeclared global variables -- All global variables must be 'declared' through a regular assignment -- (even assigning nil will do) in a main chunk before being used -- anywhere or assigned to inside a function. -- distributed under the Lua license: http://www.lua.org/license.html local getinfo, error, rawset, rawget = debug.getinfo, error, rawset, rawget local mt = getmetatable(_G) if mt == nil then mt = {} setmetatable(_G, mt) end mt.__declared = {} local function what () local d = getinfo(3, "S") return d and d.what or "C" end mt.__newindex = function (t, n, v) if not mt.__declared[n] then local w = what() if w ~= "main" and w ~= "C" then error("assign to undeclared variable '"..n.."'", 2) end mt.__declared[n] = true end rawset(t, n, v) end mt.__index = function (t, n) if not mt.__declared[n] and what() ~= "C" then error("variable '"..n.."' is not declared", 2) end return rawget(t, n) end busted-2.2.0/spec/strict_spec.lua000066400000000000000000000002771452214637700170010ustar00rootroot00000000000000require 'spec.strict' describe('runs a single successful test with strict', function() it('is a succesful test with strict', function() -- nothing here, makes it succeed end) end) busted-2.2.0/spec/test_runner/000077500000000000000000000000001452214637700163165ustar00rootroot00000000000000busted-2.2.0/spec/test_runner/interface_spec.lua000066400000000000000000000002061452214637700217710ustar00rootroot00000000000000describe('does a describe', function() for i = 1, 1000 do it('does 1000 its', function() assert(true) end) end end) busted-2.2.0/try000077500000000000000000000001551452214637700135610ustar00rootroot00000000000000#!/bin/sh luarocks remove busted --force luarocks make LUA_PATH="./?.lua;./?/init.lua;$LUA_PATH" busted "$@" busted-2.2.0/try.bat000066400000000000000000000001121452214637700143140ustar00rootroot00000000000000call luarocks remove busted --force call luarocks make cls call busted %*