Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add "-q/--quiet" flag to supress revolver spinner #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/commands/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function _zunit_init_usage() {
echo " -h, --help Output help text and exit"
echo " -v, --version Output version information and exit"
echo " -t, --travis Generate .travis.yml in project"
echo " -g, --gh Generate zunit.yml in project"
}

###
Expand Down
28 changes: 18 additions & 10 deletions src/commands/run.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ 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 " -t, --tap Output results in a TAP compatible format"
echo " -q, --quiet Supress revolver spinner for tests"
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"
Expand Down Expand Up @@ -47,12 +49,12 @@ function _zunit_output_results() {
echo
echo "$total tests run in $(_zunit_human_time $elapsed)"
echo
echo "$(color yellow underline 'Results') "
echo "$(color green '✔') Passed $passed "
echo "$(color red '✘') Failed $failed "
echo "$(color red '‼') Errors $errors "
echo "$(color magenta '●') Skipped $skipped "
echo "$(color yellow '‼') Warnings $warnings "
echo "$(color yellow underline 'Results') "
echo "$(color green '✔') Passed: $passed "
echo "$(color red '✘') Failed: $failed "
echo "$(color red '‼') Errors: $errors "
echo "$(color magenta '●') Skipped: $skipped "
echo "$(color yellow '‼') Warnings: $warnings "
echo

[[ -n $output_text ]] && echo "TAP report written at $PWD/$logfile_text"
Expand All @@ -67,7 +69,7 @@ function _zunit_execute_test() {

if [[ -n $body ]] && [[ -n $name ]]; then
# Update the progress indicator
[[ -z $tap ]] && revolver update "${name}"
[[ -z $tap ]] && [[ -z $quiet ]] && revolver update "${name}"

# Make sure we don't already have a function defined
(( $+functions[__zunit_tmp_test_function] )) && \
Expand Down Expand Up @@ -243,7 +245,7 @@ function _zunit_run_testfile() {
test_names=()

# Update status message
[[ -z $tap ]] && revolver update "Loading tests from $testfile"
[[ -z $tap ]] && [[ -z $quiet ]] && revolver update "Loading tests from $testfile"

# A regex pattern to match test declarations
pattern='^ *@test *([^ ].*) *\{ *(.*)$'
Expand Down Expand Up @@ -534,6 +536,12 @@ function _zunit_run() {
verbose=1
fi

# Quiet output is enabled
if [[ -n $quiet ]] || [[ "$zunit_config_quiet" = "true" ]]; then
# Set the $quiet variable, so we can check it later
quiet=1
fi

# Check if time_limit is specified in the config or as an option
if [[ -n $time_limit ]]; then
shift time_limit
Expand All @@ -545,7 +553,7 @@ function _zunit_run() {
testfiles=()

# Start the progress indicator
[[ -z $tap ]] && revolver start 'Loading tests'
[[ -z $tap ]] && [[ -z $quiet ]] && revolver start 'Loading tests'

# If no arguments are passed, try to work out where the tests are
if [[ ${#arguments} -eq 0 ]]; then
Expand Down Expand Up @@ -581,7 +589,7 @@ function _zunit_run() {
[[ -n $output_html ]] && _zunit_html_footer >> $logfile_html

# Output results to screen and kill the progress indicator
[[ -z $tap ]] && _zunit_output_results && revolver stop
[[ -z $tap ]] && _zunit_output_results && [[ -z $quiet ]] && revolver stop

# If the total of ($passed + $skipped) is not equal to the
# total, then there must have been failures, errors or warnings,
Expand Down
10 changes: 5 additions & 5 deletions src/events.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
###
function _zunit_fail_shutdown() {
# Kill the revolver process
[[ -z $tap ]] && revolver stop
[[ -z $tap ]] && [[ -z $quiet ]] && revolver stop

# Print a message to screen
echo $(color red bold 'Execution halted after failure')
Expand Down Expand Up @@ -47,7 +47,7 @@ function _zunit_success() {
return
fi

echo "$(color green '') ${name}"
echo "$(color green 'PASS') ${name}"
}

###
Expand All @@ -65,7 +65,7 @@ function _zunit_failure() {
if [[ -n $tap ]]; then
_zunit_tap_failure "$@"
else
echo "$(color red '' ${name})"
echo "$(color red 'FAILURE' ${name})"
echo " $(color red underline ${message})"
echo " $(color red ${output})"
fi
Expand All @@ -88,7 +88,7 @@ function _zunit_error() {
if [[ -n $tap ]]; then
_zunit_tap_error "$@"
else
echo "$(color red '' ${name})"
echo "$(color red 'ERROR' ${name})"
echo " $(color red underline ${message})"
echo " $(color red ${output})"
fi
Expand All @@ -113,7 +113,7 @@ function _zunit_warn() {
return
fi

echo "$(color yellow '') ${name}"
echo "$(color yellow 'WARNING') ${name}"
echo " $(color yellow underline ${message})"
}

Expand Down
1 change: 1 addition & 0 deletions src/zunit.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ 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 " -q, --quiet Supress revolver spinner for tests"
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"
Expand Down
2 changes: 2 additions & 0 deletions zunit.zsh-completion
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ _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]' \
'(-q --quiet)'{-q,--quiet}'[supress revolver spinner for tests]' \
'--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]' \
Expand All @@ -43,6 +44,7 @@ _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]' \
'(-q --quiet)'{-q,--quiet}'[supress revolver spinner for tests]' \
'--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]' \
Expand Down