mirror of
https://github.com/zunit-zsh/zunit.git
synced 2026-09-10 06:36:15 -04:00
Compare commits
No commits in common. "master" and "v0.7.0" have entirely different histories.
61
.travis.yml
61
.travis.yml
|
|
@ -7,53 +7,20 @@ addons:
|
|||
- yodl
|
||||
- man
|
||||
dist: trusty
|
||||
language: generic
|
||||
cache:
|
||||
apt: true
|
||||
directories:
|
||||
- "$HOME/.zvm"
|
||||
jobs:
|
||||
matrix:
|
||||
include:
|
||||
- stage: linux
|
||||
os: linux
|
||||
env: ZVM_VERSION='4.3.12'
|
||||
- os: linux
|
||||
env: ZVM_VERSION='4.3.17'
|
||||
- os: linux
|
||||
env: ZVM_VERSION='5.0.8'
|
||||
- os: linux
|
||||
env: ZVM_VERSION='5.1.1'
|
||||
- os: linux
|
||||
env: ZVM_VERSION='5.2'
|
||||
- os: linux
|
||||
env: ZVM_VERSION='5.3.1'
|
||||
- stage: mac os
|
||||
os: osx
|
||||
env: ZVM_VERSION='5.0.8'
|
||||
- os: osx
|
||||
env: ZVM_VERSION='5.1.1'
|
||||
- os: osx
|
||||
env: ZVM_VERSION='5.2'
|
||||
- os: osx
|
||||
env: ZVM_VERSION='5.3.1'
|
||||
- stage: deploy
|
||||
script: skip
|
||||
deploy:
|
||||
provider: releases
|
||||
api_key:
|
||||
secure: JudjZ9Ou15GKmgOga6qpcxtCKITpq+EnGCUvNAGefuuG/etxSAEdXQfjmC4VBzCAC9Pn1gkABFAASUtZdZ5xxXhxkuU/lTopJxWG2tdxNuvW/wflZNGdnxgWA1PcYptKrLoDRLzUpDtsnnvD75mMvAR8+YjRJk76gWVM02we2JR8WKcD1bchQiqzc7CK2X4kDL6zRayYpwFnFKhA8bTlIEJ36k92liTeW8VNwg+9CAsM2zjWpCKmLXrecNl3e5sO+4ssGU+J4gnWYSC112oEzLJzm3cYsEj8dTuFtVHby1DrLrpW1fPQdF1h1cwjHtQkbKTF5vrNKcCmSGcFxA2YbMu8aMdkEZmwN8JvShFamyyYHi90UTyv8PQ/WYER143zGZinZ2VeSaIlFEvH7R/sbS6t4DjbXV7rHF9Zbg0d3D7p71kNDpbtH1dkX6KXxtqCOOVRwAMhwRJ6c7VCXwj0AZEr6YrqZucPjbLTn9NVtI0WPZPOIL/HhyB6vzB1zunmjQERmcwNcC3gR47mmOPWfh1XaCpIurrZKjF+SfH/mDN6Tr24a9oeae6+subI5LW9G1qP2/GmibDVmlX+F1jE4xxKr6sIrzB/DLdYVtiSnzAmquZnGNunUCOMB6DN4nCajh9X3O/e2DzKImHSHZyYIThytSNyMs885ZBbev6F850=
|
||||
file:
|
||||
- zunit
|
||||
- zunit.zsh-completion
|
||||
skip_cleanup: true
|
||||
on:
|
||||
tags: true
|
||||
- env: ZVM_VERSION='4.3.12'
|
||||
- env: ZVM_VERSION='4.3.17'
|
||||
- env: ZVM_VERSION='5.0.8'
|
||||
- env: ZVM_VERSION='5.1.1'
|
||||
- env: ZVM_VERSION='5.2'
|
||||
- env: ZVM_VERSION='5.3.1'
|
||||
before_script:
|
||||
- if [[ $(ls "$HOME/.zvm" | wc -l) -eq 0 ]]; then rm -rf "$HOME/.zvm"; fi
|
||||
- mkdir .bin
|
||||
- curl -L https://raw.githubusercontent.com/molovo/revolver/master/revolver > .bin/revolver
|
||||
- curl -L https://raw.githubusercontent.com/molovo/color/master/color.zsh > .bin/color
|
||||
- curl -L https://raw.githubusercontent.com/molovo/zvm/master/zvm > .bin/zvm
|
||||
- curl -L https://raw.githubusercontent.com/molovo/zvm/master/zvm-shell-integration.zsh > zvm-shell-integration.zsh
|
||||
- chmod u+x .bin/{color,revolver,zvm}
|
||||
- export PATH="$HOME/.zvm/bin:$PWD/.bin:$PATH"
|
||||
- zvm use ${ZVM_VERSION}
|
||||
|
|
@ -61,5 +28,13 @@ before_script:
|
|||
script: "./zunit"
|
||||
notifications:
|
||||
email: false
|
||||
slack:
|
||||
secure: gYbqJKOiko4AKjIY+68CxDPCyRQl22rdodRq55Wj745/ljyY5AQ8i3/Pvds19z2waX2ti232hWOczG09huYloTIDuiKNCqeedKVQQvThSqLW/8zYo1ETbOb09OPu6e68u8EAoPiwXeY56AqFEa5J3RBXP0cXl6EI9m1aL+LvGzV6AI149vh35Fib3a6Cr1JMspjf/iXf5LO9JI3YvdPI5xWGfjuqf7BWoJuQXsAIWtrpy9rHV1jfCFQNMuefwJruU0DbGEhW1er0HVWw4Sm8xP2BnIGoPDpqHUALaGs6RYBdsHTMUq9TjXVYNiYymvlpU4KpfUxOBQx8vIzzBwWjGua9YZsUMPxRw+ShVBnfVzMG/sGqG9zLSDMbMNiy5NXi9JxZi87/s9/7gUMWZqVXBucJ7L/xRr6xv/UTKe1Ur+Tb2FkZewWxkW3w8VU1uW5TgD1e72aeMHm+hXuBnKORIUB/BrNIYvfiUuKTMNZ6P78TgwGwe8BWA1NmqTwsyQip6OU7+OW5VYmB6Kv8YMZ87RtLTS6kPn2W5T+5wEYqTAMH4a1nbFglmM5Qu6i6Vf6Fhr05+YJtUToBQsB929VIqKVOlDYK8mMuS7K/B3dMSA/BjAgFQWDKaacGbM65PDhOZZTB6uTht9qvbxX0hLc7aU3Bj8Y7TRenv+BJwA26fnU=
|
||||
deploy:
|
||||
provider: releases
|
||||
api_key:
|
||||
secure: JudjZ9Ou15GKmgOga6qpcxtCKITpq+EnGCUvNAGefuuG/etxSAEdXQfjmC4VBzCAC9Pn1gkABFAASUtZdZ5xxXhxkuU/lTopJxWG2tdxNuvW/wflZNGdnxgWA1PcYptKrLoDRLzUpDtsnnvD75mMvAR8+YjRJk76gWVM02we2JR8WKcD1bchQiqzc7CK2X4kDL6zRayYpwFnFKhA8bTlIEJ36k92liTeW8VNwg+9CAsM2zjWpCKmLXrecNl3e5sO+4ssGU+J4gnWYSC112oEzLJzm3cYsEj8dTuFtVHby1DrLrpW1fPQdF1h1cwjHtQkbKTF5vrNKcCmSGcFxA2YbMu8aMdkEZmwN8JvShFamyyYHi90UTyv8PQ/WYER143zGZinZ2VeSaIlFEvH7R/sbS6t4DjbXV7rHF9Zbg0d3D7p71kNDpbtH1dkX6KXxtqCOOVRwAMhwRJ6c7VCXwj0AZEr6YrqZucPjbLTn9NVtI0WPZPOIL/HhyB6vzB1zunmjQERmcwNcC3gR47mmOPWfh1XaCpIurrZKjF+SfH/mDN6Tr24a9oeae6+subI5LW9G1qP2/GmibDVmlX+F1jE4xxKr6sIrzB/DLdYVtiSnzAmquZnGNunUCOMB6DN4nCajh9X3O/e2DzKImHSHZyYIThytSNyMs885ZBbev6F850=
|
||||
file:
|
||||
- zunit
|
||||
- zunit.zsh-completion
|
||||
skip_cleanup: true
|
||||
on:
|
||||
tags: true
|
||||
|
|
|
|||
|
|
@ -6,4 +6,3 @@ directories:
|
|||
time_limit: 15
|
||||
fail_fast: true
|
||||
allow_risky: false
|
||||
verbose: false
|
||||
|
|
|
|||
33
README.md
33
README.md
|
|
@ -1,12 +1,12 @@
|
|||

