diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 10:41:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 10:41:58 +0000 |
commit | 1852910ef0fd7393da62b88aee66ee092208748e (patch) | |
tree | ad3b659dbbe622b58a5bda4fe0b5e1d80eee9277 /tests/config/tapered | |
parent | Initial commit. (diff) | |
download | knot-resolver-upstream.tar.xz knot-resolver-upstream.zip |
Adding upstream version 5.3.1.upstream/5.3.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
49 files changed, 2156 insertions, 0 deletions
diff --git a/tests/config/tapered/.travis.yml b/tests/config/tapered/.travis.yml new file mode 100644 index 0000000..77135af --- /dev/null +++ b/tests/config/tapered/.travis.yml @@ -0,0 +1,40 @@ +language: c + +sudo: false + +env: + global: + - LUAROCKS=2.4.3 + matrix: + - LUA=lua5.1 + - LUA=lua5.2 + - LUA=lua5.3 + - LUA=luajit # latest stable version (2.0.4) + - LUA=luajit2.0 # current head of 2.0 branch + - LUA=luajit2.1 # current head of 2.1 branch + +branches: + only: + - bugfix + - master + +before_install: + - source .travis/setenv_lua.sh + - lua -v + - luarocks install luacov + +script: + - cd test + - git clone https://github.com/sstephenson/bats.git + - ./bats/bin/bats runner.bash + +after_success: + - luacov + - cp -v luacov.report.out ../ + - cd .. + - bash <(curl -s https://codecov.io/bash) + +notifications: + email: + on_success: change + on_failure: always diff --git a/tests/config/tapered/.travis/platform.sh b/tests/config/tapered/.travis/platform.sh new file mode 100644 index 0000000..7259a7d --- /dev/null +++ b/tests/config/tapered/.travis/platform.sh @@ -0,0 +1,15 @@ +if [ -z "${PLATFORM:-}" ]; then + PLATFORM=$TRAVIS_OS_NAME; +fi + +if [ "$PLATFORM" == "osx" ]; then + PLATFORM="macosx"; +fi + +if [ -z "$PLATFORM" ]; then + if [ "$(uname)" == "Linux" ]; then + PLATFORM="linux"; + else + PLATFORM="macosx"; + fi; +fi diff --git a/tests/config/tapered/.travis/setenv_lua.sh b/tests/config/tapered/.travis/setenv_lua.sh new file mode 100644 index 0000000..8d8c825 --- /dev/null +++ b/tests/config/tapered/.travis/setenv_lua.sh @@ -0,0 +1,3 @@ +export PATH=${PATH}:$HOME/.lua:$HOME/.local/bin:${TRAVIS_BUILD_DIR}/install/luarocks/bin +bash .travis/setup_lua.sh +eval `$HOME/.lua/luarocks path` diff --git a/tests/config/tapered/.travis/setup_lua.sh b/tests/config/tapered/.travis/setup_lua.sh new file mode 100644 index 0000000..a72b6d2 --- /dev/null +++ b/tests/config/tapered/.travis/setup_lua.sh @@ -0,0 +1,122 @@ +#! /bin/bash + +# A script for setting up environment for travis-ci testing. +# Sets up Lua and Luarocks. +# LUA must be "lua5.1", "lua5.2" or "luajit". +# luajit2.0 - master v2.0 +# luajit2.1 - master v2.1 + +set -eufo pipefail + +LUAJIT_VERSION="2.0.4" +LUAJIT_BASE="LuaJIT-$LUAJIT_VERSION" + +source .travis/platform.sh + +LUA_HOME_DIR=$TRAVIS_BUILD_DIR/install/lua + +LR_HOME_DIR=$TRAVIS_BUILD_DIR/install/luarocks + +mkdir $HOME/.lua + +LUAJIT="no" + +if [ "$PLATFORM" == "macosx" ]; then + if [ "$LUA" == "luajit" ]; then + LUAJIT="yes"; + fi + if [ "$LUA" == "luajit2.0" ]; then + LUAJIT="yes"; + fi + if [ "$LUA" == "luajit2.1" ]; then + LUAJIT="yes"; + fi; +elif [ "$(expr substr $LUA 1 6)" == "luajit" ]; then + LUAJIT="yes"; +fi + +mkdir -p "$LUA_HOME_DIR" + +if [ "$LUAJIT" == "yes" ]; then + + if [ "$LUA" == "luajit" ]; then + curl --location https://github.com/LuaJIT/LuaJIT/archive/v$LUAJIT_VERSION.tar.gz | tar xz; + else + git clone https://github.com/LuaJIT/LuaJIT.git $LUAJIT_BASE; + fi + + cd $LUAJIT_BASE + + if [ "$LUA" == "luajit2.1" ]; then + git checkout v2.1; + # force the INSTALL_TNAME to be luajit + perl -i -pe 's/INSTALL_TNAME=.+/INSTALL_TNAME= luajit/' Makefile + fi + + make && make install PREFIX="$LUA_HOME_DIR" + + ln -s $LUA_HOME_DIR/bin/luajit $HOME/.lua/luajit + ln -s $LUA_HOME_DIR/bin/luajit $HOME/.lua/lua; + +else + + if [ "$LUA" == "lua5.1" ]; then + curl http://www.lua.org/ftp/lua-5.1.5.tar.gz | tar xz + cd lua-5.1.5; + elif [ "$LUA" == "lua5.2" ]; then + curl http://www.lua.org/ftp/lua-5.2.4.tar.gz | tar xz + cd lua-5.2.4; + elif [ "$LUA" == "lua5.3" ]; then + curl http://www.lua.org/ftp/lua-5.3.4.tar.gz | tar xz + cd lua-5.3.4; + fi + + # Build Lua without backwards compatibility for testing + perl -i -pe 's/-DLUA_COMPAT_(ALL|5_2)//' src/Makefile + make $PLATFORM + make INSTALL_TOP="$LUA_HOME_DIR" install; + + ln -s $LUA_HOME_DIR/bin/lua $HOME/.lua/lua + ln -s $LUA_HOME_DIR/bin/luac $HOME/.lua/luac; + +fi + +cd $TRAVIS_BUILD_DIR + +lua -v + +LUAROCKS_BASE=luarocks-$LUAROCKS + +curl --location http://luarocks.org/releases/$LUAROCKS_BASE.tar.gz | tar xz + +cd $LUAROCKS_BASE + +if [ "$LUA" == "luajit" ]; then + ./configure --lua-suffix=jit --with-lua-include="$LUA_HOME_DIR/include/luajit-2.0" --prefix="$LR_HOME_DIR"; +elif [ "$LUA" == "luajit2.0" ]; then + ./configure --lua-suffix=jit --with-lua-include="$LUA_HOME_DIR/include/luajit-2.0" --prefix="$LR_HOME_DIR"; +elif [ "$LUA" == "luajit2.1" ]; then + ./configure --lua-suffix=jit --with-lua-include="$LUA_HOME_DIR/include/luajit-2.1" --prefix="$LR_HOME_DIR"; +else + ./configure --with-lua="$LUA_HOME_DIR" --prefix="$LR_HOME_DIR" +fi + +make build && make install + +ln -s $LR_HOME_DIR/bin/luarocks $HOME/.lua/luarocks + +cd $TRAVIS_BUILD_DIR + +luarocks --version + +rm -rf $LUAROCKS_BASE + +if [ "$LUAJIT" == "yes" ]; then + rm -rf $LUAJIT_BASE; +elif [ "$LUA" == "lua5.1" ]; then + rm -rf lua-5.1.5; +elif [ "$LUA" == "lua5.2" ]; then + rm -rf lua-5.2.4; +elif [ "$LUA" == "lua5.3" ]; then + rm -rf lua-5.3.4; +fi diff --git a/tests/config/tapered/CHANGES.md b/tests/config/tapered/CHANGES.md new file mode 100644 index 0000000..63b19b0 --- /dev/null +++ b/tests/config/tapered/CHANGES.md @@ -0,0 +1,70 @@ +# tapered version history + +## *1.0-0* (July 10, 2015) + ++ Initial public release + +## *1.0-1* (July 10, 2015) + ++ Fix rockspec: the URL for Bitbucket was wrong. + +## *1.1-0* (July 13, 2015) + ++ Improve organization and coverage of tests ++ Refactor the `same` method ++ Remove `same_mt` ++ Meaningful exit statuses via `done` ++ Add CI via [drone.io][dio] + +[dio]: https://drone.io/bitbucket.org/telemachus/tapered/latest + +## *1.2.0-1* (July 19, 2015) + ++ Clean up code using luacheck and luacov ++ Small tweaks to README and CHANGES ++ Fix version number: the previous two digit number was a mistake, based on + a misunderstanding of LuaRocks conventions. This is an annoying switch, but + better now than later. And better to do it than to live with a versioning + pattern I dislike. + +## *1.2.1-1* (December 5, 2015) + ++ Test coverage stats are now thanks to [codecov][codecov]. ++ Latest stable Lua in the 5.3 series is 5.3.2, so we test against that now. + +[codecov]: https://codecov.io + +## *2.0.0-1* (May 1, 2016) + ++ The informational fields are now functions that return strings. This is to prevent them from violating Lua recommendations about variables such as `_VERSION`. (I've bumped the major version number since this is technically an API change, though for most users it will not require any changes on their end.) + +## *2.0.1-1* (May 2, 2016) + ++ Fix a typo in the documentation. ++ Adjust the `version()` return value to show only software version, not the rockspec version as well. + +## *2.1.0-1* (July 21, 2016) + ++ Update to test against Lua 5.3.3 + +## *2.2.0-1* (February 11, 2017) + ++ Update to test against Lua 5.3.4 ++ The repo is now housed on [Github](https://github.com/telemachus/tapered) ++ CI is now provided by [Travis.ci](https://travis-ci.org/telemachus/tapered) + +## *2.3.0-1* (October 15, 2017) + ++ Remove `setup()` and `teardown()` ++ Update to use luarocks 2.4.3 for testing on Travis + +Would you rather view the [documentation][d]? + +[d]: /README.md + +--- + +(c) 2012-2017 Peter Aronoff. BSD 3-Clause license; see [LICENSE.md][l] for +details. + +[l]: /LICENSE.md diff --git a/tests/config/tapered/LICENSE.md b/tests/config/tapered/LICENSE.md new file mode 100644 index 0000000..bcaacde --- /dev/null +++ b/tests/config/tapered/LICENSE.md @@ -0,0 +1,27 @@ +Copyright (c) 2012-2017, Peter Aronoff All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/tests/config/tapered/README.md b/tests/config/tapered/README.md new file mode 100644 index 0000000..bafb2e7 --- /dev/null +++ b/tests/config/tapered/README.md @@ -0,0 +1,116 @@ +# tapered [![Build Status](https://travis-ci.org/telemachus/tapered.svg?branch=master)](https://travis-ci.org/telemachus/tapered) [![Coverage](https://codecov.io/gh/telemachus/tapered/branch/master/graph/badge.svg)](https://codecov.io/gh/telemachus/tapered) + +## Synopsis + +Very minimal tap testing for Lua. Arguably too minimal. + +## Assertions + +The `message` parameter is always optional. Brief messages help make test output +clearer to readers, but are not needed if the output goes straight to another +program for parsing. + ++ `ok(expression, [message])` Tests whether `expression` returns a truthy + value. + ++ `nok(expression, [message])` Tests whether `expression` returns a falsy + value. + ++ `is(actual, expected, [message])` Tests whether `actual` is equal to + `expected`. The test uses `==` internally. + ++ `isnt(actual, expected, [message])` Tests whether `actual` is not equal to + `actual`. The test uses `~=` internally. + ++ `same(actual, expected, [message])` Tests whether `actual` is a deep copy + of `expected`. The test uses an `__eq` metamethod if one is found. Useful + for comparing tables. + ++ `like(string, pattern, [message])` Tests whether `string` matches the given + `pattern`. + ++ `unlike(string, pattern, [message])` Tests whether `string` does not match + the given `pattern`. + ++ `pass([message])` A test that always passes. Useful as a quasi-skip with a + message. + ++ `fail([message])` A test that always fails. Useful as a quasi-TODO with a + message. + ++ `boom(function, args, [message])` Calls `function` with `args` as + parameters and checks to see if an exception is raised. Passes if an + exception is raised; fails otherwise. (The exception is swallowed.) The + `args` parameter expects a table. The table can be empty but not `nil`. + +## Helper method + +A method is available to show how many tests were run. (This output +is required for [TAP compliance][tap], which may matter in some cases.) + +[tap]: http://testanything.org/tap-specification.html + ++ `done([number])` Call this function (optionally) at the end of your test file. + It will print out a line in the form `1..n` where `n` is the total number + of tests run. This secures TAP compliance when needed. The call to `done` + is not otherwise required. If you don't care about TAP compliance, neither does + the library. If you pass the optional parameter to the method, it will check + whether the number of tests you expected matches the number of actual tests. + Thus, if can function like a traditional `plan` method. However, this method + should always be called *last* in your tap file, unlike `plan` methods which + normally start the test file. + + Another reason to use `done` is if you care about the exit status of the + tests. Many continuous integration tools rely on tests signalling success or + failure via their exit status. After `done` is called, the script will exit + with a status of 0, indicating success, if all tests passed. If some tests + failed, the script will exit with a status equal to the number of failed + tests, indicating failure. A script will also exit with an error status if + there is a mismatch between the actual number of tests run and the number + passed to `done` as a parameter. + +## Varia + +The module provides four informational functions that return strings. They +should be self-explanatory. + ++ `version() -- 2.3.0` + ++ `author() -- Peter Aronoff` + ++ `url() -- https://github.com/telemachus/tapered.git` + ++ `license() -- BSD 3-Clause` + +## Credits + +For the `same` method I took ideas and code from [Penlight][p], [Underscore][u], +[luassert][l], and [cwtest][cw]. I thank all the people who worked on those. + +Indirect inspirations include [knock][k], [Test::More][tm], and [bats][b]—not so +much for code as for ideas about testing and simplicity. + +Thanks in particular to [Pierre Chapuis][pchapuis] for help with ideas and +getting continuous integration for tapered. + +An anonymous email showed me that my setup and teardown methods had a logical +flaw. As a result, I've removed those methods. I appreciate the report. + +All the mistakes are mine. See [version history][c] for release details. + +[p]: https://github.com/stevedonovan/Penlight +[u]: https://github.com/mirven/underscore.lua +[l]: https://github.com/Olivine-Labs/luassert +[cw]: https://github.com/catwell/cwtest +[k]: https://github.com/chneukirchen/knock +[tm]: http://search.cpan.org/perldoc?Test::More +[b]: https://github.com/sstephenson/bats +[c]: /CHANGES.md +[pchapuis]: https://twitter.com/pchapuis + +--- + +(c) 2012-2017 Peter Aronoff. BSD 3-Clause license; see [LICENSE.md][li] for +details. + +[li]: /LICENSE.md diff --git a/tests/config/tapered/doc/changes.html b/tests/config/tapered/doc/changes.html new file mode 100644 index 0000000..a4f7034 --- /dev/null +++ b/tests/config/tapered/doc/changes.html @@ -0,0 +1,104 @@ +<!DOCTYPE html> +<html lang="en"> +<head> +<meta charset="utf-8"> +<meta name="author" content="Peter Aronoff"> +<title>tapered version history</title> +<link rel="stylesheet" href="normalize.css" media="screen,projection"> +<link rel="stylesheet" href="screen.css" media="screen,projection"> +</head> +<body> +<h1>tapered version history</h1> + +<h2><em>1.0-0</em> (July 10, 2015)</h2> + +<ul> +<li>Initial public release</li> +</ul> + + +<h2><em>1.0-1</em> (July 10, 2015)</h2> + +<ul> +<li>Fix rockspec: the URL for Bitbucket was wrong.</li> +</ul> + + +<h2><em>1.1-0</em> (July 13, 2015)</h2> + +<ul> +<li>Improve organization and coverage of tests</li> +<li>Refactor the <code>same</code> method</li> +<li>Remove <code>same_mt</code></li> +<li>Meaningful exit statuses via <code>done</code></li> +<li>Add CI via <a href="https://drone.io/bitbucket.org/telemachus/tapered/latest">drone.io</a></li> +</ul> + + +<h2><em>1.2.0-1</em> (July 19, 2015)</h2> + +<ul> +<li>Clean up code using luacheck and luacov</li> +<li>Small tweaks to README and CHANGES</li> +<li>Fix version number: the previous two digit number was a mistake, based on +a misunderstanding of LuaRocks conventions. This is an annoying switch, but +better now than later. And better to do it than to live with a versioning +pattern I dislike.</li> +</ul> + + +<h2><em>1.2.1-1</em> (December 5, 2015)</h2> + +<ul> +<li>Test coverage stats are now thanks to <a href="https://codecov.io">codecov</a>.</li> +<li>Latest stable Lua in the 5.3 series is 5.3.2, so we test against that now.</li> +</ul> + + +<h2><em>2.0.0-1</em> (May 1, 2016)</h2> + +<ul> +<li>The informational fields are now functions that return strings. This is to prevent them from violating Lua recommendations about variables such as <code>_VERSION</code>. (I’ve bumped the major version number since this is technically an API change, though for most users it will not require any changes on their end.)</li> +</ul> + + +<h2><em>2.0.1-1</em> (May 2, 2016)</h2> + +<ul> +<li>Fix a typo in the documentation.</li> +<li>Adjust the <code>version()</code> return value to show only software version, not the rockspec version as well.</li> +</ul> + + +<h2><em>2.1.0-1</em> (July 21, 2016)</h2> + +<ul> +<li>Update to test against Lua 5.3.3</li> +</ul> + + +<h2><em>2.2.0-1</em> (February 11, 2017)</h2> + +<ul> +<li>Update to test against Lua 5.3.4</li> +<li>The repo is now housed on <a href="https://github.com/telemachus/tapered">Github</a></li> +<li>CI is now provided by <a href="https://travis-ci.org/telemachus/tapered">Travis.ci</a></li> +</ul> + + +<h2><em>2.3.0-1</em> (October 15, 2017)</h2> + +<ul> +<li>Remove <code>setup()</code> and <code>teardown()</code></li> +<li>Update to use luarocks 2.4.3 for testing on Travis</li> +</ul> + + +<p>Would you rather view the <a href="index.html">documentation</a>?</p> + +<hr /> + +<p>© 2012-2017 Peter Aronoff. BSD 3-Clause license; see <a href="license.html">the license</a> for +details.</p> +</body> +</html> diff --git a/tests/config/tapered/doc/index.html b/tests/config/tapered/doc/index.html new file mode 100644 index 0000000..69d6b24 --- /dev/null +++ b/tests/config/tapered/doc/index.html @@ -0,0 +1,111 @@ +<!DOCTYPE html> +<html lang="en"> +<head> +<meta charset="utf-8"> +<meta name="author" content="Peter Aronoff"> +<title>tapered documentation</title> +<link rel="stylesheet" href="normalize.css" media="screen,projection"> +<link rel="stylesheet" href="screen.css" media="screen,projection"> +</head> +<body> +<h1>tapered <a href="https://travis-ci.org/telemachus/tapered"><img src="https://travis-ci.org/telemachus/tapered.svg?branch=master" alt="Build Status" /></a> <a href="https://codecov.io/gh/telemachus/tapered"><img src="https://codecov.io/gh/telemachus/tapered/branch/master/graph/badge.svg" alt="Coverage" /></a></h1> + +<h2>Synopsis</h2> + +<p>Very minimal tap testing for Lua. Arguably too minimal.</p> + +<h2>Assertions</h2> + +<p>The <code>message</code> parameter is always optional. Brief messages help make test output +clearer to readers, but are not needed if the output goes straight to another +program for parsing.</p> + +<ul> +<li><p><code>ok(expression, [message])</code> Tests whether <code>expression</code> returns a truthy +value.</p></li> +<li><p><code>nok(expression, [message])</code> Tests whether <code>expression</code> returns a falsy +value.</p></li> +<li><p><code>is(actual, expected, [message])</code> Tests whether <code>actual</code> is equal to +<code>expected</code>. The test uses <code>==</code> internally.</p></li> +<li><p><code>isnt(actual, expected, [message])</code> Tests whether <code>actual</code> is not equal to +<code>actual</code>. The test uses <code>~=</code> internally.</p></li> +<li><p><code>same(actual, expected, [message])</code> Tests whether <code>actual</code> is a deep copy +of <code>expected</code>. The test uses an <code>__eq</code> metamethod if one is found. Useful +for comparing tables.</p></li> +<li><p><code>like(string, pattern, [message])</code> Tests whether <code>string</code> matches the given +<code>pattern</code>.</p></li> +<li><p><code>unlike(string, pattern, [message])</code> Tests whether <code>string</code> does not match +the given <code>pattern</code>.</p></li> +<li><p><code>pass([message])</code> A test that always passes. Useful as a quasi-skip with a +message.</p></li> +<li><p><code>fail([message])</code> A test that always fails. Useful as a quasi-TODO with a +message.</p></li> +<li><p><code>boom(function, args, [message])</code> Calls <code>function</code> with <code>args</code> as +parameters and checks to see if an exception is raised. Passes if an +exception is raised; fails otherwise. (The exception is swallowed.) The +<code>args</code> parameter expects a table. The table can be empty but not <code>nil</code>.</p></li> +</ul> + + +<h2>Helper method</h2> + +<p>A method is available to show how many tests were run. (This output +is required for <a href="http://testanything.org/tap-specification.html">TAP compliance</a>, which may matter in some cases.)</p> + +<ul> +<li><p><code>done([number])</code> Call this function (optionally) at the end of your test file. +It will print out a line in the form <code>1..n</code> where <code>n</code> is the total number +of tests run. This secures TAP compliance when needed. The call to <code>done</code> +is not otherwise required. If you don’t care about TAP compliance, neither does +the library. If you pass the optional parameter to the method, it will check +whether the number of tests you expected matches the number of actual tests. +Thus, if can function like a traditional <code>plan</code> method. However, this method +should always be called <em>last</em> in your tap file, unlike <code>plan</code> methods which +normally start the test file.</p> + +<p>Another reason to use <code>done</code> is if you care about the exit status of the +tests. Many continuous integration tools rely on tests signalling success or +failure via their exit status. After <code>done</code> is called, the script will exit +with a status of 0, indicating success, if all tests passed. If some tests +failed, the script will exit with a status equal to the number of failed +tests, indicating failure. A script will also exit with an error status if +there is a mismatch between the actual number of tests run and the number +passed to <code>done</code> as a parameter.</p></li> +</ul> + + +<h2>Varia</h2> + +<p>The module provides four informational functions that return strings. They +should be self-explanatory.</p> + +<ul> +<li><p><code>version() -- 2.3.0</code></p></li> +<li><p><code>author() -- Peter Aronoff</code></p></li> +<li><p><code>url() -- https://github.com/telemachus/tapered.git</code></p></li> +<li><p><code>license() -- BSD 3-Clause</code></p></li> +</ul> + + +<h2>Credits</h2> + +<p>For the <code>same</code> method I took ideas and code from <a href="https://github.com/stevedonovan/Penlight">Penlight</a>, <a href="https://github.com/mirven/underscore.lua">Underscore</a>, +<a href="https://github.com/Olivine-Labs/luassert">luassert</a>, and <a href="https://github.com/catwell/cwtest">cwtest</a>. I thank all the people who worked on those.</p> + +<p>Indirect inspirations include <a href="https://github.com/chneukirchen/knock">knock</a>, <a href="http://search.cpan.org/perldoc?Test::More">Test::More</a>, and <a href="https://github.com/sstephenson/bats">bats</a>—not so +much for code as for ideas about testing and simplicity.</p> + +<p>Thanks in particular to <a href="https://twitter.com/pchapuis">Pierre Chapuis</a> for help with ideas and +getting continuous integration for tapered.</p> + +<p>An anonymous email showed me that my setup and teardown methods had a logical +flaw. As a result, I’ve removed those methods. I appreciate the report.</p> + +<p>All the mistakes are mine. See <a href="changes.html">version history</a> for release details.</p> + +<hr /> + +<p>© 2012-2017 Peter Aronoff. BSD 3-Clause license; see <a href="license.html">the license</a> for +details.</p> +</body> +</html> diff --git a/tests/config/tapered/doc/license.html b/tests/config/tapered/doc/license.html new file mode 100644 index 0000000..7c8ae8c --- /dev/null +++ b/tests/config/tapered/doc/license.html @@ -0,0 +1,40 @@ +<!DOCTYPE html> +<html lang="en"> +<head> +<meta charset="utf-8"> +<meta name="author" content="Peter Aronoff"> +<title>tapered license</title> +<link rel="stylesheet" href="normalize.css" media="screen,projection"> +<link rel="stylesheet" href="screen.css" media="screen,projection"> +</head> +<body> +<p>Copyright © 2012-2017, Peter Aronoff All rights reserved.</p> + +<p>Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met:</p> + +<ol> +<li><p>Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer.</p></li> +<li><p>Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution.</p></li> +<li><p>Neither the name of the copyright holder nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission.</p></li> +</ol> + + +<p>THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE.</p> +</body> +</html> diff --git a/tests/config/tapered/doc/normalize.css b/tests/config/tapered/doc/normalize.css new file mode 100644 index 0000000..9fc7ae4 --- /dev/null +++ b/tests/config/tapered/doc/normalize.css @@ -0,0 +1,439 @@ +/*! normalize.css 2011-08-12T17:28 UTC · http://github.com/necolas/normalize.css */ + +/* ============================================================================= + HTML5 display definitions + ========================================================================== */ + +/* + * Corrects block display not defined in IE6/7/8/9 & FF3 + */ + +article, +aside, +details, +figcaption, +figure, +footer, +header, +hgroup, +nav, +section { + display: block; +} + +/* + * Corrects inline-block display not defined in IE6/7/8/9 & FF3 + */ + +audio, +canvas, +video { + display: inline-block; + *display: inline; + *zoom: 1; +} + +/* + * Prevents modern browsers from displaying 'audio' without controls + */ + +audio:not([controls]) { + display: none; +} + +/* + * Addresses styling for 'hidden' attribute not present in IE7/8/9, FF3, S4 + * Known issue: no IE6 support + */ + +[hidden] { + display: none; +} + + +/* ============================================================================= + Base + ========================================================================== */ + +/* + * 1. Corrects text resizing oddly in IE6/7 when body font-size is set using em units + * http://clagnut.com/blog/348/#c790 + * 2. Keeps page centred in all browsers regardless of content height + * 3. Prevents iOS text size adjust after orientation change, without disabling user zoom + * www.456bereastreet.com/archive/201012/controlling_text_size_in_safari_for_ios_without_disabling_user_zoom/ + */ + +html { + font-size: 100%; /* 1 */ + overflow-y: scroll; /* 2 */ + -webkit-text-size-adjust: 100%; /* 3 */ + -ms-text-size-adjust: 100%; /* 3 */ +} + +/* + * Addresses margins handled incorrectly in IE6/7 + */ + +body { + margin: 0; +} + +/* + * Addresses font-family inconsistency between 'textarea' and other form elements. + */ + +body, +button, +input, +select, +textarea { + font-family: sans-serif; +} + + +/* ============================================================================= + Links + ========================================================================== */ + +a { + color: #00e; +} + +a:visited { + color: #551a8b; +} + +/* + * Addresses outline displayed oddly in Chrome + */ + +a:focus { + outline: thin dotted; +} + +/* + * Improves readability when focused and also mouse hovered in all browsers + * people.opera.com/patrickl/experiments/keyboard/test + */ + +a:hover, +a:active { + outline: 0; +} + + +/* ============================================================================= + Typography + ========================================================================== */ + +/* + * Addresses styling not present in IE7/8/9, S5, Chrome + */ + +abbr[title] { + border-bottom: 1px dotted; +} + +/* + * Addresses style set to 'bolder' in FF3/4, S4/5, Chrome +*/ + +b, +strong { + font-weight: bold; +} + +blockquote { + margin: 1em 40px; +} + +/* + * Addresses styling not present in S5, Chrome + */ + +dfn { + font-style: italic; +} + +/* + * Addresses styling not present in IE6/7/8/9 + */ + +mark { + background: #ff0; + color: #000; +} + +/* + * Corrects font family set oddly in IE6, S4/5, Chrome + * en.wikipedia.org/wiki/User:Davidgothberg/Test59 + */ + +pre, +code, +kbd, +samp { + font-family: monospace, serif; + _font-family: 'courier new', monospace; + font-size: 1em; +} + +/* + * Improves readability of pre-formatted text in all browsers + */ + +pre { + white-space: pre; + white-space: pre-wrap; + word-wrap: break-word; +} + +/* + * 1. Addresses CSS quotes not supported in IE6/7 + * 2. Addresses quote property not supported in S4 + */ + +/* 1 */ + +q { + quotes: none; +} + +/* 2 */ + +q:before, +q:after { + content: ''; + content: none; +} + +small { + font-size: 75%; +} + +/* + * Prevents sub and sup affecting line-height in all browsers + * gist.github.com/413930 + */ + +sub, +sup { + font-size: 75%; + line-height: 0; + position: relative; + vertical-align: baseline; +} + +sup { + top: -0.5em; +} + +sub { + bottom: -0.25em; +} + + +/* ============================================================================= + Lists + ========================================================================== */ + +ul, +ol { + margin: 1em 0; + padding: 0 0 0 40px; +} + +dd { + margin: 0 0 0 40px; +} + +nav ul, +nav ol { + list-style: none; + list-style-image: none; +} + + +/* ============================================================================= + Embedded content + ========================================================================== */ + +/* + * 1. Removes border when inside 'a' element in IE6/7/8/9 + * 2. Improves image quality when scaled in IE7 + * code.flickr.com/blog/2008/11/12/on-ui-quality-the-little-things-client-side-image-resizing/ + */ + +img { + border: 0; /* 1 */ + -ms-interpolation-mode: bicubic; /* 2 */ +} + +/* + * Corrects overflow displayed oddly in IE9 + */ + +svg:not(:root) { + overflow: hidden; +} + + +/* ============================================================================= + Figures + ========================================================================== */ + +/* + * Addresses margin not present in IE6/7/8/9, S5, O11 + */ + +figure { + margin: 0; +} + + +/* ============================================================================= + Forms + ========================================================================== */ + +/* + * Corrects margin displayed oddly in IE6/7 + */ + +form { + margin: 0; +} + +/* + * Define consistent margin and padding + */ + +fieldset { + margin: 0 2px; + padding: 0.35em 0.625em 0.75em; +} + +/* + * 1. Corrects color not being inherited in IE6/7/8/9 + * 2. Corrects alignment displayed oddly in IE6/7 + */ + +legend { + border: 0; /* 1 */ + *margin-left: -7px; /* 2 */ +} + +/* + * 1. Corrects font size not being inherited in all browsers + * 2. Addresses margins set differently in IE6/7, F3/4, S5, Chrome + * 3. Improves appearance and consistency in all browsers + */ + +button, +input, +select, +textarea { + font-size: 100%; /* 1 */ + margin: 0; /* 2 */ + vertical-align: baseline; /* 3 */ + *vertical-align: middle; /* 3 */ +} + +/* + * 1. Addresses FF3/4 setting line-height using !important in the UA stylesheet + * 2. Corrects inner spacing displayed oddly in IE6/7 + */ + +button, +input { + line-height: normal; /* 1 */ + *overflow: visible; /* 2 */ +} + +/* + * Corrects overlap and whitespace issue for buttons and inputs in IE6/7 + * Known issue: reintroduces inner spacing + */ + +table button, +table input { + *overflow: auto; +} + +/* + * 1. Improves usability and consistency of cursor style between image-type 'input' and others + * 2. Corrects inability to style clickable 'input' types in iOS + */ + +button, +html input[type="button"], +input[type="reset"], +input[type="submit"] { + cursor: pointer; /* 1 */ + -webkit-appearance: button; /* 2 */ +} + +/* + * 1. Addresses box sizing set to content-box in IE8/9 + * 2. Addresses excess padding in IE8/9 + */ + +input[type="checkbox"], +input[type="radio"] { + box-sizing: border-box; /* 1 */ + padding: 0; /* 2 */ +} + +/* + * 1. Addresses appearance set to searchfield in S5, Chrome + * 2. Addresses box sizing set to border-box in S5, Chrome (include -moz to future-proof) + */ + +input[type="search"] { + -webkit-appearance: textfield; /* 1 */ + -moz-box-sizing: content-box; + -webkit-box-sizing: content-box; /* 2 */ + box-sizing: content-box; +} + +/* + * Corrects inner padding displayed oddly in S5, Chrome on OSX + */ + +input[type="search"]::-webkit-search-decoration { + -webkit-appearance: none; +} + +/* + * Corrects inner padding and border displayed oddly in FF3/4 + * www.sitepen.com/blog/2008/05/14/the-devils-in-the-details-fixing-dojos-toolbar-buttons/ + */ + +button::-moz-focus-inner, +input::-moz-focus-inner { + border: 0; + padding: 0; +} + +/* + * 1. Removes default vertical scrollbar in IE6/7/8/9 + * 2. Improves readability and alignment in all browsers + */ + +textarea { + overflow: auto; /* 1 */ + vertical-align: top; /* 2 */ +} + + +/* ============================================================================= + Tables + ========================================================================== */ + +/* + * Remove most spacing between table cells + */ + +table { + border-collapse: collapse; + border-spacing: 0; +} diff --git a/tests/config/tapered/doc/screen.css b/tests/config/tapered/doc/screen.css new file mode 100644 index 0000000..2583183 --- /dev/null +++ b/tests/config/tapered/doc/screen.css @@ -0,0 +1,109 @@ +body { + margin: 10px auto; + width: 820px; + font-size: 18px; + font-family: "DejaVuSerifBook", "Palatino", "Palatino Linotype", serif; + color: #333; +} + +h1, h2, h3, h4, h5, h6 { + font-family: "DejaVuSansBook", "Lucida Grande", "Helvetica Neue", sans-serif; + font-weight: bold; + line-height: 1.6; + margin-bottom: 5px; + color: #111; +} + +h1 { + margin-top: 10px; +} + +h2, h3, h4, h5, h6 { margin-top: 20px; } + +h1 { font-size: 28px; } + +h2 { font-size: 24px; border-bottom: solid 4px; } +h3 { font-size: 20px; } + +p { + line-height: 1.3; + margin: 12px auto; + +} + +code { + font-family: "DejaVuSansMono", Inconsolata, Consolas, Menlo, monospace; +} + +blockquote { + margin: 10px 30px 10px 20px; +} + +blockquote p { + line-height: 1.2; +} + +ul, ol, ul p, ol p { + margin-left: 0; + line-height: 1.3; +} + +ul ul, ol ol { + font-size: 100%; +} + +ul { + list-style-type: disc; +} + +ul ul { + list-style-type: circle; +} + +ul ul ul { + list-style-type: square; +} + +ul ul ul ul { + list-style-type: disc; +} + +h2 + p { + margin-top: 15px; +} + +a:link, a:visited { + text-decoration: underline; + color: #336891; +} + +a:hover, a:focus { + text-decoration: none; + color: #336891; +} + +pre { + margin: 30px 15px; + padding: 10px 5px 10px 15px; + border: solid black 5px; + border-left: solid black 30px; + font-size: 14px; + line-height: 1.3; + background: #FFF; + color: #000; + -moz-border-radius: 5px; + -webkit-border-radius: 5px; + border-radius: 5px; +} + +ins { + text-decoration: none; +} + +ins:before { + content: "〈"; +} + +ins:after { + content: "〉"; +} diff --git a/tests/config/tapered/make-doc.bash b/tests/config/tapered/make-doc.bash new file mode 100755 index 0000000..4ceb65d --- /dev/null +++ b/tests/config/tapered/make-doc.bash @@ -0,0 +1,55 @@ +#!/usr/bin/env bash + +{ + printf "<!DOCTYPE html>\n" + printf "<html lang=\"en\">\n" + printf "<head>\n" + printf "<meta charset=\"utf-8\">\n" + printf "<meta name=\"author\" content=\"Peter Aronoff\">\n" + printf "<title>tapered documentation</title>\n" + printf "<link rel=\"stylesheet\" href=\"normalize.css\" " + printf "media=\"screen,projection\">\n" + printf "<link rel=\"stylesheet\" href=\"screen.css\" " + printf "media=\"screen,projection\">\n" + printf "</head>\n" + printf "<body>\n" + markdown README.md | sed -e 's/\/CHANGES.md/changes.html/' -e 's/\/LICENSE.md/license.html/' -e 's/LICENSE.md/the license/' + printf "</body>\n" + printf "</html>\n" +} > doc/index.html + +{ + printf "<!DOCTYPE html>\n" + printf "<html lang=\"en\">\n" + printf "<head>\n" + printf "<meta charset=\"utf-8\">\n" + printf "<meta name=\"author\" content=\"Peter Aronoff\">\n" + printf "<title>tapered version history</title>\n" + printf "<link rel=\"stylesheet\" href=\"normalize.css\" " + printf "media=\"screen,projection\">\n" + printf "<link rel=\"stylesheet\" href=\"screen.css\" " + printf "media=\"screen,projection\">\n" + printf "</head>\n" + printf "<body>\n" + markdown CHANGES.md | sed -e 's/\/README.md/index.html/' -e 's/\/LICENSE.md/license.html/' -e 's/LICENSE.md/the license/' + printf "</body>\n" + printf "</html>\n" +} > doc/changes.html + +{ + printf "<!DOCTYPE html>\n" + printf "<html lang=\"en\">\n" + printf "<head>\n" + printf "<meta charset=\"utf-8\">\n" + printf "<meta name=\"author\" content=\"Peter Aronoff\">\n" + printf "<title>tapered license</title>\n" + printf "<link rel=\"stylesheet\" href=\"normalize.css\" " + printf "media=\"screen,projection\">\n" + printf "<link rel=\"stylesheet\" href=\"screen.css\" " + printf "media=\"screen,projection\">\n" + printf "</head>\n" + printf "<body>\n" + markdown LICENSE.md + printf "</body>\n" + printf "</html>\n" +} > doc/license.html diff --git a/tests/config/tapered/src/tapered.lua b/tests/config/tapered/src/tapered.lua new file mode 100644 index 0000000..5bcb331 --- /dev/null +++ b/tests/config/tapered/src/tapered.lua @@ -0,0 +1,189 @@ +-- Helper variables and functions +local get_info = debug.getinfo +local pcall = pcall +local slice = string.sub +local sprintf = string.format +local str_find = string.find +local tonumber = tonumber +-- Lua 5.3 moved unpack to table.unpack +local unpack = unpack or table.unpack +local write = io.write +local rawget = rawget +local getmetatable = getmetatable +local exit = os.exit + +---- Helper methods + +--- C-like printf method +local printf = function(fmt, ...) + write(sprintf(fmt, ...)) +end + +--- Compare potentially complex tables or objects +-- +-- Ideas here are taken from [Penlight][p], [Underscore][u], [cwtest][cw], and +-- [luassert][l]. +-- [p]: https://github.com/stevedonovan/Penlight +-- [u]: https://github.com/mirven/underscore.lua +-- [cw]: https://github.com/catwell/cwtest +-- [l]: https://github.com/Olivine-Labs/luassert +-- +-- Predeclare both function names +local keyvaluesame +local deepsame +-- +--- keyvaluesame(table, table) => true or false +-- Helper method to compare all the keys and values of a table +keyvaluesame = function (t1, t2) + for k1, v1 in pairs(t1) do + local v2 = t2[k1] + if v2 == nil or not deepsame(v1, v2) then return false end + end + + -- Check for any keys present in t2 but not t1 + for k2, _ in pairs(t2) do + if t1[k2] == nil then return false end + end + + return true +end +-- +--- deepsame(item, item) => true or false +-- Compare two items of any type for identity +deepsame = function (t1, t2) + local ty1, ty2 = type(t1), type(t2) + if ty1 ~= ty2 then return false end + if ty1 ~= 'table' then return t1 == t2 end + + -- If ._eq is found, use == and end quickly. + -- As of Lua 5.3 == only cares if **one** of the two items has a __eq + -- metamethod. Penlight, underscore and cwtest take the same approach, + -- so I will as well. + local eq = rawget(getmetatable(t1) or {}, '__eq') + if (type(eq) == 'function') then + return not not eq(t1, t2) + else + return keyvaluesame(t1, t2) + end +end + +---- tapered test suite + +local exit_status = 0 +local test_count = 0 +local debug_level = 3 + +-- All other tests are defined in terms of this primitive, which is +-- kept private. +local _test = function (exp, msg) + test_count = test_count + 1 + + if msg then + msg = sprintf(" - %s", msg) + else + msg = '' + end + + if exp then + printf("ok %s%s\n", test_count, msg) + else + exit_status = 1 + exit_status + printf("not ok %s%s\n", test_count, msg) + local info = get_info(debug_level) + printf("# Trouble in %s around line %s\n", + slice(info.source, 2), info.currentline) + end +end + +local ok = function (expression, msg) + _test(expression, msg) +end + +local nok = function (expression, msg) + _test(not expression, msg) +end + +local is = function (actual, expected, msg) + _test(actual == expected, msg) +end + +local isnt = function (actual, expected, msg) + _test(actual ~= expected, msg) +end + +local same = function (actual, expected, msg) + _test(deepsame(actual, expected), msg) +end + +local like = function (str, pattern, msg) + _test(str_find(str, pattern), msg) +end + +local unlike = function (str, pattern, msg) + _test(not str_find(str, pattern), msg) +end + +local pass = function (msg) + _test(true, msg) +end + +local fail = function (msg) + _test(false, msg) +end + +local boom = function (func, args, msg) + local err, errmsg + err, errmsg = pcall(func, unpack(args)) + _test(not err, msg) + if not err and type(errmsg) == 'string' then + printf('# Got this error: "%s"\n', errmsg) + end +end + +local done = function (n) + local expected = tonumber(n) + if not expected or test_count == expected then + printf('1..%d\n', test_count) + elseif expected ~= test_count then + exit_status = 1 + exit_status + local s + if expected == 1 then s = '' else s = 's' end + printf("# Bad plan. You planned %d test%s but ran %d\n", + expected, s, test_count) + end + exit(exit_status) +end + +local version = function () + return "2.3.0" +end + +local author = function () + return "Peter Aronoff" +end + +local url = function () + return "https://github.com/telemachus/tapered" +end + +local license = function () + return "BSD 3-Clause" +end + +return { + ok = ok, + nok = nok, + is = is, + isnt = isnt, + same = same, + like = like, + unlike = unlike, + pass = pass, + fail = fail, + boom = boom, + done = done, + version = version, + author = author, + url = url, + license = license +} diff --git a/tests/config/tapered/tapered-1.1-0.rockspec b/tests/config/tapered/tapered-1.1-0.rockspec new file mode 100644 index 0000000..d6dea7d --- /dev/null +++ b/tests/config/tapered/tapered-1.1-0.rockspec @@ -0,0 +1,21 @@ +package = 'tapered' +version = '1.1-0' +source = { + url = 'https://bitbucket.org/telemachus/tapered/downloads/tapered-v1.1-0.tar.gz', + dir = 'tapered', +} +description = { + summary = 'Very minimal tap testing for Lua.', + detailed = [[ + Very minimal tap testing for Lua. Arguably too minimal. + ]], + license = 'BSD 3-Clause' +} +dependencies = { + 'lua >= 5.1' +} +build = { + type = 'builtin', + modules = { tapered = 'src/tapered.lua' }, + copy_directories = { 'doc' } +} diff --git a/tests/config/tapered/tapered-1.2.0-1.rockspec b/tests/config/tapered/tapered-1.2.0-1.rockspec new file mode 100644 index 0000000..5e6c364 --- /dev/null +++ b/tests/config/tapered/tapered-1.2.0-1.rockspec @@ -0,0 +1,21 @@ +package = 'tapered' +version = '1.2.0-1' +source = { + url = 'https://bitbucket.org/telemachus/tapered/downloads/tapered-v1.2.0-1.tar.gz', + dir = 'tapered', +} +description = { + summary = 'Very minimal tap testing for Lua.', + detailed = [[ + Very minimal tap testing for Lua. Arguably too minimal. + ]], + license = 'BSD 3-Clause' +} +dependencies = { + 'lua >= 5.1' +} +build = { + type = 'builtin', + modules = { tapered = 'src/tapered.lua' }, + copy_directories = { 'doc' } +} diff --git a/tests/config/tapered/tapered-1.2.1-1.rockspec b/tests/config/tapered/tapered-1.2.1-1.rockspec new file mode 100644 index 0000000..673e1af --- /dev/null +++ b/tests/config/tapered/tapered-1.2.1-1.rockspec @@ -0,0 +1,21 @@ +package = 'tapered' +version = '1.2.1-1' +source = { + url = 'https://bitbucket.org/telemachus/tapered/downloads/tapered-v1.2.1-1.tar.gz', + dir = 'tapered', +} +description = { + summary = 'Very minimal tap testing for Lua.', + detailed = [[ + Very minimal tap testing for Lua. Arguably too minimal. + ]], + license = 'BSD 3-Clause' +} +dependencies = { + 'lua >= 5.1' +} +build = { + type = 'builtin', + modules = { tapered = 'src/tapered.lua' }, + copy_directories = { 'doc' } +} diff --git a/tests/config/tapered/tapered-2.0.0-1.rockspec b/tests/config/tapered/tapered-2.0.0-1.rockspec new file mode 100644 index 0000000..5e5484a --- /dev/null +++ b/tests/config/tapered/tapered-2.0.0-1.rockspec @@ -0,0 +1,21 @@ +package = 'tapered' +version = '2.0.0-1' +source = { + url = 'https://bitbucket.org/telemachus/tapered/downloads/tapered-v2.0.0-1.tar.gz', + dir = 'tapered', +} +description = { + summary = 'Very minimal tap testing for Lua.', + detailed = [[ + Very minimal tap testing for Lua. Arguably too minimal. + ]], + license = 'BSD 3-Clause' +} +dependencies = { + 'lua >= 5.1' +} +build = { + type = 'builtin', + modules = { tapered = 'src/tapered.lua' }, + copy_directories = { 'doc' } +} diff --git a/tests/config/tapered/tapered-2.0.1-1.rockspec b/tests/config/tapered/tapered-2.0.1-1.rockspec new file mode 100644 index 0000000..1127375 --- /dev/null +++ b/tests/config/tapered/tapered-2.0.1-1.rockspec @@ -0,0 +1,21 @@ +package = 'tapered' +version = '2.0.1-1' +source = { + url = 'https://bitbucket.org/telemachus/tapered/downloads/tapered-v2.0.1-1.tar.gz', + dir = 'tapered', +} +description = { + summary = 'Very minimal tap testing for Lua.', + detailed = [[ + Very minimal tap testing for Lua. Arguably too minimal. + ]], + license = 'BSD 3-Clause' +} +dependencies = { + 'lua >= 5.1' +} +build = { + type = 'builtin', + modules = { tapered = 'src/tapered.lua' }, + copy_directories = { 'doc' } +} diff --git a/tests/config/tapered/tapered-2.1.0-1.rockspec b/tests/config/tapered/tapered-2.1.0-1.rockspec new file mode 100644 index 0000000..f14c756 --- /dev/null +++ b/tests/config/tapered/tapered-2.1.0-1.rockspec @@ -0,0 +1,21 @@ +package = 'tapered' +version = '2.1.0-1' +source = { + url = 'https://bitbucket.org/telemachus/tapered/downloads/tapered-v2.1.0-1.tar.gz', + dir = 'tapered', +} +description = { + summary = 'Very minimal tap testing for Lua.', + detailed = [[ + Very minimal tap testing for Lua. Arguably too minimal. + ]], + license = 'BSD 3-Clause' +} +dependencies = { + 'lua >= 5.1' +} +build = { + type = 'builtin', + modules = { tapered = 'src/tapered.lua' }, + copy_directories = { 'doc' } +} diff --git a/tests/config/tapered/tapered-2.2.0-1.rockspec b/tests/config/tapered/tapered-2.2.0-1.rockspec new file mode 100644 index 0000000..cfb8b51 --- /dev/null +++ b/tests/config/tapered/tapered-2.2.0-1.rockspec @@ -0,0 +1,22 @@ +package = 'tapered' +version = '2.2.0-1' +source = { + url = 'git://github.com/telemachus/tapered.git', + branch = 'master', + tag = 'v2.2.0-1' +} +description = { + summary = 'Very minimal tap testing for Lua.', + detailed = [[ + Very minimal tap testing for Lua. Arguably too minimal. + ]], + license = 'BSD 3-Clause' +} +dependencies = { + 'lua >= 5.1' +} +build = { + type = 'builtin', + modules = { tapered = 'src/tapered.lua' }, + copy_directories = { 'doc' } +} diff --git a/tests/config/tapered/tapered-2.3.0-1.rockspec b/tests/config/tapered/tapered-2.3.0-1.rockspec new file mode 100644 index 0000000..b3060fb --- /dev/null +++ b/tests/config/tapered/tapered-2.3.0-1.rockspec @@ -0,0 +1,22 @@ +package = 'tapered' +version = '2.3.0-1' +source = { + url = 'git://github.com/telemachus/tapered.git', + branch = 'master', + tag = 'v2.3.0-1' +} +description = { + summary = 'Very minimal tap testing for Lua.', + detailed = [[ + Very minimal tap testing for Lua. Arguably too minimal. + ]], + license = 'BSD 3-Clause' +} +dependencies = { + 'lua >= 5.1' +} +build = { + type = 'builtin', + modules = { tapered = 'src/tapered.lua' }, + copy_directories = { 'doc' } +} diff --git a/tests/config/tapered/test/.luacov b/tests/config/tapered/test/.luacov new file mode 100644 index 0000000..7d3205e --- /dev/null +++ b/tests/config/tapered/test/.luacov @@ -0,0 +1,55 @@ +--- Global configuration file. Copy, customize and store in your +-- project folder as '.luacov' for project specific configuration. +-- If some options are missing, their default values from this file +-- will be used. +-- @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", + + -- luacov.stats file updating frequency. + -- The lower this value - the more frequenty results will be written out to luacov.stats + -- You may want to reduce this value for short lived scripts (to for example 2) to avoid losing coverage data. + ["savestepsize"] = 100, + + -- Run reporter on completion? (won't work for ticks) + runreport = false, + + -- Delete stats file after reporting? + deletestats = false, + + -- Process Lua code loaded from raw strings + -- (that is, when the 'source' field in the debug info + -- does not start with '@') + codefromstrings = false, + + -- Patterns for files to include when reporting + -- all will be included if nothing is listed + -- (exclude overrules include, do not include + -- the .lua extension, path separator is always '/') + ["include"] = { 'src/tapered' }, + + -- Patterns for files to exclude when reporting + -- all will be included if nothing is listed + -- (exclude overrules include, do not include + -- the .lua extension, path separator is always '/') + ["exclude"] = { + "luacov$", + "luacov/reporter$", + "luacov/defaults$", + "luacov/runner$", + "luacov/stats$", + "luacov/tick$", + }, + + +} diff --git a/tests/config/tapered/test/boom-result.txt b/tests/config/tapered/test/boom-result.txt new file mode 100644 index 0000000..871b509 --- /dev/null +++ b/tests/config/tapered/test/boom-result.txt @@ -0,0 +1,7 @@ +ok 1 - ok - return nada.__eq +# Got this error: "boom-test.lua:13: attempt to index local 'x' (a nil value)" +not ok 2 - not ok - Test boom with a method that throws no exception +# Trouble in boom-test.lua around line 16 +ok 3 - ok - Test boom with a method that throws an exception "Kaboom!" +# Got this error: "Kaboom!" +1..3 diff --git a/tests/config/tapered/test/boom-test.lua b/tests/config/tapered/test/boom-test.lua new file mode 100755 index 0000000..f2b585a --- /dev/null +++ b/tests/config/tapered/test/boom-test.lua @@ -0,0 +1,19 @@ +package.path = '../src/?.lua;' .. package.path +local tap = require 'tapered' +local error = error + +--- boom +-- boom(method, arguments, [msg]) tests if the function throws an exception when +-- given the arguments supplied. The arguments parameter must be a table. It can +-- be empty if the given method takes no arguments, but it cannot be nil. +-- +-- Note that boom expects an exception. It passes if an exception is throw, and +-- fails if one is not. The exception, however, will be swallowed by boom so +-- that test execution continues. +local broken = function (x) return x.__eq end +local add = function (x, y) return x+y end +tap.boom(broken, {}, 'ok - return nada.__eq') +tap.boom(add, {2, 3}, 'not ok - Test boom with a method that throws no exception') +tap.boom(error, {'Kaboom!'}, + 'ok - Test boom with a method that throws an exception "Kaboom!"') +tap.done() diff --git a/tests/config/tapered/test/done-failure-result.txt b/tests/config/tapered/test/done-failure-result.txt new file mode 100644 index 0000000..ce29e24 --- /dev/null +++ b/tests/config/tapered/test/done-failure-result.txt @@ -0,0 +1,2 @@ +ok 1 +# Bad plan. You planned 10 tests but ran 1 diff --git a/tests/config/tapered/test/done-failure-test.lua b/tests/config/tapered/test/done-failure-test.lua new file mode 100644 index 0000000..40603d4 --- /dev/null +++ b/tests/config/tapered/test/done-failure-test.lua @@ -0,0 +1,5 @@ +package.path = '../src/?.lua;' .. package.path +local tap = require 'tapered' + +tap.ok(true) +tap.done(10) diff --git a/tests/config/tapered/test/done-success-result.txt b/tests/config/tapered/test/done-success-result.txt new file mode 100644 index 0000000..45541bc --- /dev/null +++ b/tests/config/tapered/test/done-success-result.txt @@ -0,0 +1,2 @@ +ok 1 +1..1 diff --git a/tests/config/tapered/test/done-success-test.lua b/tests/config/tapered/test/done-success-test.lua new file mode 100644 index 0000000..9e58ddd --- /dev/null +++ b/tests/config/tapered/test/done-success-test.lua @@ -0,0 +1,5 @@ +package.path = '../src/?.lua;' .. package.path +local tap = require 'tapered' + +tap.ok(true) +tap.done(1) diff --git a/tests/config/tapered/test/dynamic-setup-teardown-result.txt b/tests/config/tapered/test/dynamic-setup-teardown-result.txt new file mode 100644 index 0000000..7130f99 --- /dev/null +++ b/tests/config/tapered/test/dynamic-setup-teardown-result.txt @@ -0,0 +1,10 @@ +# I'm a little teapot. +ok 1 - setup() only with '# I'm a little teapot.' +# This is my handle and this is my spout. +ok 2 - setup() handle and spout, teardown() cleanup on aisle 9 +# Cleanup on aisle 9! +# This is my handle and this is my spout. +ok 3 - setup() again handle and spout, teardown() changed +# I changed this. +ok 4 - Both setup and teardown should be gone now: redefined as nil. +1..4 diff --git a/tests/config/tapered/test/dynamic-setup-teardown-test.lua b/tests/config/tapered/test/dynamic-setup-teardown-test.lua new file mode 100755 index 0000000..c7abb9d --- /dev/null +++ b/tests/config/tapered/test/dynamic-setup-teardown-test.lua @@ -0,0 +1,27 @@ +package.path = '../src/?.lua;' .. package.path +local tap = require 'tapered' + +-- luacheck: globals setup teardown +function setup() + print("# I'm a little teapot.") +end +tap.ok(true, "setup() only with '# I'm a little teapot.'") + +function setup() + print('# This is my handle and this is my spout.') +end +function teardown() + print('# Cleanup on aisle 9!') +end +tap.ok(true, 'setup() handle and spout, teardown() cleanup on aisle 9') + +function teardown() + print('# I changed this.') +end +tap.ok(true, 'setup() again handle and spout, teardown() changed') + +setup = nil +teardown = nil +tap.ok(true, 'Both setup and teardown should be gone now: redefined as nil.') + +tap.done() diff --git a/tests/config/tapered/test/exit-failure-test.lua b/tests/config/tapered/test/exit-failure-test.lua new file mode 100755 index 0000000..18339c2 --- /dev/null +++ b/tests/config/tapered/test/exit-failure-test.lua @@ -0,0 +1,6 @@ +package.path = '../src/?.lua;' .. package.path +local tap = require 'tapered' + +-- Test exit status with a failed test. Call `fail` and we're done! +tap.fail('not ok - No test: just fail') +tap.done() diff --git a/tests/config/tapered/test/exit-success-test.lua b/tests/config/tapered/test/exit-success-test.lua new file mode 100755 index 0000000..b588b64 --- /dev/null +++ b/tests/config/tapered/test/exit-success-test.lua @@ -0,0 +1,6 @@ +package.path = '../src/?.lua;' .. package.path +local tap = require 'tapered' + +-- Testing exit status. Call `pass` and then we're out. +tap.pass('ok - No test: just pass') +tap.done() diff --git a/tests/config/tapered/test/informational-fields-result.txt b/tests/config/tapered/test/informational-fields-result.txt new file mode 100644 index 0000000..4d0ebc1 --- /dev/null +++ b/tests/config/tapered/test/informational-fields-result.txt @@ -0,0 +1,4 @@ +ok 1 - author() should be 'Peter Aronoff' +ok 2 - version() should be '2.3.0' +ok 3 - license() should be 'BSD 3-Clause' +ok 4 - url() should be 'https://github.com/telemachus/tapered' diff --git a/tests/config/tapered/test/informational-fields-test.lua b/tests/config/tapered/test/informational-fields-test.lua new file mode 100755 index 0000000..35ef7d8 --- /dev/null +++ b/tests/config/tapered/test/informational-fields-test.lua @@ -0,0 +1,8 @@ +package.path = '../src/?.lua;' .. package.path +local tap = require 'tapered' + +tap.is(tap.author(), 'Peter Aronoff', "author() should be 'Peter Aronoff'") +tap.is(tap.version(), '2.3.0', "version() should be '2.3.0'") +tap.is(tap.license(), 'BSD 3-Clause', "license() should be 'BSD 3-Clause'") +tap.is(tap.url(), "https://github.com/telemachus/tapered", + "url() should be 'https://github.com/telemachus/tapered'") diff --git a/tests/config/tapered/test/is-isnt-result.txt b/tests/config/tapered/test/is-isnt-result.txt new file mode 100644 index 0000000..583a9a7 --- /dev/null +++ b/tests/config/tapered/test/is-isnt-result.txt @@ -0,0 +1,43 @@ +ok 1 - ok - is(2+1, 3) +not ok 2 - not ok - is(2+2, 3) +# Trouble in is-isnt-test.lua around line 8 +ok 3 - ok - is(print, print) +not ok 4 - not ok - is(print, 3) +# Trouble in is-isnt-test.lua around line 10 +ok 5 - ok - is("hello", "hello") +not ok 6 - not ok - is("goodbye", "hello") +# Trouble in is-isnt-test.lua around line 12 +ok 7 - ok - is(nil, nil) +not ok 8 - not ok - is(nil, false) +# Trouble in is-isnt-test.lua around line 14 +ok 9 - ok - is(false, false) +ok 10 - ok - is(true, true) +not ok 11 - not ok - is(true, false) +# Trouble in is-isnt-test.lua around line 17 +not ok 12 - not ok - is(false, true) +# Trouble in is-isnt-test.lua around line 18 +ok 13 - ok - isnt(2+2, 3) +not ok 14 - not ok - isnt(2+2, 4) +# Trouble in is-isnt-test.lua around line 20 +ok 15 - ok - isnt(3, print) +ok 16 - ok - isnt(print, os.exit) +ok 17 - ok - isnt("hello", "goodbye") +not ok 18 - not ok - isnt("hello", "hello") +# Trouble in is-isnt-test.lua around line 24 +not ok 19 - not ok - isnt(nil, nil) +# Trouble in is-isnt-test.lua around line 25 +ok 20 - ok - isnt(nil, false) +not ok 21 - not ok - isnt(false, false) +# Trouble in is-isnt-test.lua around line 27 +not ok 22 - not ok - isnt(true, true) +# Trouble in is-isnt-test.lua around line 28 +ok 23 - ok - isnt(true, false) +ok 24 - ok - isnt(false, true) +ok 25 - ok - isnt(nil, false) +not ok 26 - not ok - isnt(false, false) +# Trouble in is-isnt-test.lua around line 32 +not ok 27 - not ok - isnt(true, true) +# Trouble in is-isnt-test.lua around line 33 +ok 28 - ok - isnt(true, false) +ok 29 - ok - isnt(false, true) +1..29 diff --git a/tests/config/tapered/test/is-isnt-test.lua b/tests/config/tapered/test/is-isnt-test.lua new file mode 100755 index 0000000..d1c7636 --- /dev/null +++ b/tests/config/tapered/test/is-isnt-test.lua @@ -0,0 +1,36 @@ +package.path = '../src/?.lua;' .. package.path +local tap = require 'tapered' + +--- is and isnt +-- is(actual, expected, [msg]) tests if actual == expected +-- isnt(actual, expected, [msg]) tests if actual ~= expected +tap.is(2+1, 3, 'ok - is(2+1, 3)') +tap.is(2+2, 3, 'not ok - is(2+2, 3)') +tap.is(print, print, 'ok - is(print, print)') +tap.is(print, 3, 'not ok - is(print, 3)') +tap.is('hello', 'hello', 'ok - is("hello", "hello")') +tap.is('goodbye', 'hello', 'not ok - is("goodbye", "hello")') +tap.is(nil, nil, 'ok - is(nil, nil)') +tap.is(nil, false, 'not ok - is(nil, false)') +tap.is(false, false, 'ok - is(false, false)') +tap.is(true, true, 'ok - is(true, true)') +tap.is(true, false, 'not ok - is(true, false)') +tap.is(false, true, 'not ok - is(false, true)') +tap.isnt(2+2, 3, 'ok - isnt(2+2, 3)') +tap.isnt(2+2, 4, 'not ok - isnt(2+2, 4)') +tap.isnt(3, print, 'ok - isnt(3, print)') +tap.isnt(print, os.exit, 'ok - isnt(print, os.exit)') +tap.isnt('hello', 'goodbye', 'ok - isnt("hello", "goodbye")') +tap.isnt('hello', 'hello', 'not ok - isnt("hello", "hello")') +tap.isnt(nil, nil, 'not ok - isnt(nil, nil)') +tap.isnt(nil, false, 'ok - isnt(nil, false)') +tap.isnt(false, false, 'not ok - isnt(false, false)') +tap.isnt(true, true, 'not ok - isnt(true, true)') +tap.isnt(true, false, 'ok - isnt(true, false)') +tap.isnt(false, true, 'ok - isnt(false, true)') +tap.isnt(nil, false, 'ok - isnt(nil, false)') +tap.isnt(false, false, 'not ok - isnt(false, false)') +tap.isnt(true, true, 'not ok - isnt(true, true)') +tap.isnt(true, false, 'ok - isnt(true, false)') +tap.isnt(false, true, 'ok - isnt(false, true)') +tap.done() diff --git a/tests/config/tapered/test/like-unlike-result.txt b/tests/config/tapered/test/like-unlike-result.txt new file mode 100644 index 0000000..f61aac2 --- /dev/null +++ b/tests/config/tapered/test/like-unlike-result.txt @@ -0,0 +1,13 @@ +ok 1 - ok - like('sat', 'sat') +not ok 2 - not ok - like('sat', 'bbb') +# Trouble in like-unlike-test.lua around line 8 +ok 3 - ok - unlike('sat', 'q') +not ok 4 - not ok - unlike('q', 'q') +# Trouble in like-unlike-test.lua around line 10 +ok 5 - ok - like(' sat', '%s+sat') +ok 6 - ok - like('934', '%d%d%d') +ok 7 - ok - like('934', '%d%d') +not ok 8 - not ok - like('934', '%d%s') +# Trouble in like-unlike-test.lua around line 14 +ok 9 - ok - unlike('934', '%d%s') +1..9 diff --git a/tests/config/tapered/test/like-unlike-test.lua b/tests/config/tapered/test/like-unlike-test.lua new file mode 100755 index 0000000..ab48ca7 --- /dev/null +++ b/tests/config/tapered/test/like-unlike-test.lua @@ -0,0 +1,16 @@ +package.path = '../src/?.lua;' .. package.path +local tap = require 'tapered' + +--- like and unlike +-- like(string, pattern, [msg]) tests if the pattern matches the string +-- unlike(string, pattern, [msg]) tests if the pattern does not match the string +tap.like('sat', 'sat', "ok - like('sat', 'sat')") +tap.like('sat', 'bbb', "not ok - like('sat', 'bbb')") +tap.unlike('sat', 'q', "ok - unlike('sat', 'q')") +tap.unlike('q', 'q', "not ok - unlike('q', 'q')") +tap.like(' sat', '%s+sat', "ok - like(' sat', '%s+sat')") +tap.like('934', '%d%d%d', "ok - like('934', '%d%d%d')") +tap.like('934', '%d%d', "ok - like('934', '%d%d')") +tap.like('934', '%d%s', "not ok - like('934', '%d%s')") +tap.unlike('934', '%d%s', "ok - unlike('934', '%d%s')") +tap.done() diff --git a/tests/config/tapered/test/ok-nok-result.txt b/tests/config/tapered/test/ok-nok-result.txt new file mode 100644 index 0000000..ef45c6a --- /dev/null +++ b/tests/config/tapered/test/ok-nok-result.txt @@ -0,0 +1,7 @@ +ok 1 - ok - ok(true) +not ok 2 - not ok - ok(false) +# Trouble in ok-nok-test.lua around line 8 +ok 3 - ok - nok(false) +not ok 4 - not ok - nok(true) +# Trouble in ok-nok-test.lua around line 10 +1..4 diff --git a/tests/config/tapered/test/ok-nok-test.lua b/tests/config/tapered/test/ok-nok-test.lua new file mode 100755 index 0000000..c2a0b4d --- /dev/null +++ b/tests/config/tapered/test/ok-nok-test.lua @@ -0,0 +1,11 @@ +package.path = '../src/?.lua;' .. package.path +local tap = require 'tapered' + +--- ok and nok +-- ok(exp, [msg]) tests if exp returns (or is) a truthy value. +-- nok(exp, [msg]) tests if exp returns (or is) a falsey value. +tap.ok(true, 'ok - ok(true)') +tap.ok(false, 'not ok - ok(false)') +tap.nok(false, 'ok - nok(false)') +tap.nok(true, 'not ok - nok(true)') +tap.done() diff --git a/tests/config/tapered/test/pass-fail-result.txt b/tests/config/tapered/test/pass-fail-result.txt new file mode 100644 index 0000000..8c29e66 --- /dev/null +++ b/tests/config/tapered/test/pass-fail-result.txt @@ -0,0 +1,4 @@ +ok 1 - ok - No test: just pass +not ok 2 - not ok - No test: just fail +# Trouble in pass-fail-test.lua around line 10 +1..2 diff --git a/tests/config/tapered/test/pass-fail-test.lua b/tests/config/tapered/test/pass-fail-test.lua new file mode 100755 index 0000000..0f2418a --- /dev/null +++ b/tests/config/tapered/test/pass-fail-test.lua @@ -0,0 +1,11 @@ +package.path = '../src/?.lua;' .. package.path +local tap = require 'tapered' + +--- pass and fail +-- pass([msg]) is not a test. It always passes. +-- fail([msg]) is not a test. It always fails. +-- These two methods are useful for checking the basic setup of a test suite. +-- Also, pass can be used as a quasi-skip and fail as a quasi-TODO. +tap.pass('ok - No test: just pass') +tap.fail('not ok - No test: just fail') +tap.done() diff --git a/tests/config/tapered/test/result_test03.txt b/tests/config/tapered/test/result_test03.txt new file mode 100644 index 0000000..58c066c --- /dev/null +++ b/tests/config/tapered/test/result_test03.txt @@ -0,0 +1,55 @@ +ok 1 - Test ok on true +not ok 2 - Test ok on false +# Trouble in test03-allfuncs.lua around line 9 +ok 3 - Test nok on false +not ok 4 - Test nok on true +# Trouble in test03-allfuncs.lua around line 11 +ok 5 - Test is on 2 + 1 = 3 +not ok 6 - Test is on 2 + 2 = 3 +# Trouble in test03-allfuncs.lua around line 17 +ok 7 - Test isnt on 2 + 2 = 3 +not ok 8 - Test isnt on 2 + 2 = 4 +# Trouble in test03-allfuncs.lua around line 19 +ok 9 - Test same on two empty tables +ok 10 - Test same on two identical, simple tables +not ok 11 - Test same on two simple non-identical tables +# Trouble in test03-allfuncs.lua around line 36 +ok 12 - Test same on two identical, nested tables +ok 13 - Test same on identical, array-like tables +not ok 14 - Test same on two non-identical, array-like tables +# Trouble in test03-allfuncs.lua around line 43 +ok 15 - Test same on two identical, hash-like tables +not ok 16 - Test same on two non-identical, hash-like tables +# Trouble in test03-allfuncs.lua around line 65 +ok 17 - Test same on two identical tables with functions as values +not ok 18 - Test same on two non-identical tables with functions as values +# Trouble in test03-allfuncs.lua around line 74 +ok 19 - Test same on two dissimilar tables that share .__eq => true +not ok 20 - Test same: first table .__eq => true, second => false +# Trouble in test03-allfuncs.lua around line 89 +not ok 21 - Test same: first table .__eq => false, second => true +# Trouble in test03-allfuncs.lua around line 90 +not ok 22 - Test same on two similar tables where first .__eq => true +# Trouble in test03-allfuncs.lua around line 91 +not ok 23 - Test same on two similar tables where second .__eq => true +# Trouble in test03-allfuncs.lua around line 92 +ok 24 - Test like with string 'sat' and pattern 'sat' +not ok 25 - Test like with string 'sat' and pattern 'bbb' +# Trouble in test03-allfuncs.lua around line 98 +ok 26 - Test unlike with string 'sat' and pattern 'q' +not ok 27 - Test unlike with string 'q' and pattern 'q' +# Trouble in test03-allfuncs.lua around line 100 +ok 28 - Test like with string ' sat' and pattern '%s+sat' +ok 29 - Test like with string '934' and pattern '%d%d%d' +ok 30 - Test like with string '934' and pattern '%d%d' +ok 31 - Test unlike with string '934' and pattern '%d%s' +ok 32 - No test: just pass +not ok 33 - No test: just fail +# Trouble in test03-allfuncs.lua around line 112 +not ok 34 - Test boom with a method that throws no exception +# Trouble in test03-allfuncs.lua around line 123 +ok 35 - Test boom with a method that throws an exception "Kaboom!" +# Got this error: +# Kaboom! +1..35 +# Bad plan. You planned 43 tests but ran 35 diff --git a/tests/config/tapered/test/runner.bash b/tests/config/tapered/test/runner.bash new file mode 100755 index 0000000..f7f38fc --- /dev/null +++ b/tests/config/tapered/test/runner.bash @@ -0,0 +1,71 @@ +#!/usr/bin/env bats + +@test "ignition!" { + run true + [ "$status" -eq 0 ] + [ "$output" = "" ] +} + +@test "ok and nok" { + run lua -lluacov ok-nok-test.lua + [ "$status" -eq 2 ] + [ "$output" = "$(cat ok-nok-result.txt)" ] +} + +@test "is and isnt" { + run lua -lluacov is-isnt-test.lua + [ "$status" -eq 13 ] + [ "$output" = "$(cat is-isnt-result.txt)" ] +} + +@test "same" { + run lua -lluacov same-test.lua + [ "$status" -eq 10 ] + [ "$output" = "$(cat same-result.txt)" ] +} + +@test "like and unlike" { + run lua -lluacov like-unlike-test.lua + [ "$status" -eq 3 ] + [ "$output" = "$(cat like-unlike-result.txt)" ] +} + +@test "pass and fail" { + run lua -lluacov pass-fail-test.lua + [ "$status" -eq 1 ] + [ "$output" = "$(cat pass-fail-result.txt)" ] +} + +@test "boom" { + run lua -lluacov boom-test.lua + [ "$status" -eq 1 ] + # This is foul, but choices are limited. Error messages for Lua 5.3 + # are different, so I need to look at the output but NOT the errors. + [ "$(grep -v '^#' <<< "$output")" = "$(cat boom-result.txt | grep -v '^#')" ] +} + +@test "done success" { + run lua -lluacov done-success-test.lua + [ "$status" -eq 0 ] + [ "$output" = "$(cat done-success-result.txt)" ] +} + +@test "done failure" { + run lua -lluacov done-failure-test.lua + [ "$status" -eq 1 ] + [ "$output" = "$(cat done-failure-result.txt)" ] +} + +@test "exit status" { + run lua -lluacov exit-success-test.lua + [ "$status" -eq 0 ] + + run lua -lluacov exit-failure-test.lua + [ "$status" -eq 1 ] +} + +@test "informational fields" { + run lua -lluacov informational-fields-test.lua + [ "$status" -eq 0 ] + [ "$output" = "$(cat informational-fields-result.txt)" ] +} diff --git a/tests/config/tapered/test/same-result.txt b/tests/config/tapered/test/same-result.txt new file mode 100644 index 0000000..c77a5a4 --- /dev/null +++ b/tests/config/tapered/test/same-result.txt @@ -0,0 +1,31 @@ +ok 1 - ok - same({}, {} +ok 2 - ok - same({1,2,3}, {1,2,3}) +not ok 3 - not ok - same({1}, {}) +# Trouble in same-test.lua around line 7 +ok 4 - ok - same({{1}, 2, {3,4}}, {{1}, 2, {3,4}) +ok 5 - ok - same({"Monday", "Tuesday"}, {"Monday", "Tuesday"}) +not ok 6 - not ok - same({"Monday", "Tuesday"}, {"Monday", "Tuesday", "Wednesday"}) +# Trouble in same-test.lua around line 15 +ok 7 - ok - same({Monday = 1}, {Monday = 1}) +not ok 8 - not ok - same({Monday = 1}, {Monday = 1, Tuesday = 2}) +# Trouble in same-test.lua around line 29 +ok 9 - ok - same({m = {1,2}, n = {1,2}}, {m = {1,2}, n = {1,2}}) +not ok 10 - not ok - same({m = {1,2}, n = {1,2}}, {m = {1,2}, n = {1,2,3}}) +# Trouble in same-test.lua around line 36 +not ok 11 - not ok - same({m = {1,2}, n = {1,2,3}}, {m = {1,2}, n = {1,2}}) +# Trouble in same-test.lua around line 37 +ok 12 - ok - same({p = print, a = assert}, {p = print, a = assert}) +not ok 13 - not ok - same({p = print, a = assert}, {p = print, a = assert, e = error}) +# Trouble in same-test.lua around line 44 +ok 14 - ok - same({4, s=4}, {6, s=4},__eq => x[s] and y[s] are even) +ok 15 - ok - same({6, s=8}, {4, s=4},__eq => x[s] and y[s] are even) +not ok 16 - not ok - same({4, s=4}, {4, s=3},__eq => x[s] and y[s] are even) +# Trouble in same-test.lua around line 61 +not ok 17 - not ok - same({4, s=4}, {4, s=3},__eq => x[s] and y[s] are even) +# Trouble in same-test.lua around line 63 +not ok 18 - not ok - same({4, s=4}, {6, s=4},__eq => x[s] is even, y[s] odd) +# Trouble in same-test.lua around line 68 +ok 19 - ok - same({4, s=4}, {4, s=3},__eq => x[s] is even, y[s] odd) +not ok 20 - not ok - same({4, s=3}, {4, s=4},__eq => x[s] is even, y[s] odd) +# Trouble in same-test.lua around line 72 +1..20 diff --git a/tests/config/tapered/test/same-test.lua b/tests/config/tapered/test/same-test.lua new file mode 100644 index 0000000..68c3574 --- /dev/null +++ b/tests/config/tapered/test/same-test.lua @@ -0,0 +1,74 @@ +package.path = '../src/?.lua;' .. package.path +local tap = require 'tapered' +-- luacheck: compat + +tap.same({},{}, 'ok - same({}, {}') +tap.same({1,2,3}, {1,2,3}, 'ok - same({1,2,3}, {1,2,3})') +tap.same({1},{}, 'not ok - same({1}, {})') +tap.same({{1}, 2, {3,4}},{{1}, 2, {3,4}}, + 'ok - same({{1}, 2, {3,4}}, {{1}, 2, {3,4})') + +local days1 = { 'Monday', 'Tuesday' } +local days2 = { 'Monday', 'Tuesday' } +tap.same(days1, days2, 'ok - same({"Monday", "Tuesday"}, {"Monday", "Tuesday"})') +local days3 = { 'Monday', 'Tuesday', 'Wednesday', } +tap.same(days2, days3, + 'not ok - same({"Monday", "Tuesday"}, {"Monday", "Tuesday", "Wednesday"})') + +local hash1 = { + Monday = 1, +} +local hash2 = { + Monday = 1, +} +local hash3 = { + Monday = 1, + Tuesday = 2, +} +tap.same(hash1, hash2, 'ok - same({Monday = 1}, {Monday = 1})') +tap.same(hash1, hash3, + 'not ok - same({Monday = 1}, {Monday = 1, Tuesday = 2})') + +local n1 = { m = { 1, 2 }, n = { 1, 2 } } +local n2 = { m = { 1, 2 }, n = { 1, 2 } } +local n3 = { m = { 1, 2 }, n = { 1, 2, 3 } } +tap.same(n1, n2, 'ok - same({m = {1,2}, n = {1,2}}, {m = {1,2}, n = {1,2}})') +tap.same(n1, n3, 'not ok - same({m = {1,2}, n = {1,2}}, {m = {1,2}, n = {1,2,3}})') +tap.same(n3, n1, 'not ok - same({m = {1,2}, n = {1,2,3}}, {m = {1,2}, n = {1,2}})') + +local method_table1 = { p = print, a = assert } +local method_table2 = { p = print, a = assert } +local method_table3 = { p = print, a = assert, e = error } +tap.same(method_table1, method_table2, + 'ok - same({p = print, a = assert}, {p = print, a = assert})') +tap.same(method_table1, method_table3, + 'not ok - same({p = print, a = assert}, {p = print, a = assert, e = error})') + +local foo = {4, s = 4} +local bar = {6, s = 8} +local oof = {4, s = 3} +local mt1 = {} +local mt2 = {} +local evens = function (x, y) return x['s'] % 2 == 0 and y['s'] % 2 == 0 end +local even_odd = function (x, y) return x['s'] % 2 == 0 and y['s'] % 2 ~= 0 end +mt1.__eq = evens +mt2.__eq = even_odd +setmetatable(foo, mt1) +setmetatable(bar, mt1) +setmetatable(oof, mt1) +tap.same(foo, bar, 'ok - same({4, s=4}, {6, s=4},__eq => x[s] and y[s] are even)') +tap.same(bar, foo, 'ok - same({6, s=8}, {4, s=4},__eq => x[s] and y[s] are even)') +tap.same(foo, oof, + 'not ok - same({4, s=4}, {4, s=3},__eq => x[s] and y[s] are even)') +tap.same(oof, foo, + 'not ok - same({4, s=4}, {4, s=3},__eq => x[s] and y[s] are even)') +setmetatable(foo, mt2) +setmetatable(bar, mt2) +setmetatable(oof, mt2) +tap.same(foo, bar, + 'not ok - same({4, s=4}, {6, s=4},__eq => x[s] is even, y[s] odd)') +tap.same(foo, oof, + 'ok - same({4, s=4}, {4, s=3},__eq => x[s] is even, y[s] odd)') +tap.same(oof, foo, + 'not ok - same({4, s=3}, {4, s=4},__eq => x[s] is even, y[s] odd)') +tap.done() diff --git a/tests/config/tapered/test/setup-teardown-result.txt b/tests/config/tapered/test/setup-teardown-result.txt new file mode 100644 index 0000000..c5d5668 --- /dev/null +++ b/tests/config/tapered/test/setup-teardown-result.txt @@ -0,0 +1,4 @@ +# I'm a little teapot. +ok 1 - Short and stout. +# Here is my handle, and here is my spout. +1..1 diff --git a/tests/config/tapered/test/setup-teardown-test.lua b/tests/config/tapered/test/setup-teardown-test.lua new file mode 100755 index 0000000..974a4aa --- /dev/null +++ b/tests/config/tapered/test/setup-teardown-test.lua @@ -0,0 +1,14 @@ +package.path = '../src/?.lua;' .. package.path +local tap = require 'tapered' + +-- luacheck: globals setup teardown +function setup() + print("# I'm a little teapot.") +end + +function teardown() + print("# Here is my handle, and here is my spout.") +end + +tap.ok(true, "Short and stout.") +tap.done() |