diff --git a/.travis.yml b/.travis.yml
index b9d7ab3..bbe59ac 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,18 +1,11 @@
-matrix:
- include:
- - os: linux
- dist: trusty
- sudo: required
- - os: osx
- env: ZSH_SRC=system
- - os: osx
- env: ZSH_SRC=homebrew
+addons:
+ apt:
+ packages:
+ zsh
before_script:
-- if [[ "$ZSH_SRC" == "homebrew" ]]; then brew install zsh; fi
-- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install zsh; fi
- mkdir .bin
-- sudo curl -L https://raw.githubusercontent.com/molovo/revolver/master/revolver > .bin/revolver
-- sudo curl -L https://raw.githubusercontent.com/molovo/color/master/color.zsh > .bin/color
+- 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
- chmod u+x .bin/{color,revolver}
- export PATH="$PWD/.bin:$PATH"
script: ./zunit
diff --git a/README.md b/README.md
index eb4082e..0c1a19f 100644
--- a/README.md
+++ b/README.md
@@ -256,6 +256,27 @@ directories:
To set up ZUnit for a new project, just run `zunit init` in the project's root directory. This will create the `.zunit.yml` config file and relevant directories, including an example test.
+### [Travis CI](https://travis-ci.org) config
+
+ZUnit can generate a `.travis.yml` file for you, which contains the build steps needed to install ZUnit's dependencies and then run tests. Just run `zunit init --travis` when initialising your project.
+
+An example `.travis.yml` is below:
+
+```yaml
+addons:
+ apt:
+ packages:
+ zsh
+before_script:
+- 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/zunit/master/zunit > .bin/zunit
+- chmod u+x .bin/{color,revolver,zunit}
+- export PATH="$PWD/.bin:$PATH"
+script: zunit
+```
+
## Running Tests
The CLI program `zunit` is used to run tests.
@@ -286,6 +307,15 @@ zunit --tap
zunit --output-text
```
+### HTML Reports
+
+ZUnit is capable of producing a detail HTML report, which you can view in your browser.
+
+```sh
+# Prints HTML report to the _output directory
+zunit --output-html
+```
+
### Risky Tests
By default, risky tests (those that make no assertions) raise a warning in the test output. To supress this behaviour, and allow risky tests to pass without warning, use the `--allow-risky` option.
diff --git a/zunit b/zunit
index 5b3577f..8d63608 100755
--- a/zunit
+++ b/zunit
@@ -4,6 +4,16 @@
# Internal assertion functions #
################################
+function _zunit_html_header() {
+ echo '
"
+ echo $output
+}
+
###
# Assert that two integers are equal
###
@@ -359,6 +369,7 @@ function _zunit_usage() {
echo " -f, --fail-fast Stop the test runner immediately after the first failure"
echo " -t, --tap Output results in a TAP compatible format"
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"
}
@@ -375,6 +386,7 @@ function _zunit_run_usage() {
echo " -f, --fail-fast Stop the test runner immediately after the first failure"
echo " -t, --tap Output results in a TAP compatible format"
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"
}
@@ -388,20 +400,64 @@ function _zunit_init_usage() {
echo "$(color yellow 'Options:')"
echo " -h, --help Output help text and exit"
echo " -v, --version Output version information and exit"
+ echo " -t, --travis Generate .travis.yml in project"
+}
+
+###
+# Shutdown testing early
+# Usually called if --fail-fast is specified
+###
+function _zunit_fail_shutdown() {
+ # Kill the revolver process
+ [[ -z $tap ]] && revolver stop
+
+ echo $(color red bold 'Execution halted after failure')
+ end_time=$((EPOCHREALTIME*1000))
+
+ [[ -z $tap ]] && _zunit_output_results
+
+ # Print end of HTML report
+ if [[ -n $output_html ]]; then
+ name='Execution halted after failure'
+ _zunit_html_error >> $logfile_html
+ _zunit_html_footer >> $logfile_html
+ fi
+
+ exit 1
+}
+
+###
+# Output a HTML fatal error message
+###
+_zunit_html_fatal_error() {
+ message="$@"
+ echo "
+
$message
+
"
}
###
# Output a TAP compatible success message
###
-_zunit_tap_success() {
+function _zunit_tap_success() {
echo "ok ${total} - ${name}"
}
+###
+# Output a HTML success message
+###
+_zunit_html_success() {
+ echo "