|
||||

|
||||
|
||||
[](https://github.com/zunit-zsh/zunit/releases/latest) [](https://travis-ci.org/zunit-zsh/zunit) [](https://gitter.im/zunit-zsh/zunit?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
[](https://travis-ci.org/molovo/zunit) [](https://gitter.im/molovo/zunit?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
|
||||
ZUnit is a powerful unit testing framework for ZSH
|
||||
|
||||
## Installation
|
||||
|
||||
> **WARNING**: Although the majority of ZUnit's functionality works as expected, it is in the early stages of development, and as such bugs are likely to be present. Please continue with caution, and [report any issues](https://github.com/zunit-zsh/zunit/issues/new) you may have.
|
||||
> **WARNING**: Although the majority of ZUnit's functionality works as expected, it is in the early stages of development, and as such bugs are likely to be present. Please continue with caution, and [report any issues](https://github.com/molovo/zunit/issues/new) you may have.
|
||||
|
||||
### [Zulu](https://github.com/zulu-zsh/zulu)
|
||||
|
||||
|
|
@ -21,39 +21,18 @@ zulu install zunit
|
|||
./build.zsh
|
||||
zulu link zunit
|
||||
```
|
||||
|
||||
### [zplug](https://github.com/zplug/zplug)
|
||||
|
||||
ZUnit and its dependencies can all be installed with zplug.
|
||||
|
||||
```sh
|
||||
zplug 'molovo/revolver', \
|
||||
as:command, \
|
||||
use:revolver
|
||||
zplug 'zunit-zsh/zunit', \
|
||||
as:command, \
|
||||
use:zunit, \
|
||||
hook-build:'./build.zsh'
|
||||
```
|
||||
|
||||
|
||||
### Homebrew
|
||||
|
||||
```sh
|
||||
brew install zunit-zsh/zunit/zunit
|
||||
```
|
||||
|
||||
### Manual
|
||||
|
||||
```sh
|
||||
git clone https://github.com/zunit-zsh/zunit
|
||||
git clone https://github.com/molovo/zunit
|
||||
cd ./zunit
|
||||
./build.zsh
|
||||
chmod u+x ./zunit
|
||||
cp ./zunit /usr/local/bin
|
||||
```
|
||||
|
||||
> ZUnit requires [Revolver](https://github.com/molovo/revolver) to be installed, and in your `$PATH`. The zulu or homebrew installation methods will install this dependency for you.
|
||||
> ZUnit requires the utilities [Color](https://github.com/molovo/color) and [Revolver](https://github.com/molovo/revolver) to be installed, and in your `$PATH`. The zulu installation method will install these dependencies for you.
|
||||
|
||||
## Writing Tests
|
||||
|
||||
|
|
@ -73,7 +52,7 @@ The body of each test can contain any valid ZSH code. The zunit shebang `#!/usr/
|
|||
|
||||
## Documentation
|
||||
|
||||
For a full breakdown of ZUnit's syntax and functionality, check out the [official documentation](https://zunit.xyz/docs/).
|
||||
For a full breakdown of ZUnit's syntax and functionality, check out the [official documentation](https://molovo.co/zunit/docs).
|
||||
|
||||
## Contributing
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ Please note that this project is released with a [Contributor Code of Conduct](c
|
|||
|
||||
As a user of ZUnit you're the perfect candidate to help us improve our documentation. Typo corrections, error fixes, better explanations, more examples, etc. Open issues for things that could be improved. Anything. Even improvements to this document.
|
||||
|
||||
Use the [`docs` label](https://github.com/zunit-zsh/zunit/labels/docs) to find suggestions for what we'd love to see more documentation on.
|
||||
Use the [`docs` label](https://github.com/molovo/zunit/labels/docs) to find suggestions for what we'd love to see more documentation on.
|
||||
|
||||
### Improve issues
|
||||
|
||||
|
|
@ -20,30 +20,30 @@ Some issues are created with missing information, not reproducible, or plain inv
|
|||
|
||||
We're always looking for more opinions on discussions in the issue tracker. It's a good opportunity to influence the future direction of ZUnit.
|
||||
|
||||
The [`question` label](https://github.com/zunit-zsh/zunit/labels/question) is a good place to find ongoing discussions.
|
||||
The [`question` label](https://github.com/molovo/zunit/labels/question) is a good place to find ongoing discussions.
|
||||
|
||||
### Write code
|
||||
|
||||
You can use issue labels to discover issues you could help out with:
|
||||
|
||||
* [`blocked` issues](https://github.com/zunit-zsh/zunit/labels/blocked) need help getting unstuck
|
||||
* [`bug` issues](https://github.com/zunit-zsh/zunit/labels/bug) are known bugs we'd like to fix
|
||||
* [`enhancement` issues](https://github.com/zunit-zsh/zunit/labels/enhancement) are features we're open to including
|
||||
* [`performance` issues](https://github.com/zunit-zsh/zunit/labels/performance) track ideas on how to improve ZUnit’s performance
|
||||
* [`blocked` issues](https://github.com/molovo/zunit/labels/blocked) need help getting unstuck
|
||||
* [`bug` issues](https://github.com/molovo/zunit/labels/bug) are known bugs we'd like to fix
|
||||
* [`enhancement` issues](https://github.com/molovo/zunit/labels/enhancement) are features we're open to including
|
||||
* [`performance` issues](https://github.com/molovo/zunit/labels/performance) track ideas on how to improve ZUnit’s performance
|
||||
|
||||
The [`help wanted`](https://github.com/zunit-zsh/zunit/labels/help%20wanted) and [`good for beginner`](https://github.com/zunit-zsh/zunit/labels/good%20for%20beginner) labels are especially useful.
|
||||
The [`help wanted`](https://github.com/molovo/zunit/labels/help%20wanted) and [`good for beginner`](https://github.com/molovo/zunit/labels/good%20for%20beginner) labels are especially useful.
|
||||
|
||||
You may find an issue is assigned, or has the [`assigned` label](https://github.com/zunit-zsh/zunit/labels/assigned). Please double-check before starting on this issue because somebody else is likely already working on it.
|
||||
You may find an issue is assigned, or has the [`assigned` label](https://github.com/molovo/zunit/labels/assigned). Please double-check before starting on this issue because somebody else is likely already working on it.
|
||||
|
||||
We'd like to fix [`priority` issues](https://github.com/zunit-zsh/zunit/labels/priority) first. We'd love to see progress on [`low-priority` issues](https://github.com/zunit-zsh/zunit/labels/low%20priority) too. [`future` issues](https://github.com/zunit-zsh/zunit/labels/future) are those that we'd like to get to, but not anytime soon. Please check before working on these since we may not yet want to take on the burden of supporting those features.
|
||||
We'd like to fix [`priority` issues](https://github.com/molovo/zunit/labels/priority) first. We'd love to see progress on [`low-priority` issues](https://github.com/molovo/zunit/labels/low%20priority) too. [`future` issues](https://github.com/molovo/zunit/labels/future) are those that we'd like to get to, but not anytime soon. Please check before working on these since we may not yet want to take on the burden of supporting those features.
|
||||
|
||||
### Hang out in our chat
|
||||
|
||||
We have a [chat](https://gitter.im/zunit-zsh/zunit). Jump in there and lurk, talk to us, and help others.
|
||||
We have a [chat](https://gitter.im/molovo/zunit). Jump in there and lurk, talk to us, and help others.
|
||||
|
||||
## Submitting an issue
|
||||
|
||||
- The issue tracker is for issues. Use our [chat](https://gitter.im/zunit-zsh/zunit) for support.
|
||||
- The issue tracker is for issues. Use our [chat](https://gitter.im/molovo/zunit) for support.
|
||||
- Search the issue tracker before opening an issue.
|
||||
- Ensure you're using the latest version of ZUnit.
|
||||
- Use a clear and descriptive title.
|
||||
|
|
@ -53,8 +53,6 @@ We have a [chat](https://gitter.im/zunit-zsh/zunit). Jump in there and lurk, tal
|
|||
|
||||
## Submitting a pull request
|
||||
|
||||
- Most pull requests should target the `next` branch, so they can be included in the next release.
|
||||
- Urgent bug fixes may be targeted to the `master` branch, and a new patch release will be created immediately after they are merged. If in doubt, ask.
|
||||
- Non-trivial changes are often best discussed in an issue first, to prevent you from doing unnecessary work.
|
||||
- For ambitious tasks, you should try to get your work in front of the community for feedback as soon as possible. Open a pull request as soon as you have done the minimum needed to demonstrate your idea. At this early stage, don't worry about making things perfect, or 100% complete. Add a [WIP] prefix to the title, and describe what you still need to do. This lets reviewers know not to nit-pick small details or point out improvements you already know you need to make.
|
||||
- New features should be accompanied with tests and documentation.
|
||||
|
|
|
|||
|
|
@ -2,54 +2,6 @@
|
|||
# Internal assertion functions #
|
||||
################################
|
||||
|
||||
###
|
||||
# Assert one string is a substring of another
|
||||
###
|
||||
function _zunit_assert_is_substring_of() {
|
||||
local value=$1 comparison=$2
|
||||
|
||||
[[ "$comparison" = *"$value"* ]] && return 0
|
||||
|
||||
echo "'$value' is not a substring of '$comparison'"
|
||||
exit 1
|
||||
}
|
||||
|
||||
###
|
||||
# Assert one string is not a substring of another
|
||||
###
|
||||
function _zunit_assert_is_not_substring_of() {
|
||||
local value=$1 comparison=$2
|
||||
|
||||
[[ "$comparison" != *"$value"* ]] && return 0
|
||||
|
||||
echo "'$value' is a substring of '$comparison'"
|
||||
exit 1
|
||||
}
|
||||
|
||||
###
|
||||
# Assert one string contains another
|
||||
###
|
||||
function _zunit_assert_contains() {
|
||||
local value=$1 comparison=$2
|
||||
|
||||
[[ "$value" = *"$comparison"* ]] && return 0
|
||||
|
||||
echo "'$value' does not contain '$comparison'"
|
||||
exit 1
|
||||
}
|
||||
|
||||
###
|
||||
# Assert one string does not contain another
|
||||
###
|
||||
function _zunit_assert_does_not_contain() {
|
||||
local value=$1 comparison=$2
|
||||
|
||||
[[ "$value" != *"$comparison"* ]] && return 0
|
||||
|
||||
echo "'$value' contains '$comparison'"
|
||||
exit 1
|
||||
}
|
||||
|
||||
###
|
||||
# Assert that two integers are equal
|
||||
###
|
||||
|
|
@ -74,54 +26,6 @@ function _zunit_assert_not_equal_to() {
|
|||
exit 1
|
||||
}
|
||||
|
||||
###
|
||||
# Assert that an integer is positive
|
||||
###
|
||||
function _zunit_assert_is_positive() {
|
||||
local value=$1 comparison=$2
|
||||
|
||||
[[ $value -gt 0 ]] && return 0
|
||||
|
||||
echo "'$value' is not positive"
|
||||
exit 1
|
||||
}
|
||||
|
||||
###
|
||||
# Assert that an integer is negative
|
||||
###
|
||||
function _zunit_assert_is_negative() {
|
||||
local value=$1 comparison=$2
|
||||
|
||||
[[ $value -lt 0 ]] && return 0
|
||||
|
||||
echo "'$value' is not negative"
|
||||
exit 1
|
||||
}
|
||||
|
||||
###
|
||||
# Assert that an integer is greater than the comparison
|
||||
###
|
||||
function _zunit_assert_is_greater_than() {
|
||||
local value=$1 comparison=$2
|
||||
|
||||
[[ $value -gt $comparison ]] && return 0
|
||||
|
||||
echo "'$value' is not greater than '$comparison'"
|
||||
exit 1
|
||||
}
|
||||
|
||||
###
|
||||
# Assert that an integer is less than the comparison
|
||||
###
|
||||
function _zunit_assert_is_less_than() {
|
||||
local value=$1 comparison=$2
|
||||
|
||||
[[ $value -lt $comparison ]] && return 0
|
||||
|
||||
echo "'$value' is not less than '$comparison'"
|
||||
exit 1
|
||||
}
|
||||
|
||||
###
|
||||
# Assert that two string are the same
|
||||
###
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ allow_risky: false"
|
|||
zsh
|
||||
install:
|
||||
- mkdir .bin
|
||||
- curl -L https://github.com/zunit-zsh/zunit/releases/download/v$(_zunit_version)/zunit > .bin/zunit
|
||||
- curl -L https://github.com/molovo/zunit/releases/download/v$(_zunit_version)/zunit > .bin/zunit
|
||||
- curl -L https://raw.githubusercontent.com/molovo/revolver/master/revolver > .bin/revolver
|
||||
- curl -L https://raw.githubusercontent.com/molovo/color/master/color.zsh > .bin/color
|
||||
before_script:
|
||||
|
|
@ -82,19 +82,19 @@ script: zunit"
|
|||
# Check that a config file doesn't already exist so that
|
||||
# we don't overwrite it
|
||||
if [[ -f "$PWD/.zunit.yml" ]]; then
|
||||
echo $(color yellow "ZUnit config file already exists at $PWD/.zunit.yml. Skipping...")
|
||||
echo $(color red "Zunit config file already exists at $PWD/.zunit.yml") >&2
|
||||
exit 1
|
||||
else
|
||||
# Write the contents to the config file
|
||||
echo "Writing ZUnit config file to $PWD/.zunit.yml"
|
||||
echo "$yaml" > "$PWD/.zunit.yml"
|
||||
fi
|
||||
|
||||
# Check that the tests directory doesn't already exist so that
|
||||
# we don't overwrite it
|
||||
if [[ -d "$PWD/tests" ]]; then
|
||||
echo $(color yellow "Test directory already exists at $PWD/tests. Skipping...")
|
||||
echo $(color red "Directory already exists at $PWD/tests") >&2
|
||||
exit 1
|
||||
else
|
||||
echo "Creating test directory at $PWD/tests"
|
||||
# Create the directory structure for tests
|
||||
mkdir -p tests/_{output,support}
|
||||
touch tests/_{output,support}/.gitkeep
|
||||
|
|
@ -109,9 +109,9 @@ script: zunit"
|
|||
# Check that a travis config doesn't already exist so that
|
||||
# we don't overwrite it
|
||||
if [[ -f "$PWD/.travis.yml" ]]; then
|
||||
echo $(color yellow "Travis config already exists at $PWD/.travis.yml. Skipping...")
|
||||
echo $(color red "Travis config already exists at $PWD/.travis.yml") >&2
|
||||
exit 1
|
||||
else
|
||||
echo "Writing Travis CI config to $PWD/.travis.yml"
|
||||
# Write the contents to the config file
|
||||
echo "$travis_yml" > "$PWD/.travis.yml"
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ function _zunit_run_usage() {
|
|||
echo " -v, --version Output version information and exit"
|
||||
echo " -f, --fail-fast Stop the test runner immediately after the first failure"
|
||||
echo " -t, --tap Output results in a TAP compatible format"
|
||||
echo " --verbose Prints full output from each test"
|
||||
echo " --output-text Print results to a text log, in TAP compatible format"
|
||||
echo " --output-html Print results to a HTML page"
|
||||
echo " --allow-risky Supress warnings generated for risky tests"
|
||||
|
|
@ -25,18 +24,18 @@ function _zunit_run_usage() {
|
|||
# Format a ms timestamp in a human-readable format
|
||||
###
|
||||
function _zunit_human_time() {
|
||||
local ms=$1
|
||||
local tmp=$(( $1 / 1000 ))
|
||||
local days=$(( tmp / 60 / 60 / 24 ))
|
||||
local hours=$(( tmp / 60 / 60 % 24 ))
|
||||
local minutes=$(( tmp / 60 % 60 ))
|
||||
local seconds=$(( tmp % 60 ))
|
||||
local ms=$(( $1 % 1000 ))
|
||||
(( $days > 0 )) && print -n "${days}d "
|
||||
(( $hours > 0 )) && print -n "${hours}h "
|
||||
(( $minutes > 0 )) && print -n "${minutes}m "
|
||||
(( $seconds > 5 )) && print -n "${seconds}s "
|
||||
(( $seconds < 30 )) && (( $seconds > 5 )) && print -n "${ms}ms"
|
||||
(( $seconds <= 5 )) && print -n "${1}ms"
|
||||
(( $seconds < 30 )) && (( $seconds > 5 )) && print -n "$(( ms - $((seconds*1000)) ))ms"
|
||||
(( $tmp <= 5 )) && print -n "${1}ms"
|
||||
}
|
||||
|
||||
###
|
||||
|
|
@ -83,7 +82,7 @@ function _zunit_execute_test() {
|
|||
# defined and the test exits early
|
||||
if (( \$+functions[__zunit_test_teardown] )); then
|
||||
zshexit() {
|
||||
__zunit_test_teardown 2>&1
|
||||
__zunit_test_teardown >/dev/null 2>&1
|
||||
}
|
||||
fi
|
||||
|
||||
|
|
@ -95,7 +94,7 @@ function _zunit_execute_test() {
|
|||
|
||||
# If a setup function is defined, run it now
|
||||
if (( \$+functions[__zunit_test_setup] )); then
|
||||
__zunit_test_setup 2>&1
|
||||
__zunit_test_setup >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
# The test body is printed here, so when we eval the wrapper
|
||||
|
|
@ -104,7 +103,7 @@ function _zunit_execute_test() {
|
|||
|
||||
# If a teardown function is defined, run it now
|
||||
if (( \$+functions[__zunit_test_teardown] )); then
|
||||
__zunit_test_teardown 2>&1
|
||||
__zunit_test_teardown >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
# Remove the error handler
|
||||
|
|
@ -167,7 +166,6 @@ function _zunit_execute_test() {
|
|||
# The kill time has been reached, kill the child process,
|
||||
# and exit the wrapper function
|
||||
kill -9 $pid >/dev/null 2>&1
|
||||
echo "Test took too long to run. Terminated after $time_limit seconds"
|
||||
exit 78
|
||||
fi
|
||||
done
|
||||
|
|
@ -192,20 +190,14 @@ function _zunit_execute_test() {
|
|||
|
||||
return
|
||||
elif [[ $state -eq 78 ]]; then
|
||||
_zunit_error $output
|
||||
_zunit_error "Test took too long to run. Terminated after $time_limit seconds" $output
|
||||
|
||||
return
|
||||
elif [[ -z $allow_risky && $state -eq 248 ]]; then
|
||||
# If --verbose is specified, print test output to screen
|
||||
[[ -n $verbose && -n $output ]] && echo $output
|
||||
|
||||
_zunit_warn 'No assertions were run, test is risky'
|
||||
|
||||
return
|
||||
elif [[ -n $allow_risky && $state -eq 248 ]] || [[ $state -eq 0 ]]; then
|
||||
# If --verbose is specified, print test output to screen
|
||||
[[ -n $verbose && -n $output ]] && echo $output
|
||||
|
||||
_zunit_success
|
||||
|
||||
return
|
||||
|
|
@ -409,7 +401,7 @@ function _zunit_parse_argument() {
|
|||
line=$(cat $argument | head -n 1)
|
||||
|
||||
# Check for the zunit shebang
|
||||
if [[ $line =~ "#! ?/usr/bin/env zunit" ]]; then
|
||||
if [[ $line = "#!/usr/bin/env zunit" ]]; then
|
||||
# Add it to the array
|
||||
testfiles[(( ${#testfiles} + 1 ))]=("$argument${test_name+"@$test_name"}")
|
||||
return
|
||||
|
|
@ -434,7 +426,7 @@ function _zunit_parse_argument() {
|
|||
###
|
||||
function _zunit_run() {
|
||||
local -a arguments testfiles
|
||||
local fail_fast tap allow_risky verbose
|
||||
local fail_fast tap allow_risky
|
||||
local output_text logfile_text output_html logfile_html
|
||||
|
||||
# Load the datetime module, and record the start time
|
||||
|
|
@ -446,7 +438,6 @@ function _zunit_run() {
|
|||
v=version -version=version \
|
||||
f=fail_fast -fail-fast=fail_fast \
|
||||
t=tap -tap=tap \
|
||||
-verbose=verbose \
|
||||
-output-text=output_text \
|
||||
-output-html=output_html \
|
||||
-allow-risky=allow_risky \
|
||||
|
|
@ -529,11 +520,6 @@ function _zunit_run() {
|
|||
allow_risky=1
|
||||
fi
|
||||
|
||||
# Check if verbose is specified in the config or as an option
|
||||
if [[ -z $verbose ]] && [[ "$zunit_config_verbose" = "true" ]]; then
|
||||
verbose=1
|
||||
fi
|
||||
|
||||
# Check if time_limit is specified in the config or as an option
|
||||
if [[ -n $time_limit ]]; then
|
||||
shift time_limit
|
||||
|
|
|
|||
170
src/helpers.zsh
170
src/helpers.zsh
|
|
@ -2,35 +2,6 @@
|
|||
# Helpers for use within tests #
|
||||
################################
|
||||
|
||||
###
|
||||
# Colorise and style a string
|
||||
###
|
||||
function color() {
|
||||
local color=$1 style=$2 b=0
|
||||
|
||||
shift
|
||||
|
||||
case $style in
|
||||
bold|b) b=1; shift ;;
|
||||
italic|i) b=2; shift ;;
|
||||
underline|u) b=4; shift ;;
|
||||
inverse|in) b=7; shift ;;
|
||||
strikethrough|s) b=9; shift ;;
|
||||
esac
|
||||
|
||||
case $color in
|
||||
black|b) echo "\033[${b};30m${@}\033[0;m" ;;
|
||||
red|r) echo "\033[${b};31m${@}\033[0;m" ;;
|
||||
green|g) echo "\033[${b};32m${@}\033[0;m" ;;
|
||||
yellow|y) echo "\033[${b};33m${@}\033[0;m" ;;
|
||||
blue|bl) echo "\033[${b};34m${@}\033[0;m" ;;
|
||||
magenta|m) echo "\033[${b};35m${@}\033[0;m" ;;
|
||||
cyan|c) echo "\033[${b};36m${@}\033[0;m" ;;
|
||||
white|w) echo "\033[${b};37m${@}\033[0;m" ;;
|
||||
*) echo "\033[${b};38;5;$(( ${color} ))m${@}\033[0;m" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
###
|
||||
# Find a file, and load it into the environment
|
||||
###
|
||||
|
|
@ -81,36 +52,18 @@ function run() {
|
|||
|
||||
# Store each word of the command in an array, and grab the first
|
||||
# argument which is the command name
|
||||
cmd=("${@[@]}")
|
||||
cmd=(${@[@]})
|
||||
name="${cmd[1]}"
|
||||
|
||||
# If the command is not an existing command or file,
|
||||
# then prepend the test directory to the path
|
||||
type -- $name > /dev/null
|
||||
type $name > /dev/null
|
||||
if [[ $? -ne 0 && ! -f $name && -f "$testdir/${name}" ]]; then
|
||||
cmd[1]="$testdir/${name}"
|
||||
fi
|
||||
|
||||
# Store full output in a variable
|
||||
|
||||
local -a dont_quote
|
||||
dont_quote=(
|
||||
# Allow redirections and running multiple commands
|
||||
"[[:digit:]]#(>|>>)(&|)[[:digit:]]#"
|
||||
"[[:digit:]]#(<|<<)(&|)[[:digit:]]#"
|
||||
"<<<" ";" "\\|" "\\|\\|" "&" "&&"
|
||||
|
||||
# Skip quoting of var=... -like strings and also of a single
|
||||
# `)' as it might follow var=( ... array assignment
|
||||
"([0-9]#|[a-zA-Z_][a-zA-Z0-9_]#)=*" "\\)"
|
||||
)
|
||||
|
||||
# The new line is important, it makes the error messages include the line
|
||||
# number, i.e. e.g.:
|
||||
# run:1: command not found: a-non-existent-command
|
||||
# It would be skipped otherwise, i.e. "run: command ..." would be printed
|
||||
IFS=$'\n' eval "output=\$( function run {
|
||||
${cmd[@]/(#m)*/${${${${${(M)MATCH:#(${(j:|:)~dont_quote})}:+$MATCH}}:-\"${MATCH//(#b)([\"\`\\])/\\${match[1]}}\"}}} 2>&1 }; run )";
|
||||
output=$("${cmd[@]}" 2>&1)
|
||||
|
||||
# Get the process exit state
|
||||
state="$?"
|
||||
|
|
@ -122,92 +75,10 @@ function run() {
|
|||
# Restore $IFS
|
||||
IFS=$oldIFS
|
||||
|
||||
# Print the command output if --verbose is specified
|
||||
if [[ -n $verbose && -n $output ]]; then
|
||||
echo $output
|
||||
fi
|
||||
|
||||
# Restore the exit on error state
|
||||
setopt ERR_EXIT
|
||||
}
|
||||
|
||||
###
|
||||
# Eval given code and capture its output and exit status
|
||||
###
|
||||
function evl() {
|
||||
# Separation of the main zunit option scope
|
||||
setopt localoptions
|
||||
|
||||
# Within tests, the shell is set to exit immediately when errors
|
||||
# occur. Since we want to capture the exit code of the command
|
||||
# we're running, we stop the shell from exiting on error temporarily
|
||||
unsetopt ERR_EXIT
|
||||
|
||||
# Preserve current $IFS
|
||||
local ___oldIFS=$IFS ___name
|
||||
local -a ___cmd
|
||||
|
||||
# Store each word of the command in an array, and grab the first
|
||||
# argument which is the command ___name
|
||||
___cmd=("${@[@]}")
|
||||
___name="${___cmd[1]}"
|
||||
|
||||
# If the command is not an existing command or file,
|
||||
# then prepend the test directory to the path
|
||||
type -- $___name > /dev/null
|
||||
if [[ $? -ne 0 && ! -f $___name && -f "$testdir/${___name}" ]]; then
|
||||
___cmd[1]="$testdir/${___name}"
|
||||
fi
|
||||
|
||||
# Store full output in a variable
|
||||
|
||||
local -a ___dont_quote
|
||||
___dont_quote=(
|
||||
# Allow redirections and running multiple commands
|
||||
"[[:digit:]]#(>|>>)(&|)[[:digit:]]#"
|
||||
"[[:digit:]]#(<|<<)(&|)[[:digit:]]#"
|
||||
"<<<" ";" "\\|" "\\|\\|" "&" "&&"
|
||||
|
||||
# Skip quoting of var=... -like strings and also of a single
|
||||
# `)' as it might follow var=( ... array assignment
|
||||
"([0-9]#|[a-zA-Z_][a-zA-Z0-9_]#)=*" "\\)"
|
||||
)
|
||||
|
||||
# Prepare the output file
|
||||
local ___OUTFILE=$(mktemp)
|
||||
|
||||
# The new line is important, it makes the error messages include the line
|
||||
# number, i.e. e.g.:
|
||||
# eval:1: command not found: a-non-existent-command
|
||||
# It would be skipped otherwise, i.e. "eval: command ..." would be printed.
|
||||
# This is to maintain consistency with the messages printed from run().
|
||||
IFS=$'\n' builtin eval "function __eval {
|
||||
${___cmd[@]/(#m)*/${${${${${(M)MATCH:#(${(j:|:)~___dont_quote})}:+$MATCH}}:-\"${MATCH//(#b)([\"\`\\])/\\${match[1]}}\"}}} \
|
||||
}; __eval >!$___OUTFILE 2>&1";
|
||||
|
||||
# Get the process exit state
|
||||
state="$?"
|
||||
|
||||
# $(<...) trims all trailing \n-s, therefore cat is being used
|
||||
output="$(cat "$___OUTFILE")"
|
||||
|
||||
# Cleanup
|
||||
unset -f __eval;
|
||||
command rm -f "$___OUTFILE"
|
||||
|
||||
# Store individual lines of output in an array
|
||||
IFS=$'\n'
|
||||
lines=("${(@f)output}")
|
||||
|
||||
# Restore $IFS
|
||||
IFS=$___oldIFS
|
||||
|
||||
# Print the command output if --verbose is specified
|
||||
if [[ -n $verbose && -n $output ]]; then
|
||||
echo $output
|
||||
fi
|
||||
}
|
||||
|
||||
###
|
||||
# Redirect the assertion shorthand to the correct function
|
||||
###
|
||||
|
|
@ -239,7 +110,7 @@ function assert() {
|
|||
_zunit_assertion_count=$(( _zunit_assertion_count + 1 ))
|
||||
|
||||
# Run the assertion
|
||||
"_zunit_assert_${assertion}" "$value" ${(@f)comparisons[@]}
|
||||
"_zunit_assert_${assertion}" $value ${(@f)comparisons[@]}
|
||||
|
||||
local state=$?
|
||||
|
||||
|
|
@ -253,37 +124,6 @@ function assert() {
|
|||
IFS=$oldIFS
|
||||
}
|
||||
|
||||
###
|
||||
# Mark the current test as passed
|
||||
###
|
||||
function pass() {
|
||||
# Exit code 0 will end the test, and mark is as passed. The reason for
|
||||
# skipping is echoed to stdout first, so that it can be picked up by the
|
||||
# error handler
|
||||
exit 0
|
||||
}
|
||||
|
||||
###
|
||||
# Mark the current test as failed
|
||||
###
|
||||
function fail() {
|
||||
# Any non-zero exit code without special meaning will mark the test as failed.
|
||||
# The failure message is echoed to stdout first, so that it can be picked up
|
||||
# by the error handler
|
||||
echo "$@"
|
||||
exit 1
|
||||
}
|
||||
|
||||
###
|
||||
# Mark the current test as skipped
|
||||
###
|
||||
function error() {
|
||||
# Exit code 78 will end the test, and report an error. The error message
|
||||
# is echoed to stdout first, so that it can be picked up by the error handler
|
||||
echo "$@"
|
||||
exit 78
|
||||
}
|
||||
|
||||
###
|
||||
# Mark the current test as skipped
|
||||
###
|
||||
|
|
@ -295,5 +135,3 @@ function skip() {
|
|||
echo "$@"
|
||||
exit 48
|
||||
}
|
||||
|
||||
# vim:ft=zsh:et:sts=2:sw=2
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -1,7 +1,5 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
setopt extendedglob typesetsilent
|
||||
|
||||
######################
|
||||
# Main zunit process #
|
||||
######################
|
||||
|
|
@ -22,7 +20,6 @@ function _zunit_usage() {
|
|||
echo " -v, --version Output version information and exit"
|
||||
echo " -f, --fail-fast Stop the test runner immediately after the first failure"
|
||||
echo " -t, --tap Output results in a TAP compatible format"
|
||||
echo " --verbose Prints full output from each test"
|
||||
echo " --output-text Print results to a text log, in TAP compatible format"
|
||||
echo " --output-html Print results to a HTML page"
|
||||
echo " --allow-risky Supress warnings generated for risky tests"
|
||||
|
|
@ -33,7 +30,7 @@ function _zunit_usage() {
|
|||
# Output the version number
|
||||
###
|
||||
function _zunit_version() {
|
||||
echo '0.8.2'
|
||||
echo '0.7.0'
|
||||
}
|
||||
|
||||
###
|
||||
|
|
@ -59,14 +56,25 @@ function _zunit() {
|
|||
fi
|
||||
fi
|
||||
|
||||
# Check for the 'color' dependency
|
||||
$(type color >/dev/null 2>&1)
|
||||
if [[ $? -ne 0 ]]; then
|
||||
# 'color' could not be found, so print an error message
|
||||
missing_dependencies=$(( missing_dependencies + 1 ))
|
||||
echo "\033[0;31mMissing required dependency: Color - https://github.com/molovo/color\033[0;m" >&2
|
||||
fi
|
||||
|
||||
# Check for the 'revolver' dependency
|
||||
$(type revolver >/dev/null 2>&1)
|
||||
if [[ $? -ne 0 ]]; then
|
||||
# 'revolver' could not be found, so print an error message
|
||||
missing_dependencies=$(( missing_dependencies + 1 ))
|
||||
echo "\033[0;31mMissing required dependency: Revolver - https://github.com/molovo/revolver\033[0;m" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# If any missing dependencies have been found, we can't run tests, so we exit
|
||||
[[ $missing_dependencies -gt 0 ]] && exit 1
|
||||
|
||||
zparseopts -D -E \
|
||||
h=help -help=help \
|
||||
v=version -version=version
|
||||
|
|
|
|||
|
|
@ -1,43 +0,0 @@
|
|||
#!/usr/bin/env zunit
|
||||
|
||||
@test 'Test _zunit_assert_contains match' {
|
||||
run assert 'hello world' contains 'lo wo'
|
||||
|
||||
assert "$output" is_empty
|
||||
assert $state equals 0
|
||||
}
|
||||
|
||||
@test 'Test _zunit_assert_contains suffix match' {
|
||||
run assert 'hello world' contains 'world'
|
||||
|
||||
assert "$output" is_empty
|
||||
assert $state equals 0
|
||||
}
|
||||
|
||||
@test 'Test _zunit_assert_contains prefix match' {
|
||||
run assert 'hello world' contains 'hello'
|
||||
|
||||
assert "$output" is_empty
|
||||
assert $state equals 0
|
||||
}
|
||||
|
||||
@test 'Test _zunit_assert_contains whole word matches' {
|
||||
run assert 'red blue green' contains 'red blue green'
|
||||
|
||||
assert "$output" is_empty
|
||||
assert $state equals 0
|
||||
}
|
||||
|
||||
@test 'Test _zunit_assert_contains match failure' {
|
||||
run assert 'elephants' contains 'foo'
|
||||
|
||||
assert "$output" same_as "'elephants' does not contain 'foo'"
|
||||
assert $state equals 1
|
||||
}
|
||||
|
||||
@test 'Test _zunit_assert_contains match failure with empty value' {
|
||||
run assert '' contains 'foo'
|
||||
|
||||
assert "$output" same_as "'' does not contain 'foo'"
|
||||
assert $state equals 1
|
||||
}
|
||||
|
|
@ -11,9 +11,3 @@
|
|||
assert $state equals 1
|
||||
assert $output same_as "'test' is the same as 'test'"
|
||||
}
|
||||
|
||||
@test 'Test _zunit_assert_different_to passes with empty value' {
|
||||
run assert '' different_to 'test'
|
||||
assert $state equals 0
|
||||
assert $output is_empty
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,22 +0,0 @@
|
|||
#!/usr/bin/env zunit
|
||||
|
||||
@test 'Test _zunit_assert_does_not_contain success' {
|
||||
run assert 'yellow' does_not_contain 'foo'
|
||||
|
||||
assert "$output" is_empty
|
||||
assert $state equals 0
|
||||
}
|
||||
|
||||
@test 'Test _zunit_assert_does_not_contain success with empty value' {
|
||||
run assert '' does_not_contain 'foo'
|
||||
|
||||
assert "$output" is_empty
|
||||
assert $state equals 0
|
||||
}
|
||||
|
||||
@test 'Test _zunit_assert_does_not_contain failure' {
|
||||
run assert 'foobar' does_not_contain 'foo'
|
||||
|
||||
assert "$output" same_as "'foobar' contains 'foo'"
|
||||
assert $state equals 1
|
||||
}
|
||||
|
|
@ -10,12 +10,6 @@
|
|||
assert $output is_empty
|
||||
}
|
||||
|
||||
@test 'Test _zunit_assert_does_not_match success with empty value' {
|
||||
run assert '' does_not_match '[0-9]+'
|
||||
assert $state equals 0
|
||||
assert $output is_empty
|
||||
}
|
||||
|
||||
@test 'Test _zunit_assert_does_not_match failure' {
|
||||
run assert 'test' does_not_match '[a-z]{4}'
|
||||
assert $state equals 1
|
||||
|
|
|
|||
|
|
@ -11,9 +11,3 @@
|
|||
assert $state equals 1
|
||||
assert $output same_as "'1' is not equal to '0'"
|
||||
}
|
||||
|
||||
@test 'Test _zunit_assert_equals failure with empty value' {
|
||||
run assert '' equals 1
|
||||
assert $state equals 1
|
||||
assert $output same_as "'' is not equal to '1'"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#! /usr/bin/env zunit
|
||||
#!/usr/bin/env zunit
|
||||
|
||||
@test 'Test _zunit_assert_exists success' {
|
||||
run assert './exists.zunit' exists
|
||||
|
|
|
|||
|
|
@ -11,9 +11,3 @@
|
|||
assert $state equals 1
|
||||
assert "$output" same_as "'a' is not in (x y z)"
|
||||
}
|
||||
|
||||
@test 'Test _zunit_assert_in failure with empty value' {
|
||||
run assert '' in 'x' 'y' 'z'
|
||||
assert $state equals 1
|
||||
assert "$output" same_as "'' is not in (x y z)"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
#!/usr/bin/env zunit
|
||||
|
||||
@test 'Test _zunit_assert_is_greater_than success' {
|
||||
run assert 2 is_greater_than 1
|
||||
assert $state equals 0
|
||||
assert $output is_empty
|
||||
}
|
||||
|
||||
@test 'Test _zunit_assert_is_greater_than failure' {
|
||||
run assert -1 is_greater_than 1
|
||||
assert $state equals 1
|
||||
assert $output same_as "'-1' is not greater than '1'"
|
||||
}
|
||||
|
||||
@test 'Test _zunit_assert_is_greater_than failure with empty value' {
|
||||
run assert '' is_greater_than 1
|
||||
assert $state equals 1
|
||||
assert $output same_as "'' is not greater than '1'"
|
||||
}
|
||||
|
|
@ -21,14 +21,3 @@
|
|||
assert $state equals 1
|
||||
assert "$output" same_as "'a' is not a key in (x 1 y 2 z 3)"
|
||||
}
|
||||
|
||||
@test 'Test _zunit_assert_is_key_in failure with empty value' {
|
||||
typeset -A hash; hash=(
|
||||
'x' 1
|
||||
'y' 2
|
||||
'z' 3
|
||||
)
|
||||
run assert '' is_key_in ${(@kv)hash}
|
||||
assert $state equals 1
|
||||
assert "$output" same_as "'' is not a key in (x 1 y 2 z 3)"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
#!/usr/bin/env zunit
|
||||
|
||||
@test 'Test _zunit_assert_is_less_than success' {
|
||||
run assert -1 is_less_than 1
|
||||
assert $state equals 0
|
||||
assert $output is_empty
|
||||
}
|
||||
|
||||
@test 'Test _zunit_assert_is_less_than failure' {
|
||||
run assert 2 is_less_than 1
|
||||
assert $state equals 1
|
||||
assert $output same_as "'2' is not less than '1'"
|
||||
}
|
||||
|
||||
@test 'Test _zunit_assert_is_less_than failure' {
|
||||
run assert '' is_less_than -1
|
||||
assert $state equals 1
|
||||
assert $output same_as "'' is not less than '-1'"
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
#!/usr/bin/env zunit
|
||||
|
||||
@test 'Test _zunit_assert_is_negative success' {
|
||||
run assert -1 is_negative
|
||||
assert $state equals 0
|
||||
assert $output is_empty
|
||||
}
|
||||
|
||||
@test 'Test _zunit_assert_is_negative failure' {
|
||||
run assert 1 is_negative
|
||||
assert $state equals 1
|
||||
assert $output same_as "'1' is not negative"
|
||||
}
|
||||
|
||||
@test 'Test _zunit_assert_is_negative failure with empty value' {
|
||||
run assert '' is_negative
|
||||
assert $state equals 1
|
||||
assert $output same_as "'' is not negative"
|
||||
}
|
||||
|
|
@ -11,17 +11,6 @@
|
|||
assert "$output" is_empty
|
||||
}
|
||||
|
||||
@test 'Test _zunit_assert_is_not_key_in success with empty value' {
|
||||
typeset -A assoc; assoc=(
|
||||
'x' 1
|
||||
'y' 2
|
||||
'z' 3
|
||||
)
|
||||
run assert '' is_not_key_in ${(@kv)assoc}
|
||||
assert $state equals 0
|
||||
assert "$output" is_empty
|
||||
}
|
||||
|
||||
@test 'Test _zunit_assert_is_not_key_in failure' {
|
||||
typeset -A assoc; assoc=(
|
||||
'a' 1
|
||||
|
|
|
|||
|
|
@ -1,22 +0,0 @@
|
|||
#!/usr/bin/env zunit
|
||||
|
||||
@test 'Test _zunit_assert_is_substring_of success' {
|
||||
run assert 'foo' is_not_substring_of 'yellow'
|
||||
|
||||
assert "$output" is_empty
|
||||
assert $state equals 0
|
||||
}
|
||||
|
||||
@test 'Test _zunit_assert_is_substring_of failure' {
|
||||
run assert 'foo' is_not_substring_of 'foobar'
|
||||
|
||||
assert "$output" same_as "'foo' is a substring of 'foobar'"
|
||||
assert $state equals 1
|
||||
}
|
||||
|
||||
@test 'Test _zunit_assert_is_substring_of failure with empty value' {
|
||||
run assert '' is_not_substring_of 'foobar'
|
||||
|
||||
assert "$output" same_as "'' is a substring of 'foobar'"
|
||||
assert $state equals 1
|
||||
}
|
||||
|
|
@ -11,17 +11,6 @@
|
|||
assert "$output" is_empty
|
||||
}
|
||||
|
||||
@test 'Test _zunit_assert_is_not_value_in success with empty value' {
|
||||
typeset -A hash; hash=(
|
||||
'x' 7
|
||||
'y' 8
|
||||
'z' 9
|
||||
)
|
||||
run assert '' is_not_value_in ${(@kv)hash}
|
||||
assert $state equals 0
|
||||
assert "$output" is_empty
|
||||
}
|
||||
|
||||
@test 'Test _zunit_assert_is_not_value_in failure' {
|
||||
typeset -A hash; hash=(
|
||||
'a' 1
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
#!/usr/bin/env zunit
|
||||
|
||||
@test 'Test _zunit_assert_is_positive success' {
|
||||
run assert 1 is_positive
|
||||
assert $state equals 0
|
||||
assert $output is_empty
|
||||
}
|
||||
|
||||
@test 'Test _zunit_assert_is_positive failure' {
|
||||
run assert -1 is_positive
|
||||
assert $state equals 1
|
||||
assert $output same_as "'-1' is not positive"
|
||||
}
|
||||
|
||||
@test 'Test _zunit_assert_is_positive failure with empty value' {
|
||||
run assert '' is_positive
|
||||
assert $state equals 1
|
||||
assert $output same_as "'' is not positive"
|
||||
}
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
#!/usr/bin/env zunit
|
||||
|
||||
@test 'Test _zunit_assert_is_substring_of match' {
|
||||
run assert 'lo wo' is_substring_of 'hello world'
|
||||
|
||||
assert "$output" is_empty
|
||||
assert $state equals 0
|
||||
}
|
||||
|
||||
@test 'Test _zunit_assert_is_substring_of match with empty value' {
|
||||
run assert '' is_substring_of 'hello world'
|
||||
|
||||
assert "$output" is_empty
|
||||
assert $state equals 0
|
||||
}
|
||||
|
||||
@test 'Test _zunit_assert_is_substring_of suffix match' {
|
||||
run assert 'world' is_substring_of 'hello world'
|
||||
|
||||
assert "$output" is_empty
|
||||
assert $state equals 0
|
||||
}
|
||||
|
||||
@test 'Test _zunit_assert_is_substring_of prefix match' {
|
||||
run assert 'hello' is_substring_of 'hello world'
|
||||
|
||||
assert "$output" is_empty
|
||||
assert $state equals 0
|
||||
}
|
||||
|
||||
@test 'Test _zunit_assert_is_substring_of whole word matches' {
|
||||
run assert 'red blue green' is_substring_of 'red blue green'
|
||||
|
||||
assert "$output" is_empty
|
||||
assert $state equals 0
|
||||
}
|
||||
|
||||
@test 'Test _zunit_assert_is_substring_of match failure' {
|
||||
run assert 'foo' is_substring_of 'elephants'
|
||||
|
||||
assert "$output" same_as "'foo' is not a substring of 'elephants'"
|
||||
assert $state equals 1
|
||||
}
|
||||
|
|
@ -21,14 +21,3 @@
|
|||
assert $state equals 1
|
||||
assert "$output" same_as "'4' is not a value in (x 1 y 2 z 3)"
|
||||
}
|
||||
|
||||
@test 'Test _zunit_assert_is_value_in failure with empty value' {
|
||||
typeset -A hash; hash=(
|
||||
'x' 1
|
||||
'y' 2
|
||||
'z' 3
|
||||
)
|
||||
run assert '' is_value_in ${(@kv)hash}
|
||||
assert $state equals 1
|
||||
assert "$output" same_as "'' is not a value in (x 1 y 2 z 3)"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,9 +19,3 @@
|
|||
assert $state equals 1
|
||||
assert $output same_as "'123' does not match /[a-z]+/"
|
||||
}
|
||||
|
||||
@test 'Test _zunit_assert_matches failure with empty value' {
|
||||
run assert '' matches '[a-z]+'
|
||||
assert $state equals 1
|
||||
assert $output same_as "'' does not match /[a-z]+/"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,18 +6,6 @@
|
|||
assert $output is_empty
|
||||
}
|
||||
|
||||
@test 'Test _zunit_assert_not_equal_to success with empty value' {
|
||||
run assert '' not_equal_to 1
|
||||
assert $state equals 0
|
||||
assert $output is_empty
|
||||
}
|
||||
|
||||
@test 'Test _zunit_assert_not_equal_to success with empty comparison' {
|
||||
run assert 1 not_equal_to ''
|
||||
assert $state equals 0
|
||||
assert $output is_empty
|
||||
}
|
||||
|
||||
@test 'Test _zunit_assert_not_equal_to failure' {
|
||||
run assert 1 not_equal_to 1
|
||||
assert $state equals 1
|
||||
|
|
|
|||
|
|
@ -6,12 +6,6 @@
|
|||
assert $output is_empty
|
||||
}
|
||||
|
||||
@test 'Test _zunit_assert_not_in success with empty value' {
|
||||
run assert '' not_in 'x' 'y' 'z'
|
||||
assert $state equals 0
|
||||
assert $output is_empty
|
||||
}
|
||||
|
||||
@test 'Test _zunit_assert_not_in failure' {
|
||||
run assert 'a' not_in 'a' 'b' 'c'
|
||||
assert $state equals 1
|
||||
|
|
|
|||
|
|
@ -11,9 +11,3 @@
|
|||
assert $state equals 1
|
||||
assert $output same_as "'test' is not the same as 'wrong'"
|
||||
}
|
||||
|
||||
@test 'Test _zunit_assert_same_as failure with empty value' {
|
||||
run assert '' same_as 'wrong'
|
||||
assert $state equals 1
|
||||
assert $output same_as "'' is not the same as 'wrong'"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,29 +0,0 @@
|
|||
#!/usr/bin/env zunit
|
||||
|
||||
@test 'Test pass helper' {
|
||||
run pass
|
||||
|
||||
assert $state equals 0
|
||||
assert "$output" is_empty
|
||||
}
|
||||
|
||||
@test 'Test fail helper' {
|
||||
run fail 'The failure message'
|
||||
|
||||
assert $state equals 1
|
||||
assert "$output" same_as 'The failure message'
|
||||
}
|
||||
|
||||
@test 'Test error helper' {
|
||||
run error 'The error message'
|
||||
|
||||
assert $state equals 78
|
||||
assert "$output" same_as 'The error message'
|
||||
}
|
||||
|
||||
@test 'Test skip helper' {
|
||||
run skip 'The skip message'
|
||||
|
||||
assert $state equals 48
|
||||
assert "$output" same_as 'The skip message'
|
||||
}
|
||||
|
|
@ -21,7 +21,6 @@ _zunit() {
|
|||
'(-v --version)'{-v,--version}'[show version information and exit]' \
|
||||
'(-f --fail-fast)'{-f,--fail-fast}'[stop execution after the first failure]' \
|
||||
'(-t --tap)'{-t,--tap}'[output results in a TAP compatible format]' \
|
||||
'--verbose[prints full output from each test]' \
|
||||
'--output-text[print results to a text log, in TAP compatible format]' \
|
||||
'--output-html[print results to a HTML page]' \
|
||||
'--allow-risky[supress warnings generated for risky tests]' \
|
||||
|
|
@ -43,7 +42,6 @@ _zunit() {
|
|||
'(-h --help)'{-h,--help}'[show help text and exit]' \
|
||||
'(-f --fail-fast)'{-f,--fail-fast}'[stop execution after the first failure]' \
|
||||
'(-t --tap)'{-t,--tap}'[output results in a TAP compatible format]' \
|
||||
'--verbose[prints full output from each test]' \
|
||||
'--output-text[print results to a text log, in TAP compatible format]' \
|
||||
'--output-html[print results to a HTML page]' \
|
||||
'--allow-risky[supress warnings generated for risky tests]' \
|
||||
|
|
|
|||
Loading…
Reference in a new issue