From 7f5455739d8fa3dbcb582d9b68915a5d8960c37a Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Mon, 25 Jan 2016 13:49:35 +0000 Subject: [PATCH 01/40] update readme * move shall reference to the right place * further explain cross-shell testing methods --- readme.md | 51 ++++++++++++++++++++++----------------------------- 1 file changed, 22 insertions(+), 29 deletions(-) diff --git a/readme.md b/readme.md index caeb6a6..9e7663b 100644 --- a/readme.md +++ b/readme.md @@ -106,24 +106,20 @@ The specific approach depends on your test scenario: * (b) Your scripts _source_ scripts containing portable shell code. #### (a) Cross-shell tests with test scripts that _invoke_ shell scripts +Urchin sets the `TEST_SHELL` environment variable so that you may change the +shell with which your tests call other shell programs. To run your test +scripts in multiple shells you must call `$TEST_SHELL` in your tests and then +run urchin with the appropriate option. -First, consider using [shall](https://github.com/mklement0/shall). - - #!/usr/bin/env shall - echo This is a test file. - -Alternatively, you can use urchin's built-in recognition of the -`TEST_SHELL` environment variable. In your test scripts, invoke the shell scripts to test via the shell specified in environment variable `TEST_SHELL` rather than directly; e.g.: `$TEST_SHELL ../foo bar` (rather than just `../foo bar`). -Note that if you alsow want your test scripts to work when run directly, -outside of Urchin, be sure to target scripts that happen to be in the -current directory with prefix `./`; e.g., `$TEST_SHELL ./baz` -(rather than `$TEST_SHELL baz`). -Then, on invocation of Urchin, prepend a definition of environment variable -`TEST_SHELL` specifying the shell to test with, e.g.: `TEST_SHELL=zsh urchin ./tests`. +On invocation of Urchin, prepend a definition of environment variable +`TEST_SHELL` specifying the shell to test with, e.g., + + TEST_SHELL=zsh urchin ./tests + To test with multiple shells in sequence, use something like: for shell in sh bash ksh zsh; do @@ -131,14 +127,20 @@ To test with multiple shells in sequence, use something like: done If `TEST_SHELL` has no value, Urchin defines it as `/bin/sh`, so the test -scripts can rely on `$TEST_SHELL` always containing a value. +scripts can rely on `$TEST_SHELL` always containing a value when Urchin runs +them. + +That said, we still recommand that you account for the possibility that +`$TEST_SHELL` does not contain a value so that you may run your test scripts +without Urchin. Supporting this case is very simple; when you invoke scripts +that happen to be in the current directory, be sure to use the prefix `./`, +e.g., `$TEST_SHELL ./baz` rather than `$TEST_SHELL baz`. #### (b) Cross-shell tests with test scripts that _source_ shell scripts - If you _source_ shell code in your test scripts, it is the test scripts themselves that must be run with the shell specified. -To that end, Urchin supports the `-s ` option, which instructs +Urchin supports the `-s ` option, which instructs Urchin to invoke the test scripts with the specified shell; e.g., `-s bash`. (In addition, Urchin sets environment variable `TEST_SHELL` to the specified shell.) @@ -154,21 +156,12 @@ To test with multiple shells in sequence, use something like: urchin -s $shell ./tests done - ## Alternatives to Urchin Alternatives to Urchin are discussed in [this blog post](https://blog.scraperwiki.com/2012/12/how-to-test-shell-scripts/). -- 2.39.5 From d81b7efdc3fa9fb7cf85a8cfea812dbf15079820 Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Mon, 25 Jan 2016 13:56:33 +0000 Subject: [PATCH 02/40] asciibetical --- readme.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/readme.md b/readme.md index 9e7663b..08a70d7 100644 --- a/readme.md +++ b/readme.md @@ -27,14 +27,15 @@ run this: cd urchin ./cross-shell-tests -## Globally -Download Urchin like so (as root) (or use npm, below): +## Install +Urchin is contained in a single file, so you can install it by copying it to a +directory in your `PATH`. For example, you can run the following as root. cd /usr/local/bin wget https://raw.github.com/tlevine/urchin/master/urchin chmod +x urchin -Can be installed with npm too: +Urchin can be installed with npm too. npm install -g urchin @@ -86,15 +87,14 @@ Files are only run if they are executable, and files beginning with `.` are ignored. Thus, fixtures and libraries can be included sloppily within the test directory tree. The test passes if the file exits 0; otherwise, it fails. -In case you care about the order in which your tests execute, consider that +Tests files and subdirectories are run in ASCIIbetical order within each +directory; that is, urchin looks for files within a directory in the following manner. for file in *; do do_something_with_test_file $file done -Tests within a directory are executed in whatever order `*` returns. - ### Writing cross-shell compatibility tests for testing shell code While you could write your test scripts to explicitly invoke the functionality -- 2.39.5 From 56a4e5d8af76a37abd234cebabaebbe3b360ee90 Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Mon, 25 Jan 2016 14:06:30 +0000 Subject: [PATCH 03/40] introduction paragraph --- readme.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/readme.md b/readme.md index 08a70d7..e4a9496 100644 --- a/readme.md +++ b/readme.md @@ -4,9 +4,9 @@ / /_/ / / / /__/ / / / / / / / \__,_/_/ \___/_/ /_/_/_/ /_/ -Urchin is a test framework for shell. It is implemented in -portable /bin/sh and should work on GNU/Linux, Mac OS X, and -other Unix platforms. +Urchin is a file-based test harness, normally used for testing shell programs. +It is written in portable shell and should thus work on GNU/Linux, BSD +(including Mac OS X), and other Unix-like platforms. ## Try it out Urchin's tests are written in Urchin, so you can run them to see what Urchin -- 2.39.5 From d525c1793ba26c14230f75a3505cb357d582193f Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Mon, 25 Jan 2016 13:35:53 +0000 Subject: [PATCH 04/40] remove "urchin -x" unnecessary now that shall exists --- urchin | 9 --------- 1 file changed, 9 deletions(-) diff --git a/urchin b/urchin index 60b7d84..e13e011 100755 --- a/urchin +++ b/urchin @@ -112,10 +112,6 @@ $USAGE Go to https://github.com/tlevine/urchin for documentation on writing tests. EOF - # [Experimental -x option left undocumented for now.] - # -x [Experimental; not meant for direct invocation, but for use in - # the shebang line of test scripts] - # Run with "\$TEST_SHELL", falling back on /bin/sh. } plural () { @@ -183,11 +179,6 @@ do shell_for_sh_tests=$1 which "$shell_for_sh_tests" >/dev/null || { echo "Cannot find specified shell: '$shell_for_sh_tests'" >&2; urchin_help >&2; exit 2; } ;; - -x) # [EXPERIMENTAL; UNDOCUMENTED FOR NOW] `urchin -x ` in a test script's shebang line is equivalent to invoking that script with `"$TEST_SHELL" ` - shift - urchinsh=${TEST_SHELL:-/bin/sh} - "$urchinsh" "$@" - exit $?;; -h|--help) urchin_help exit 0;; -*) urchin_help >&2 -- 2.39.5 From df80586d79d791c0ad9f1e948b2c5e825752514a Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Mon, 25 Jan 2016 13:57:14 +0000 Subject: [PATCH 05/40] remove "urchin -x" test --- tests/urchin -x should start the $TEST_SHELL. | 3 --- 1 file changed, 3 deletions(-) delete mode 100755 tests/urchin -x should start the $TEST_SHELL. diff --git a/tests/urchin -x should start the $TEST_SHELL. b/tests/urchin -x should start the $TEST_SHELL. deleted file mode 100755 index e137df2..0000000 --- a/tests/urchin -x should start the $TEST_SHELL. +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -test c = $(../urchin -x .print-arg-3 a 'b b b b' c d e) -- 2.39.5 From eda4a6e42ca4e104bc453e1c0df2c2d9ff43045e Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Mon, 25 Jan 2016 14:00:47 +0000 Subject: [PATCH 06/40] call urchin -s in cross-shell tests --- cross-shell-tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cross-shell-tests b/cross-shell-tests index 5f66f09..c0a2b08 100755 --- a/cross-shell-tests +++ b/cross-shell-tests @@ -6,7 +6,7 @@ for shell in dash bash ksh zsh; do if which $shell > /dev/null 2> /dev/null; then echo echo Running urchin tests in $shell - $shell urchin tests | tail -n 3 + $shell urchin -s $shell tests | tail -n 3 else echo echo Skipping $shell because it is not in the PATH -- 2.39.5 From 72fa30e78778c637962eed2858bd62e725f12e31 Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Mon, 25 Jan 2016 14:14:13 +0000 Subject: [PATCH 07/40] Test die on fail. --- tests/.die-on-fail/1 should run. | 0 tests/.die-on-fail/2 should run. | 1 + tests/.die-on-fail/3 should not run. | 1 + tests/.die-on-fail/4 should not run. | 1 + tests/Die on fail. | 11 +++++++++++ 5 files changed, 14 insertions(+) create mode 100755 tests/.die-on-fail/1 should run. create mode 100755 tests/.die-on-fail/2 should run. create mode 100755 tests/.die-on-fail/3 should not run. create mode 100755 tests/.die-on-fail/4 should not run. create mode 100755 tests/Die on fail. diff --git a/tests/.die-on-fail/1 should run. b/tests/.die-on-fail/1 should run. new file mode 100755 index 0000000..e69de29 diff --git a/tests/.die-on-fail/2 should run. b/tests/.die-on-fail/2 should run. new file mode 100755 index 0000000..c508d53 --- /dev/null +++ b/tests/.die-on-fail/2 should run. @@ -0,0 +1 @@ +false diff --git a/tests/.die-on-fail/3 should not run. b/tests/.die-on-fail/3 should not run. new file mode 100755 index 0000000..c508d53 --- /dev/null +++ b/tests/.die-on-fail/3 should not run. @@ -0,0 +1 @@ +false diff --git a/tests/.die-on-fail/4 should not run. b/tests/.die-on-fail/4 should not run. new file mode 100755 index 0000000..c508d53 --- /dev/null +++ b/tests/.die-on-fail/4 should not run. @@ -0,0 +1 @@ +false diff --git a/tests/Die on fail. b/tests/Die on fail. new file mode 100755 index 0000000..d9c3d22 --- /dev/null +++ b/tests/Die on fail. @@ -0,0 +1,11 @@ +tmp=$(mktemp) +../urchin -e -f ./.die-on-fail > $tmp +result=$? + +grep '1 should run.' $tmp +grep '2 should run.' $tmp +grep -v '3 should not run.' $tmp +grep -v '4 should not run.' $tmp + +rm $tmp +exit $result -- 2.39.5 From f6b57772f24eb49ded88901660f87021a2aee680 Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Mon, 25 Jan 2016 14:20:40 +0000 Subject: [PATCH 08/40] document unimplemented -e flag --- urchin | 3 +++ 1 file changed, 3 insertions(+) diff --git a/urchin b/urchin index e13e011..8ba2c6d 100755 --- a/urchin +++ b/urchin @@ -105,6 +105,9 @@ $USAGE -s Invoke test scripts that either have no shebang line at all or have shebang line "#!/bin/sh" with the specified shell. +-e Stop running if any single test fails. This is helpful if you want + to use Urchin to run things other than tests, such as a set of + configuration scripts. -f Force running even if the test directory's name does not contain the word "test". -h This help. -- 2.39.5 From d4bedbbfcf43a0dfc2fe5f1f1aa6aa2dc649874e Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Mon, 25 Jan 2016 14:35:54 +0000 Subject: [PATCH 09/40] first pass implementation of exit on fail --- urchin | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/urchin b/urchin index 8ba2c6d..ac6586d 100755 --- a/urchin +++ b/urchin @@ -48,6 +48,12 @@ recurse() { # $2 instead of $indent_level so it doesn't clash recurse "${test}" $(( $2 + 1 )) "$shell_for_sh_tests" + if $exit_on_fail && test $? -ne 0; then + [ -f teardown ] && [ -x teardown ] && ./teardown >> "$stdout_file" + [ -f teardown_dir ] && [ -x teardown_dir ] && ./teardown_dir >> "$stdout_file" + return 1 + fi + [ -f teardown ] && [ -x teardown ] && ./teardown >> "$stdout_file" done [ -f teardown_dir ] && [ -x teardown_dir ] && ./teardown_dir >> "$stdout_file" @@ -67,7 +73,6 @@ recurse() { fi exit_code="$?" - [ -f teardown ] && [ -x teardown ] && ./teardown >> "$stdout_file" indent $indent_level @@ -86,6 +91,11 @@ recurse() { cat "$stdout_file" printf '\033[0m' fi + + if $exit_on_fail && ! $exit_code; then + break + fi + fi [ $indent_level -eq 0 ] && rm "$stdout_file" } @@ -173,9 +183,11 @@ urchin_molly_guard() { shell_for_sh_tests= force=false +exit_on_fail=false while [ $# -gt 0 ] do case "$1" in + -e) exit_on_fail=true;; -f) force=true;; -s) shift -- 2.39.5 From c817355e94d0283f920f985d05976da73f068ee2 Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Mon, 25 Jan 2016 14:41:21 +0000 Subject: [PATCH 10/40] not working --- urchin | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/urchin b/urchin index ac6586d..c354458 100755 --- a/urchin +++ b/urchin @@ -47,8 +47,9 @@ recurse() { # $2 instead of $indent_level so it doesn't clash recurse "${test}" $(( $2 + 1 )) "$shell_for_sh_tests" + exit_code=$? - if $exit_on_fail && test $? -ne 0; then + if $exit_on_fail && test $exit_code -ne 0; then [ -f teardown ] && [ -x teardown ] && ./teardown >> "$stdout_file" [ -f teardown_dir ] && [ -x teardown_dir ] && ./teardown_dir >> "$stdout_file" return 1 @@ -92,10 +93,9 @@ recurse() { printf '\033[0m' fi - if $exit_on_fail && ! $exit_code; then - break + if $exit_on_fail && test 0 -ne $exit_code; then + return 1 fi - fi [ $indent_level -eq 0 ] && rm "$stdout_file" } -- 2.39.5 From 92cb735bb7c22cb89f057eba2aa8bd04ccb56334 Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Wed, 27 Jan 2016 00:32:51 +0000 Subject: [PATCH 11/40] start writing non-tap cases --- urchin | 51 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/urchin b/urchin index c354458..1ba0638 100755 --- a/urchin +++ b/urchin @@ -76,21 +76,25 @@ recurse() { [ -f teardown ] && [ -x teardown ] && ./teardown >> "$stdout_file" - indent $indent_level - if [ $exit_code -eq 0 ] - then - # On success, print a green '✓' - printf '\033[32m✓ \033[0m' - printf '%s\n' "${potential_test}" - printf '%s\n' "${potential_test} passed" >> "$logfile" + if $tap_format; then + sleep 0s else - # On fail, print a red '✗' - printf '\033[31m✗ \033[0m' - printf '%s\n' "${potential_test}" - printf '%s\n' "${potential_test} failed" >> "$logfile" - printf '\033[31m' # Print output captured from failed test in red. - cat "$stdout_file" - printf '\033[0m' + indent $indent_level + if [ $exit_code -eq 0 ] + then + # On success, print a green '✓' + printf '\033[32m✓ \033[0m' + printf '%s\n' "${potential_test}" + printf '%s\n' "${potential_test} passed" >> "$logfile" + else + # On fail, print a red '✗' + printf '\033[31m✗ \033[0m' + printf '%s\n' "${potential_test}" + printf '%s\n' "${potential_test} failed" >> "$logfile" + printf '\033[31m' # Print output captured from failed test in red. + cat "$stdout_file" + printf '\033[0m' + fi fi if $exit_on_fail && test 0 -ne $exit_code; then @@ -120,6 +124,7 @@ $USAGE configuration scripts. -f Force running even if the test directory's name does not contain the word "test". +-t Format output in Test Anything Protocol (TAP) -h This help. Go to https://github.com/tlevine/urchin for documentation on writing tests. @@ -160,12 +165,16 @@ urchin_go() { finish=$(date +%s) elapsed=$(($finish - $start)) - echo "Done, took $elapsed $(plural second $elapsed)." - set -- $(grep -e 'passed$' "$logfile"|wc -l) $(grep -e 'failed$' "$logfile"|wc -l) - printf '%s\n' "$1 $(plural test "$1") passed." - [ $2 -gt 0 ] && printf '\033[31m' || printf '\033[32m' # If tests failed, print the message in red, otherwise in green. - printf '%s\n' "$2 $(plural test "$2") failed." - printf '\033[m' + if $tap_format; then + sleep 0s + else + echo "Done, took $elapsed $(plural second $elapsed)." + set -- $(grep -e 'passed$' "$logfile"|wc -l) $(grep -e 'failed$' "$logfile"|wc -l) + printf '%s\n' "$1 $(plural test "$1") passed." + [ $2 -gt 0 ] && printf '\033[31m' || printf '\033[32m' # If tests failed, print the message in red, otherwise in green. + printf '%s\n' "$2 $(plural test "$2") failed." + printf '\033[m' + fi return "$2" } @@ -184,6 +193,7 @@ urchin_molly_guard() { shell_for_sh_tests= force=false exit_on_fail=false +tap_format=false while [ $# -gt 0 ] do case "$1" in @@ -194,6 +204,7 @@ do shell_for_sh_tests=$1 which "$shell_for_sh_tests" >/dev/null || { echo "Cannot find specified shell: '$shell_for_sh_tests'" >&2; urchin_help >&2; exit 2; } ;; + -t) tap_format=true;; -h|--help) urchin_help exit 0;; -*) urchin_help >&2 -- 2.39.5 From 0f86778d79a4217624f001b9f55923c3f99a0dac Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Wed, 27 Jan 2016 00:50:55 +0000 Subject: [PATCH 12/40] convert indents to comments --- urchin | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/urchin b/urchin index 1ba0638..b366fc9 100755 --- a/urchin +++ b/urchin @@ -31,8 +31,14 @@ recurse() { if [ -d "$potential_test" ] then ( - indent $indent_level - echo " ${potential_test}" + if $tap_format; then + indent $indent_level | sed 's/ /#/g' + echo "# ${potential_test}" + else + indent $indent_level + echo " ${potential_test}" + fi + cd -- "$potential_test" [ -f setup_dir ] && [ -x setup_dir ] && ./setup_dir >> "$stdout_file" -- 2.39.5 From 8d55550248bc8a79a65a915b3030397a26335089 Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Wed, 27 Jan 2016 01:05:08 +0000 Subject: [PATCH 13/40] test test successes better --- urchin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/urchin b/urchin index b366fc9..5594bda 100755 --- a/urchin +++ b/urchin @@ -181,7 +181,7 @@ urchin_go() { printf '%s\n' "$2 $(plural test "$2") failed." printf '\033[m' fi - return "$2" + test "$2" -eq '0' } urchin_molly_guard() { -- 2.39.5 From 0ca55d155b9104dcb1f9e707322c6f69e988fffb Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Wed, 27 Jan 2016 01:05:43 +0000 Subject: [PATCH 14/40] oops --- urchin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/urchin b/urchin index 5594bda..aa47773 100755 --- a/urchin +++ b/urchin @@ -181,7 +181,7 @@ urchin_go() { printf '%s\n' "$2 $(plural test "$2") failed." printf '\033[m' fi - test "$2" -eq '0' + test -z "$2" || test "$2" -eq '0' } urchin_molly_guard() { -- 2.39.5 From d963f10be1ea766fb087ed6373b49dc5c4ca7887 Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Wed, 27 Jan 2016 01:08:04 +0000 Subject: [PATCH 15/40] more tap --- urchin | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/urchin b/urchin index aa47773..e7ccc5b 100755 --- a/urchin +++ b/urchin @@ -83,7 +83,12 @@ recurse() { [ -f teardown ] && [ -x teardown ] && ./teardown >> "$stdout_file" if $tap_format; then - sleep 0s + if [ $exit_code -eq 0 ]; then + result=ok + else + result=not\ ok + fi + echo "${result} - ${potential_test}" else indent $indent_level if [ $exit_code -eq 0 ] -- 2.39.5 From cd124e09eec93f71d61cbb7c46bab8a679451ee8 Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Wed, 27 Jan 2016 01:13:55 +0000 Subject: [PATCH 16/40] more tap --- urchin | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/urchin b/urchin index e7ccc5b..fd11163 100755 --- a/urchin +++ b/urchin @@ -64,7 +64,7 @@ recurse() { [ -f teardown ] && [ -x teardown ] && ./teardown >> "$stdout_file" done [ -f teardown_dir ] && [ -x teardown_dir ] && ./teardown_dir >> "$stdout_file" - echo + if ! $tap_format; then echo; fi ) elif [ -x "$potential_test" ] then @@ -103,7 +103,7 @@ recurse() { printf '%s\n' "${potential_test}" printf '%s\n' "${potential_test} failed" >> "$logfile" printf '\033[31m' # Print output captured from failed test in red. - cat "$stdout_file" + sed 's/^/# /' "$stdout_file" printf '\033[0m' fi fi -- 2.39.5 From 538c8437a73f83456c86e4aaa174a570e4327233 Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Wed, 27 Jan 2016 09:48:30 +0000 Subject: [PATCH 17/40] assorted tap stuff --- urchin | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/urchin b/urchin index fd11163..737a0c4 100755 --- a/urchin +++ b/urchin @@ -88,7 +88,8 @@ recurse() { else result=not\ ok fi - echo "${result} - ${potential_test}" + n=$(grep -ce '^\(?:not \)\?ok' "$logfile") + echo "${result} $((n + 1)) - ${potential_test}" | tee --append "$logfile" else indent $indent_level if [ $exit_code -eq 0 ] @@ -176,8 +177,10 @@ urchin_go() { finish=$(date +%s) elapsed=$(($finish - $start)) + + if $tap_format; then - sleep 0s + echo "# Took $elapsed $(plural second $elapsed)." else echo "Done, took $elapsed $(plural second $elapsed)." set -- $(grep -e 'passed$' "$logfile"|wc -l) $(grep -e 'failed$' "$logfile"|wc -l) -- 2.39.5 From c3901fe17579f9b490ecffcca8cb696d25729add Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Wed, 27 Jan 2016 10:14:21 +0000 Subject: [PATCH 18/40] tap indentation comments for directories --- urchin | 112 ++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 71 insertions(+), 41 deletions(-) diff --git a/urchin b/urchin index 737a0c4..2cc8686 100755 --- a/urchin +++ b/urchin @@ -30,15 +30,16 @@ recurse() { if [ -d "$potential_test" ] then - ( - if $tap_format; then - indent $indent_level | sed 's/ /#/g' - echo "# ${potential_test}" - else - indent $indent_level - echo " ${potential_test}" - fi + if $tap_format; then + indent $indent_level | sed 's/ /#/g' + echo "# Begin ${potential_test}" + else + indent $indent_level + echo " ${potential_test}" + fi + + ( cd -- "$potential_test" [ -f setup_dir ] && [ -x setup_dir ] && ./setup_dir >> "$stdout_file" @@ -64,49 +65,75 @@ recurse() { [ -f teardown ] && [ -x teardown ] && ./teardown >> "$stdout_file" done [ -f teardown_dir ] && [ -x teardown_dir ] && ./teardown_dir >> "$stdout_file" - if ! $tap_format; then echo; fi ) - elif [ -x "$potential_test" ] - then - - [ -f setup ] && [ -x setup ] && ./setup >> "$stdout_file" - - # Run the test - if [ -n "$shell_for_sh_tests" ] && has_sh_or_no_shebang_line ./"$potential_test" - then - TEST_SHELL="$TEST_SHELL" "$shell_for_sh_tests" ./"$potential_test" > "$stdout_file" 2>&1 + if $tap_format; then + indent $indent_level | sed 's/ /#/g' + echo "# End ${potential_test}" else - TEST_SHELL="$TEST_SHELL" ./"$potential_test" > "$stdout_file" 2>&1 + echo fi - exit_code="$?" + else + if [ -x "$potential_test" ] + then + [ -f setup ] && [ -x setup ] && ./setup >> "$stdout_file" - [ -f teardown ] && [ -x teardown ] && ./teardown >> "$stdout_file" + # Run the test + if [ -n "$shell_for_sh_tests" ] && has_sh_or_no_shebang_line ./"$potential_test" + then + TEST_SHELL="$TEST_SHELL" "$shell_for_sh_tests" ./"$potential_test" > "$stdout_file" 2>&1 + else + TEST_SHELL="$TEST_SHELL" ./"$potential_test" > "$stdout_file" 2>&1 + fi + exit_code="$?" + + [ -f teardown ] && [ -x teardown ] && ./teardown >> "$stdout_file" + if [ $exit_code -eq 0 ]; then + result=success + else + result=fail + fi + else + result=skip + fi if $tap_format; then - if [ $exit_code -eq 0 ]; then - result=ok + n=$(grep -ce '^\(success\|fail\|skip\)' "$logfile") + + if [ "$result" == fail ]; then + not='not ' else - result=not\ ok + not='' fi - n=$(grep -ce '^\(?:not \)\?ok' "$logfile") - echo "${result} $((n + 1)) - ${potential_test}" | tee --append "$logfile" + if [ "$result" == skip ]; then + skip='# SKIP ' + else + skip='' + fi + echo "${not}ok $((n + 1)) - ${skip}${potential_test}" + echo "${result} ${potential_test}" >> "$logfile" else indent $indent_level - if [ $exit_code -eq 0 ] - then - # On success, print a green '✓' - printf '\033[32m✓ \033[0m' - printf '%s\n' "${potential_test}" - printf '%s\n' "${potential_test} passed" >> "$logfile" - else - # On fail, print a red '✗' - printf '\033[31m✗ \033[0m' - printf '%s\n' "${potential_test}" - printf '%s\n' "${potential_test} failed" >> "$logfile" - printf '\033[31m' # Print output captured from failed test in red. - sed 's/^/# /' "$stdout_file" - printf '\033[0m' - fi + case "$result" in + success) + # On success, print a green '✓' + printf '\033[32m✓ \033[0m' + printf '%s\n' "${potential_test}" + printf '%s\n' "${potential_test} passed" >> "$logfile" + ;; + fail) + # On fail, print a red '✗' + printf '\033[31m✗ \033[0m' + printf '%s\n' "${potential_test}" + printf '%s\n' "${potential_test} failed" >> "$logfile" + printf '\033[31m' # Print output captured from failed test in red. + sed 's/^/# /' "$stdout_file" + printf '\033[0m' + ;; + skip) + printf ' %s\n' "${potential_test}" + printf '%s\n' "${potential_test} skipped" >> "$logfile" + ;; + esac fi if $exit_on_fail && test 0 -ne $exit_code; then @@ -157,6 +184,9 @@ plural () { } urchin_go() { + if "$tap_format"; then + printf \#\ + fi echo Running tests at $(date +%Y-%m-%dT%H:%M:%S) | tee "$logfile" start=$(date +%s) -- 2.39.5 From 009fd7ea05bd24df29acbe9be26c1dc3a742f089 Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Wed, 27 Jan 2016 10:17:33 +0000 Subject: [PATCH 19/40] print stdout for tap and not-tap --- urchin | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/urchin b/urchin index 2cc8686..b41f659 100755 --- a/urchin +++ b/urchin @@ -111,6 +111,11 @@ recurse() { fi echo "${not}ok $((n + 1)) - ${skip}${potential_test}" echo "${result} ${potential_test}" >> "$logfile" + if [ "$result" == fail ]; then + echo '# ------------ Begin output ------------' + sed 's/^/# /' "$stdout_file" + echo '# ------------ End output ------------' + fi else indent $indent_level case "$result" in @@ -126,7 +131,7 @@ recurse() { printf '%s\n' "${potential_test}" printf '%s\n' "${potential_test} failed" >> "$logfile" printf '\033[31m' # Print output captured from failed test in red. - sed 's/^/# /' "$stdout_file" + cat "$stdout_file" printf '\033[0m' ;; skip) -- 2.39.5 From 144013c71c9c8cf2bf54f8af1ee18d8f775b7c8d Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Wed, 27 Jan 2016 10:24:28 +0000 Subject: [PATCH 20/40] print skip count at end --- urchin | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/urchin b/urchin index b41f659..39049e2 100755 --- a/urchin +++ b/urchin @@ -218,10 +218,14 @@ urchin_go() { echo "# Took $elapsed $(plural second $elapsed)." else echo "Done, took $elapsed $(plural second $elapsed)." - set -- $(grep -e 'passed$' "$logfile"|wc -l) $(grep -e 'failed$' "$logfile"|wc -l) - printf '%s\n' "$1 $(plural test "$1") passed." - [ $2 -gt 0 ] && printf '\033[31m' || printf '\033[32m' # If tests failed, print the message in red, otherwise in green. - printf '%s\n' "$2 $(plural test "$2") failed." + passed=$(grep -c 'passed$' "$logfile") + failed=$(grep -c 'failed$' "$logfile") + skipped=$(grep -c 'skipped$' "$logfile") + + printf '%s\n' "$passed $(plural test "$passed") passed." + printf '%s\n' "$skipped $(plural test "$skipped") skipped." + [ $failed -gt 0 ] && printf '\033[31m' || printf '\033[32m' # If tests failed, print the message in red, otherwise in green. + printf '%s\n' "$failed $(plural test "$failed") failed." printf '\033[m' fi test -z "$2" || test "$2" -eq '0' -- 2.39.5 From 53829466393a4f8924d564d8896146831a23070c Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Wed, 27 Jan 2016 10:25:21 +0000 Subject: [PATCH 21/40] error on fail --- urchin | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/urchin b/urchin index 39049e2..e168892 100755 --- a/urchin +++ b/urchin @@ -213,7 +213,6 @@ urchin_go() { finish=$(date +%s) elapsed=$(($finish - $start)) - if $tap_format; then echo "# Took $elapsed $(plural second $elapsed)." else @@ -228,7 +227,7 @@ urchin_go() { printf '%s\n' "$failed $(plural test "$failed") failed." printf '\033[m' fi - test -z "$2" || test "$2" -eq '0' + test -z "$failed" || test "$failed" -eq '0' } urchin_molly_guard() { -- 2.39.5 From c1ec06c6fe2c252b5e2fb9bd2a9785e9effe251a Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Wed, 27 Jan 2016 10:31:51 +0000 Subject: [PATCH 22/40] logfile --- urchin | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/urchin b/urchin index e168892..54aec6f 100755 --- a/urchin +++ b/urchin @@ -96,6 +96,7 @@ recurse() { result=skip fi + echo "${result}" >> "$logfile" if $tap_format; then n=$(grep -ce '^\(success\|fail\|skip\)' "$logfile") @@ -109,8 +110,7 @@ recurse() { else skip='' fi - echo "${not}ok $((n + 1)) - ${skip}${potential_test}" - echo "${result} ${potential_test}" >> "$logfile" + echo "${not}ok $n - ${skip}${potential_test}" if [ "$result" == fail ]; then echo '# ------------ Begin output ------------' sed 's/^/# /' "$stdout_file" @@ -123,20 +123,17 @@ recurse() { # On success, print a green '✓' printf '\033[32m✓ \033[0m' printf '%s\n' "${potential_test}" - printf '%s\n' "${potential_test} passed" >> "$logfile" ;; fail) # On fail, print a red '✗' printf '\033[31m✗ \033[0m' printf '%s\n' "${potential_test}" - printf '%s\n' "${potential_test} failed" >> "$logfile" printf '\033[31m' # Print output captured from failed test in red. cat "$stdout_file" printf '\033[0m' ;; skip) printf ' %s\n' "${potential_test}" - printf '%s\n' "${potential_test} skipped" >> "$logfile" ;; esac fi @@ -189,10 +186,11 @@ plural () { } urchin_go() { + rm -f "$logfile" if "$tap_format"; then printf \#\ fi - echo Running tests at $(date +%Y-%m-%dT%H:%M:%S) | tee "$logfile" + echo Running tests at $(date +%Y-%m-%dT%H:%M:%S) start=$(date +%s) # Determine the environment variable to define for test scripts @@ -217,9 +215,9 @@ urchin_go() { echo "# Took $elapsed $(plural second $elapsed)." else echo "Done, took $elapsed $(plural second $elapsed)." - passed=$(grep -c 'passed$' "$logfile") - failed=$(grep -c 'failed$' "$logfile") - skipped=$(grep -c 'skipped$' "$logfile") + passed=$(grep -c '^success' "$logfile") + failed=$(grep -c '^fail' "$logfile") + skipped=$(grep -c '^skip' "$logfile") printf '%s\n' "$passed $(plural test "$passed") passed." printf '%s\n' "$skipped $(plural test "$skipped") skipped." @@ -227,6 +225,7 @@ urchin_go() { printf '%s\n' "$failed $(plural test "$failed") failed." printf '\033[m' fi + rm -f "$logfile" test -z "$failed" || test "$failed" -eq '0' } -- 2.39.5 From bb42d27917ac86622f0d924ffabbf05a3d322dee Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Wed, 27 Jan 2016 10:39:07 +0000 Subject: [PATCH 23/40] test plan --- urchin | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/urchin b/urchin index 54aec6f..95ad81c 100755 --- a/urchin +++ b/urchin @@ -33,7 +33,7 @@ recurse() { if $tap_format; then indent $indent_level | sed 's/ /#/g' - echo "# Begin ${potential_test}" + echo "# Begin - ${potential_test}" else indent $indent_level echo " ${potential_test}" @@ -68,7 +68,7 @@ recurse() { ) if $tap_format; then indent $indent_level | sed 's/ /#/g' - echo "# End ${potential_test}" + echo "# End - ${potential_test}" else echo fi @@ -211,14 +211,14 @@ urchin_go() { finish=$(date +%s) elapsed=$(($finish - $start)) + passed=$(grep -c '^success' "$logfile") + failed=$(grep -c '^fail' "$logfile") + skipped=$(grep -c '^skip' "$logfile") if $tap_format; then echo "# Took $elapsed $(plural second $elapsed)." + echo 1..$(($passed + $failed + $skipped)) else echo "Done, took $elapsed $(plural second $elapsed)." - passed=$(grep -c '^success' "$logfile") - failed=$(grep -c '^fail' "$logfile") - skipped=$(grep -c '^skip' "$logfile") - printf '%s\n' "$passed $(plural test "$passed") passed." printf '%s\n' "$skipped $(plural test "$skipped") skipped." [ $failed -gt 0 ] && printf '\033[31m' || printf '\033[32m' # If tests failed, print the message in red, otherwise in green. -- 2.39.5 From 13e748d684a57f315b7dc6ba285af93b63afac6e Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Wed, 27 Jan 2016 10:51:03 +0000 Subject: [PATCH 24/40] remove awk dependency in test suite I'm on NixOS, so awk isn't in /usr/bin. I can search for it with /usr/bin/env, but then I can't use -f in the shebang line. --- ...h -s, a non-sh test script should be invoked directly. | 8 +++----- ...s option should invoke tests with the specified shell. | 1 - 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/tests/Cross-shell test support/.test-run-by-specified-shell/With -s, a non-sh test script should be invoked directly. b/tests/Cross-shell test support/.test-run-by-specified-shell/With -s, a non-sh test script should be invoked directly. index 2dd5303..358713c 100755 --- a/tests/Cross-shell test support/.test-run-by-specified-shell/With -s, a non-sh test script should be invoked directly. +++ b/tests/Cross-shell test support/.test-run-by-specified-shell/With -s, a non-sh test script should be invoked directly. @@ -1,5 +1,3 @@ -#!/usr/bin/awk -f - -# This script will only succeed if it is indeed processed by awk. - -BEGIN { print "ok" } +#!/usr/bin/env true +true will processed the contents of this script, but that +means that nothing will happen and the script will exit 0 diff --git a/tests/Cross-shell test support/The -s option should invoke tests with the specified shell. b/tests/Cross-shell test support/The -s option should invoke tests with the specified shell. index 62e1264..00a74ac 100755 --- a/tests/Cross-shell test support/The -s option should invoke tests with the specified shell. +++ b/tests/Cross-shell test support/The -s option should invoke tests with the specified shell. @@ -3,6 +3,5 @@ # Tests the `-s option, which invokes shebang-less and sh-shebang-line test scripts with the specified shell (for testing *sourced* shell code). which bash >/dev/null || { echo "Cannot test -s option: bash cannot be located." >&2; exit 2; } -which /usr/bin/awk >/dev/null || { echo "Cannot test -s option: /usr/bin/awk not found." >&2; exit 2; } ../../urchin -s bash ./.test-run-by-specified-shell -- 2.39.5 From e364d40f3a5df16ac5993919cd958ea38bfd86cf Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Thu, 28 Jan 2016 14:51:43 +0000 Subject: [PATCH 25/40] TAP test --- tests/TAP/.expected-output | 9 +++++++++ tests/TAP/.testsuite/a | 1 + tests/TAP/.testsuite/b | 1 + tests/TAP/.testsuite/c | 1 + tests/TAP/Running with -t should produce TAP output. | 4 ++++ 5 files changed, 16 insertions(+) create mode 100644 tests/TAP/.expected-output create mode 100755 tests/TAP/.testsuite/a create mode 100755 tests/TAP/.testsuite/b create mode 100644 tests/TAP/.testsuite/c create mode 100755 tests/TAP/Running with -t should produce TAP output. diff --git a/tests/TAP/.expected-output b/tests/TAP/.expected-output new file mode 100644 index 0000000..aae0e3e --- /dev/null +++ b/tests/TAP/.expected-output @@ -0,0 +1,9 @@ +# Begin - .testsuite/ +not ok 1 - a +# ------------ Begin output ------------ +# ------------ End output ------------ +ok 2 - b +ok 3 - # SKIP c +# End - .testsuite/ +# Took 0 seconds. +1..3 diff --git a/tests/TAP/.testsuite/a b/tests/TAP/.testsuite/a new file mode 100755 index 0000000..c508d53 --- /dev/null +++ b/tests/TAP/.testsuite/a @@ -0,0 +1 @@ +false diff --git a/tests/TAP/.testsuite/b b/tests/TAP/.testsuite/b new file mode 100755 index 0000000..27ba77d --- /dev/null +++ b/tests/TAP/.testsuite/b @@ -0,0 +1 @@ +true diff --git a/tests/TAP/.testsuite/c b/tests/TAP/.testsuite/c new file mode 100644 index 0000000..619220c --- /dev/null +++ b/tests/TAP/.testsuite/c @@ -0,0 +1 @@ +This should not be run. diff --git a/tests/TAP/Running with -t should produce TAP output. b/tests/TAP/Running with -t should produce TAP output. new file mode 100755 index 0000000..32912fa --- /dev/null +++ b/tests/TAP/Running with -t should produce TAP output. @@ -0,0 +1,4 @@ +tmp=$(mktemp) + +../../urchin -t .testsuite/ | sed 1d > $tmp +diff $tmp .expected-output -- 2.39.5 From 7339e84d7c15690388869c69dd7aff5899441556 Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Thu, 28 Jan 2016 14:55:08 +0000 Subject: [PATCH 26/40] test stdout stderr for TAP --- tests/TAP/.expected-output | 2 ++ tests/TAP/.testsuite/a | 3 +++ tests/TAP/.testsuite/b | 3 +++ 3 files changed, 8 insertions(+) diff --git a/tests/TAP/.expected-output b/tests/TAP/.expected-output index aae0e3e..5d79c31 100644 --- a/tests/TAP/.expected-output +++ b/tests/TAP/.expected-output @@ -1,6 +1,8 @@ # Begin - .testsuite/ not ok 1 - a # ------------ Begin output ------------ +# This is stderr from a. +# This is stdout from a. # ------------ End output ------------ ok 2 - b ok 3 - # SKIP c diff --git a/tests/TAP/.testsuite/a b/tests/TAP/.testsuite/a index c508d53..c68153e 100755 --- a/tests/TAP/.testsuite/a +++ b/tests/TAP/.testsuite/a @@ -1 +1,4 @@ +#!/bin/sh +echo This is stderr from a. > /dev/stderr +echo This is stdout from a. > /dev/stdout false diff --git a/tests/TAP/.testsuite/b b/tests/TAP/.testsuite/b index 27ba77d..4dd2598 100755 --- a/tests/TAP/.testsuite/b +++ b/tests/TAP/.testsuite/b @@ -1 +1,4 @@ +#!/bin/sh +echo This is stderr from b. > /dev/stderr +echo This is stdout from b. > /dev/stdout true -- 2.39.5 From 66c010b6943db6a1da4e0be02555180b7ed9c5c9 Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Thu, 28 Jan 2016 15:11:27 +0000 Subject: [PATCH 27/40] fix fixture to not expect stderr --- tests/TAP/.expected-output | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/TAP/.expected-output b/tests/TAP/.expected-output index 5d79c31..69364fc 100644 --- a/tests/TAP/.expected-output +++ b/tests/TAP/.expected-output @@ -1,7 +1,6 @@ # Begin - .testsuite/ not ok 1 - a # ------------ Begin output ------------ -# This is stderr from a. # This is stdout from a. # ------------ End output ------------ ok 2 - b -- 2.39.5 From 8e669c40a6c6b8be930723767454315344d299f4 Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Thu, 28 Jan 2016 15:12:33 +0000 Subject: [PATCH 28/40] add + indent symbol so directories line up --- urchin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/urchin b/urchin index 95ad81c..4b02fa8 100755 --- a/urchin +++ b/urchin @@ -36,7 +36,7 @@ recurse() { echo "# Begin - ${potential_test}" else indent $indent_level - echo " ${potential_test}" + echo "+ ${potential_test}" fi ( -- 2.39.5 From 3ea035d188b315453813fed0d1a41d79c4787ea3 Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Thu, 28 Jan 2016 15:24:24 +0000 Subject: [PATCH 29/40] rename test to be more clear --- tests/{Die on fail. => Exit on fail if -e is passed.} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/{Die on fail. => Exit on fail if -e is passed.} (100%) diff --git a/tests/Die on fail. b/tests/Exit on fail if -e is passed. similarity index 100% rename from tests/Die on fail. rename to tests/Exit on fail if -e is passed. -- 2.39.5 From da6d89aa56b2747dd6f0690f6ad3218518e79a62 Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Thu, 28 Jan 2016 15:27:32 +0000 Subject: [PATCH 30/40] add to change log --- HISTORY | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/HISTORY b/HISTORY index a9bf61a..e838d1d 100644 --- a/HISTORY +++ b/HISTORY @@ -1,6 +1,15 @@ HISTORY ------- +Version 0.0.6 +--------------------- + +* Produce TAP output with the -t flag. +* Correct some things in the documentation. +* Rearrange things in the documentation to be more clear. +* Pass the -e flag to exit urchin if any single test fails. +* Remove the undocumented, experimental -x flag now that shall exists. + Version 0.0.5 --------------------- * urchin now unsets `CDPATH`. -- 2.39.5 From 42dd0947e8629386116f260d4e90530e66a51c0a Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Thu, 28 Jan 2016 15:28:36 +0000 Subject: [PATCH 31/40] more changes --- HISTORY | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/HISTORY b/HISTORY index e838d1d..9d882b3 100644 --- a/HISTORY +++ b/HISTORY @@ -1,10 +1,13 @@ HISTORY -------- +======= Version 0.0.6 --------------------- * Produce TAP output with the -t flag. +* Add a + sign in front of directories in the normal output so that they + line up with non-directories. +* Display skipped tests in the normal output and in the TAP output. * Correct some things in the documentation. * Rearrange things in the documentation to be more clear. * Pass the -e flag to exit urchin if any single test fails. -- 2.39.5 From 8bdd00c3e9d3d467cc4727aa82e86d9bea0ac9b0 Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Thu, 28 Jan 2016 15:30:59 +0000 Subject: [PATCH 32/40] explain the branching --- HISTORY | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/HISTORY b/HISTORY index 9d882b3..307391c 100644 --- a/HISTORY +++ b/HISTORY @@ -13,6 +13,10 @@ Version 0.0.6 * Pass the -e flag to exit urchin if any single test fails. * Remove the undocumented, experimental -x flag now that shall exists. +These changes are made somewhat separately in the branches "exit-on-fail", +"remove-urchin-x", "tap", and "update-readme". They are rebased into one +branch, "tlevine-2016-02", for merging into "master". + Version 0.0.5 --------------------- * urchin now unsets `CDPATH`. -- 2.39.5 From bc74b20c5c0c2a1fbba493b7b77b10412349ce9e Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Thu, 28 Jan 2016 15:33:43 +0000 Subject: [PATCH 33/40] add authors --- AUTHORS | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 AUTHORS diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..d066057 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,9 @@ +Authors +------- +David Jones +Michael Klement +Thomas Levine + +Maintainer +------- +Thomas Levine <_@thomaslevine.com> -- 2.39.5 From d7c8549206d7dfc44f376ae2fcc3742d9b81fb30 Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Fri, 29 Jan 2016 17:14:34 +0000 Subject: [PATCH 34/40] urchin -v test --- tests/Print version on -v. | 2 ++ 1 file changed, 2 insertions(+) create mode 100755 tests/Print version on -v. diff --git a/tests/Print version on -v. b/tests/Print version on -v. new file mode 100755 index 0000000..6a21714 --- /dev/null +++ b/tests/Print version on -v. @@ -0,0 +1,2 @@ +#!/bin/sh +../urchin -v | grep '[0-9.]\{3,\}' -- 2.39.5 From 3f05794d7e5317229bbc585fdd36ac82b1ce3366 Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Fri, 29 Jan 2016 17:16:01 +0000 Subject: [PATCH 35/40] add -v to usage --- urchin | 1 + 1 file changed, 1 insertion(+) diff --git a/urchin b/urchin index 4b02fa8..b067f48 100755 --- a/urchin +++ b/urchin @@ -167,6 +167,7 @@ $USAGE contain the word "test". -t Format output in Test Anything Protocol (TAP) -h This help. +-v Display the version number. Go to https://github.com/tlevine/urchin for documentation on writing tests. -- 2.39.5 From d96f3707e9e31cccf4aa1bab7b3c0bd8fe703e9f Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Fri, 29 Jan 2016 17:17:31 +0000 Subject: [PATCH 36/40] implement -v --- urchin | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/urchin b/urchin index b067f48..a1e9b7e 100755 --- a/urchin +++ b/urchin @@ -4,6 +4,9 @@ # which breaks fullpath(). unset CDPATH +# Urchin version number +VERSION=0.0.6 + fullpath() { ( cd -- "$1" @@ -259,6 +262,8 @@ do -t) tap_format=true;; -h|--help) urchin_help exit 0;; + -v) echo "$VERSION" + exit;; -*) urchin_help >&2 exit 1;; *) break;; -- 2.39.5 From 31023bce21a5f0fee9fd03f28ec0757ba0e432c7 Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Fri, 29 Jan 2016 17:17:35 +0000 Subject: [PATCH 37/40] update HISTORY --- HISTORY | 1 + 1 file changed, 1 insertion(+) diff --git a/HISTORY b/HISTORY index 307391c..60523b8 100644 --- a/HISTORY +++ b/HISTORY @@ -12,6 +12,7 @@ Version 0.0.6 * Rearrange things in the documentation to be more clear. * Pass the -e flag to exit urchin if any single test fails. * Remove the undocumented, experimental -x flag now that shall exists. +* Display version number with the -v flag. These changes are made somewhat separately in the branches "exit-on-fail", "remove-urchin-x", "tap", and "update-readme". They are rebased into one -- 2.39.5 From 655daf4b74631ffd1cd1536cc81db377128a6b83 Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Fri, 29 Jan 2016 17:19:14 +0000 Subject: [PATCH 38/40] show all counts in cross-shell-tests runner It previously just showed the last three lines. It needs to show the last four lines now because urchin now displays skipped tests. --- cross-shell-tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cross-shell-tests b/cross-shell-tests index c0a2b08..a169ad8 100755 --- a/cross-shell-tests +++ b/cross-shell-tests @@ -6,7 +6,7 @@ for shell in dash bash ksh zsh; do if which $shell > /dev/null 2> /dev/null; then echo echo Running urchin tests in $shell - $shell urchin -s $shell tests | tail -n 3 + $shell urchin -s $shell tests | tail -n 4 else echo echo Skipping $shell because it is not in the PATH -- 2.39.5 From 2be01512137092d2888c7fb2295dba59342114e5 Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Fri, 29 Jan 2016 17:20:18 +0000 Subject: [PATCH 39/40] document the --help flag --- urchin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/urchin b/urchin index a1e9b7e..aa10e5d 100755 --- a/urchin +++ b/urchin @@ -169,7 +169,7 @@ $USAGE -f Force running even if the test directory's name does not contain the word "test". -t Format output in Test Anything Protocol (TAP) --h This help. +-h, --help This help. -v Display the version number. Go to https://github.com/tlevine/urchin for documentation on writing tests. -- 2.39.5 From 96ab43c2338eb13bc030503ed8192f2af1aa60de Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Fri, 29 Jan 2016 17:28:26 +0000 Subject: [PATCH 40/40] explain why urchin is called urchin --- HISTORY | 1 + readme.md | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/HISTORY b/HISTORY index 60523b8..172e137 100644 --- a/HISTORY +++ b/HISTORY @@ -13,6 +13,7 @@ Version 0.0.6 * Pass the -e flag to exit urchin if any single test fails. * Remove the undocumented, experimental -x flag now that shall exists. * Display version number with the -v flag. +* Document why Urchin is called "Urchin" These changes are made somewhat separately in the branches "exit-on-fail", "remove-urchin-x", "tap", and "update-readme". They are rebased into one diff --git a/readme.md b/readme.md index e4a9496..722c6e5 100644 --- a/readme.md +++ b/readme.md @@ -8,6 +8,10 @@ Urchin is a file-based test harness, normally used for testing shell programs. It is written in portable shell and should thus work on GNU/Linux, BSD (including Mac OS X), and other Unix-like platforms. +Urchin is called "Urchin" because +[sea urchins](https://en.wikipedia.org/wiki/Sea_urchin) +have shells called "tests". + ## Try it out Urchin's tests are written in Urchin, so you can run them to see what Urchin is like. Clone the repository -- 2.39.5