From fbaed9c4657e8df10236f17b5d79a71d2b94ce1f Mon Sep 17 00:00:00 2001 From: Henk Langeveld Date: Sun, 19 Apr 2015 02:09:07 +0200 Subject: [PATCH 01/21] Remove unnecessary quotes Remove quotes from command substitution when used in an assignment. Two assertions were reading file VERSION where once is sufficient. --- bin/shpec | 2 +- shpec/shpec_shpec.sh | 33 +++++++++++++++++---------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/bin/shpec b/bin/shpec index d00113d..9b18638 100755 --- a/bin/shpec +++ b/bin/shpec @@ -103,7 +103,7 @@ assert() { "Expected file [$2] not to exist" ;; xsymlink ) - link="$(readlink $2)" + link=$(readlink $2) print_result "[ '$link' = '$3' ]" \ "Expected [$2] to link to [$3], but got [$link]" ;; diff --git a/shpec/shpec_shpec.sh b/shpec/shpec_shpec.sh index 67cfd5a..086e454 100644 --- a/shpec/shpec_shpec.sh +++ b/shpec/shpec_shpec.sh @@ -69,24 +69,25 @@ line' end end - describe "stubbing commands" - it "stubs to the null command by default" + describe "'stub_command'" + it "defaults to the null command" stub_command "false" false # doesn't do anything assert equal "$?" 0 - unstub_command "false" - end - it "preserves the original working of the stub" - false - assert equal "$?" 1 end - it "accepts an optional function body" stub_command "curl" "echo 'stubbed body'" assert equal "$(curl)" "stubbed body" unstub_command "curl" end end + describe "'unstub_command'" + it "restores the original working" + unstub_command "false" + false + assert equal "$?" 1 + end + end describe "testing files" it "asserts file absence" @@ -126,36 +127,36 @@ line' describe "output" it "outputs passing tests to STDOUT" - message="$(. $SHPEC_ROOT/etc/passing_example)" + message=$(. $SHPEC_ROOT/etc/passing_example) assert match "$message" "a\ passing\ test" end it "outputs failing tests to STDOUT" - message="$(. $SHPEC_ROOT/etc/failing_example)" + message=$(. $SHPEC_ROOT/etc/failing_example) assert match "$message" "a\ failing\ test" end end describe "commandline options" - + _v=$(cat $SHPEC_ROOT/../VERSION) describe "--version" it "outputs the current version number" - message="$(shpec --version)" - assert match "$message" "$(cat $SHPEC_ROOT/../VERSION)" + message=$(shpec --version) + assert match "$message" "$_v" end end describe "-v" it "outputs the current version number" - message="$(shpec -v)" - assert match "$message" "$(cat $SHPEC_ROOT/../VERSION)" + message=$(shpec -v) + assert match "$message" "$_v" end end end describe "compatibility" it "works with old-style syntax" - message="$(. $SHPEC_ROOT/etc/old_example)" + message=$(. $SHPEC_ROOT/etc/old_example) assert match "$message" "old\ example" end end From bbf770fe70cef8da953060f9ef8d7f9bfb815591 Mon Sep 17 00:00:00 2001 From: Henk Langeveld Date: Sun, 19 Apr 2015 03:31:12 +0200 Subject: [PATCH 02/21] Add skip support Adds function `skip`. If a test invokes `skip` prior to an assertion, the assertion will be resolved, but failing match will not result in a failure, and instead count as a *skipped* test. This update adds counters for passed and skipped tests. This also changes the summary line, and color codes. A third color is introduced for skipped tests: yellow. The summary line will report numbers in black, with the words 'failures', 'passed', and 'skipped' in red, green, and yellow, respectively. Finally, tests are included for the presence of a terminal. If no terminal is present, color codes are replaced as follows: green OK passed red NO failed yellow ?? skipped --- bin/shpec | 45 +++++++++++++++++++++++++++++++++++++------- shpec/shpec_shpec.sh | 13 +++++++++++++ 2 files changed, 51 insertions(+), 7 deletions(-) diff --git a/bin/shpec b/bin/shpec index 9b18638..f955976 100755 --- a/bin/shpec +++ b/bin/shpec @@ -61,6 +61,10 @@ it() { assert() { case "x$1" in + xfail ) + print_result "false" \ + "Always fails" + ;; xequal ) print_result "[ '$(sanitize "$2")' = '$(sanitize "$3")' ]" \ "Expected [$2] to equal [$3]" @@ -122,13 +126,26 @@ assert() { esac } +skip() { : $((_skipping+=1)); } +noskip() { [ ${_skipping} -eq 0 ]; } +_skipped(){ : $((_skipping-=1)); } + print_result() { if eval "$1"; then + : $((passed += 1)) iecho "$green$assertion$norm" - else + return + fi + + if noskip; then : $((failures += 1)) - iecho "$red$assertion" - iecho "($2)$norm" + iecho "$red$assertion$norm" + iecho "($2)" + else + _skipped + : $((skipped += 1)) + iecho "$yellow$assertion$norm" + iecho "($2)" fi } @@ -143,12 +160,21 @@ shpec() { ) examples=0 failures=0 - test_indent=0 + passed=0 + skipped=0 + + test_indent=0 _skipping=0 + red="\033[0;31m" green="\033[0;32m" + yellow="\033[0;33m" norm="\033[0m" + [ -t 0 ] || red="NO " green="OK " yellow="?? " norm= + + SHPEC_ROOT=${SHPEC_ROOT:-$( + [ -d './shpec' ] && echo './shpec' || echo '.' + )} - SHPEC_ROOT=${SHPEC_ROOT:-$([ -d './shpec' ] && echo './shpec' || echo '.')} case "$1" in ( -v | --version ) echo "$VERSION" ;; @@ -173,8 +199,13 @@ shpec() { . "$file" done - [ $failures -eq 0 ] && color=$green || color=$red - echoe "${color}${examples} examples, ${failures} failures${norm}" + ( + [ -t 0 ] || red= green= yellow= norm= + echoe "${examples} ${norm}examples," \ + "${passed} ${green}passed${norm}" \ + "${failures} ${red}failures${norm}" \ + "${skipped} ${yellow}skipped${norm}" + ) times [ $failures -eq 0 ] diff --git a/shpec/shpec_shpec.sh b/shpec/shpec_shpec.sh index 086e454..d68be8a 100644 --- a/shpec/shpec_shpec.sh +++ b/shpec/shpec_shpec.sh @@ -160,4 +160,17 @@ line' assert match "$message" "old\ example" end end + + describe "skip" + it "skips this failing test" + skip + assert fail + end + end + + describe "fail" + it "fails this test (EXPECTED)" + assert fail + end + end end From 4ce719d0c24de5707abc3a5ba60e3ae737774bbb Mon Sep 17 00:00:00 2001 From: Henk Langeveld Date: Sun, 19 Apr 2015 12:17:12 +0200 Subject: [PATCH 03/21] Does travis support sh as a language? --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f4638da..22f129f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,2 +1,2 @@ -language: c +language: sh script: bin/shpec From 934db77adb24d96f807e834187329bc70b0cb786 Mon Sep 17 00:00:00 2001 From: Henk Langeveld Date: Sun, 19 Apr 2015 12:23:52 +0200 Subject: [PATCH 04/21] Tell travis what to expect And that's 1 failure and 1 skipped assertion. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 22f129f..3041a0e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,2 +1,2 @@ language: sh -script: bin/shpec +script: bin/shpec | grep ' 1 .*failures.* 1 skipped' From d35fa6a0e7b61b2fae31502b44fcd7cf750c987a Mon Sep 17 00:00:00 2001 From: Henk Langeveld Date: Sun, 19 Apr 2015 12:49:13 +0200 Subject: [PATCH 05/21] Add option for expected number of failures --- .travis.yml | 2 +- bin/shpec | 27 +++++++++++++++++++++++---- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3041a0e..717b4e2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,2 +1,2 @@ language: sh -script: bin/shpec | grep ' 1 .*failures.* 1 skipped' +script: bin/shpec -f 1 diff --git a/bin/shpec b/bin/shpec index f955976..15f88c5 100755 --- a/bin/shpec +++ b/bin/shpec @@ -159,7 +159,7 @@ shpec() { echo $MAJOR.$MINOR.$PATCH ) examples=0 - failures=0 + failures=0 expected_failures=0 passed=0 skipped=0 @@ -175,9 +175,28 @@ shpec() { [ -d './shpec' ] && echo './shpec' || echo '.' )} + while option=$1 + do + case $option in + ( -v | --version ) + echo "$VERSION" + exit 0 + ;; + ( -f | --failures ) + shift + expected_failures=$1 shift + ;; + (--) shift + break + ;; + (-* | --*) shift + printf -u2 -- "%s: no such option\n" $option + ;; + (*) break + esac + done + case "$1" in - ( -v | --version ) echo "$VERSION" - ;; ( * ) matcher_files=$( find "$SHPEC_ROOT/matchers" -name '*.sh' 2>/dev/null @@ -208,7 +227,7 @@ shpec() { ) times - [ $failures -eq 0 ] + [ $failures -eq $expected_failures ] exit ;; esac From 8adb1cb50e01a95ff28bbed7d313a6a2bbe3c759 Mon Sep 17 00:00:00 2001 From: Henk Langeveld Date: Sun, 19 Apr 2015 13:02:23 +0200 Subject: [PATCH 06/21] add trace --- bin/shpec | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/shpec b/bin/shpec index 15f88c5..096cb6c 100755 --- a/bin/shpec +++ b/bin/shpec @@ -182,7 +182,7 @@ shpec() { echo "$VERSION" exit 0 ;; - ( -f | --failures ) + ( -f ) shift expected_failures=$1 shift ;; @@ -190,7 +190,7 @@ shpec() { break ;; (-* | --*) shift - printf -u2 -- "%s: no such option\n" $option + printf -u2 -- "%s: no such option\n" $option ;; (*) break esac @@ -227,6 +227,8 @@ shpec() { ) times + + set -x [ $failures -eq $expected_failures ] exit ;; From 0bd8503eb77d80d8dd607dbcc466f5709e8161ec Mon Sep 17 00:00:00 2001 From: Henk Langeveld Date: Sun, 19 Apr 2015 17:04:13 +0200 Subject: [PATCH 07/21] Skip exitonerror `set -e` for expected fails Sometimes you want a test or assertion to Fail *visibly*. However, we also want to use the shell `-e`, or *exit on error* option. This extends the expected failure matcher with a temporary suspension of that option. --- bin/shpec | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/shpec b/bin/shpec index 096cb6c..d4a92d3 100755 --- a/bin/shpec +++ b/bin/shpec @@ -62,8 +62,10 @@ it() { assert() { case "x$1" in xfail ) + set +e print_result "false" \ "Always fails" + set -e ;; xequal ) print_result "[ '$(sanitize "$2")' = '$(sanitize "$3")' ]" \ From 8d133e4934ee66cfb0aa4e854f95149b2f949d35 Mon Sep 17 00:00:00 2001 From: Henk Langeveld Date: Mon, 20 Apr 2015 00:18:49 +0200 Subject: [PATCH 08/21] Stop checking status of a shpec file. Except for an example test, `shpec` itself does not check the results of a sourced file. --- bin/shpec | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/shpec b/bin/shpec index d4a92d3..cf65d6f 100755 --- a/bin/shpec +++ b/bin/shpec @@ -32,9 +32,9 @@ describe() { end() { : $((test_indent -= 1)) - if [ $test_indent -eq 0 ]; then - [ $failures -eq 0 ] - fi + [ $test_indent -ge 0 ] && return + printf -u 2 "Syntax Error in ${_shpec_file} file\n" + exit 1 } end_describe() { From a3cef2e3d7c0363ce63c4ed62a06b8ea77a1a871 Mon Sep 17 00:00:00 2001 From: Henk Langeveld Date: Mon, 20 Apr 2015 00:25:29 +0200 Subject: [PATCH 09/21] Add strict shell error checking shell options now enabled -e Exit on error. Can be suspended temporarily for some tests. -u Error on undefined variables. Checking for errors requires that we capture exit status for failing commands with `|| _r=$?` The `||` will prevent error exit, while the assignment preserves the exit status for the actual assertion. --- bin/shpec | 11 ++++++----- shpec/shpec_shpec.sh | 8 ++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/bin/shpec b/bin/shpec index cf65d6f..603775f 100755 --- a/bin/shpec +++ b/bin/shpec @@ -28,6 +28,7 @@ sanitize() { describe() { : $((test_indent += 1)) iecho "$1" + set -e } end() { @@ -43,9 +44,6 @@ end_describe() { end } -# Beware: POSIX shells are not required to accept -# any identifier as a function name. - stub_command() { body="${2:-:}" eval "$1() { $body; }" @@ -57,6 +55,8 @@ it() { : $((test_indent += 1)) : $((examples += 1)) assertion="$1" + _r=0 + set -e } assert() { @@ -65,7 +65,6 @@ assert() { set +e print_result "false" \ "Always fails" - set -e ;; xequal ) print_result "[ '$(sanitize "$2")' = '$(sanitize "$3")' ]" \ @@ -154,6 +153,7 @@ print_result() { shpec() { ( + set -u -e VERSION=$( MAJOR=0 MINOR=2 @@ -177,8 +177,9 @@ shpec() { [ -d './shpec' ] && echo './shpec' || echo '.' )} - while option=$1 + while [ $# -gt 0 ] do + option=$1 case $option in ( -v | --version ) echo "$VERSION" diff --git a/shpec/shpec_shpec.sh b/shpec/shpec_shpec.sh index d68be8a..59bd08e 100644 --- a/shpec/shpec_shpec.sh +++ b/shpec/shpec_shpec.sh @@ -84,8 +84,8 @@ line' describe "'unstub_command'" it "restores the original working" unstub_command "false" - false - assert equal "$?" 1 + (false) || _r=$? + assert equal "$_r" 1 end end @@ -115,8 +115,8 @@ line' describe "exit codes" it "returns nonzero if any test fails" - shpec $SHPEC_ROOT/etc/failing_example > /dev/null 2>& 1 - assert unequal "$?" "0" + shpec $SHPEC_ROOT/etc/failing_example > /dev/null 2>& 1 || _r=$? + assert unequal "$_r" "0" end it "returns zero if a suite passes" From 08d362da56690f9428f6841b42a8fa36f8164f3a Mon Sep 17 00:00:00 2001 From: Henk Langeveld Date: Mon, 20 Apr 2015 00:38:10 +0200 Subject: [PATCH 10/21] Add double parentheses for all case labels POSIX case labels can have balanced parentheses now. Fixes a minor annoyance with editors like vi[m]. --- bin/shpec | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/bin/shpec b/bin/shpec index 603775f..ac254af 100755 --- a/bin/shpec +++ b/bin/shpec @@ -61,68 +61,68 @@ it() { assert() { case "x$1" in - xfail ) + ( xfail ) set +e print_result "false" \ "Always fails" ;; - xequal ) + ( xequal ) print_result "[ '$(sanitize "$2")' = '$(sanitize "$3")' ]" \ "Expected [$2] to equal [$3]" ;; - xunequal ) + ( xunequal ) print_result "[ '$(sanitize "$2")' != '$(sanitize "$3")' ]" \ "Expected [$2] not to equal [$3]" ;; - xgt ) + ( xgt ) print_result "[ $2 -gt $3 ]" \ "Expected [$2] to be > [$3]" ;; - xlt ) + ( xlt ) print_result "[ $2 -lt $3 ]" \ "Expected [$2] to be < [$3]" ;; - xmatch ) + ( xmatch ) print_result "case '$2' in *$3*) :;; *) false;; esac" \ "Expected [$2] to match [$3]" ;; - xno_match ) + ( xno_match ) print_result "case '$2' in *$3*) false ;; *) :;; esac" \ "Expected [$2] not to match [$3]" ;; - xpresent ) + ( xpresent ) print_result "[ -n '$2' ]" \ "Expected [$2] to be present" ;; - xblank ) + ( xblank ) print_result "[ -z '$2' ]" \ "Expected [$2] to be blank" ;; - - xfile_present ) + ( xfile_present ) print_result "[ -e $2 ]" \ "Expected file [$2] to exist" ;; - xfile_absent ) + ( xfile_absent ) print_result "[ ! -e $2 ]" \ "Expected file [$2] not to exist" ;; - xsymlink ) + ( xsymlink ) link=$(readlink $2) print_result "[ '$link' = '$3' ]" \ "Expected [$2] to link to [$3], but got [$link]" ;; - xtest ) + ( xtest ) print_result "$2" \ "Expected $2 to be true" ;; - * ) - if type "$1" 2>/dev/null | grep -q 'function'; then + ( * ) + case "$(type $1)" in + (*function*) matcher="$1"; shift $matcher "$@" - else - print_result false "Error: Unknown matcher [$1]" - fi + return + esac + print_result false "Error: Unknown matcher [$1]" ;; esac } From e24c2708f909b71125a9338649f9b76414377d19 Mon Sep 17 00:00:00 2001 From: Henk Langeveld Date: Mon, 20 Apr 2015 00:44:23 +0200 Subject: [PATCH 11/21] Rename `skip` to `skip_next_assert` Using `skip_next_assert` is more explicit about what it does. It implies that normal processing is restored *after* the assertion. --- bin/shpec | 6 +++--- shpec/shpec_shpec.sh | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/shpec b/bin/shpec index ac254af..3833088 100755 --- a/bin/shpec +++ b/bin/shpec @@ -127,8 +127,8 @@ assert() { esac } -skip() { : $((_skipping+=1)); } -noskip() { [ ${_skipping} -eq 0 ]; } +skip_next_assert() { : $((_skipping+=1)); } +not_skipping() { [ ${_skipping} -eq 0 ]; } _skipped(){ : $((_skipping-=1)); } print_result() { @@ -138,7 +138,7 @@ print_result() { return fi - if noskip; then + if not_skipping; then : $((failures += 1)) iecho "$red$assertion$norm" iecho "($2)" diff --git a/shpec/shpec_shpec.sh b/shpec/shpec_shpec.sh index 59bd08e..1d43bf4 100644 --- a/shpec/shpec_shpec.sh +++ b/shpec/shpec_shpec.sh @@ -163,7 +163,7 @@ line' describe "skip" it "skips this failing test" - skip + skip_next_assert assert fail end end From ec3593c2b28bafbc5824d0d40a2458785b2729ac Mon Sep 17 00:00:00 2001 From: Henk Langeveld Date: Mon, 20 Apr 2015 00:52:06 +0200 Subject: [PATCH 12/21] Add function terminal_input() The function name clarifies the meaning to the reader. --- bin/shpec | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bin/shpec b/bin/shpec index 3833088..16d5bf4 100755 --- a/bin/shpec +++ b/bin/shpec @@ -171,7 +171,11 @@ shpec() { green="\033[0;32m" yellow="\033[0;33m" norm="\033[0m" - [ -t 0 ] || red="NO " green="OK " yellow="?? " norm= + + terminal_input(){ [ -t 0 ]; } + + terminal_input || + red="NO " green="OK " yellow="?? " norm= SHPEC_ROOT=${SHPEC_ROOT:-$( [ -d './shpec' ] && echo './shpec' || echo '.' From 4464d9197b433deeaff981033ec21b0873a49c00 Mon Sep 17 00:00:00 2001 From: Henk Langeveld Date: Mon, 20 Apr 2015 01:00:56 +0200 Subject: [PATCH 13/21] Remove redundant `case` block, add final report The second `case` block contained only one entry. Removed the case clutter. Integrate failure count into final report and `shpec` exit status/return value. --- bin/shpec | 91 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 50 insertions(+), 41 deletions(-) diff --git a/bin/shpec b/bin/shpec index 16d5bf4..1045561 100755 --- a/bin/shpec +++ b/bin/shpec @@ -150,6 +150,19 @@ print_result() { fi } +report_expected_failure_count() { + [ ${expected_failures} -gt 0 ] && + echo ", ${expected_failures} failures expected." +} + +exit_with_expected_failures() { + if [ $failures -eq $expected_failures ] ; then + echo OK$( report_expected_failure_count ) + exit 0 + fi + echo NO$( report_expected_failure_count ) + exit 1 +} shpec() { ( @@ -172,9 +185,7 @@ shpec() { yellow="\033[0;33m" norm="\033[0m" - terminal_input(){ [ -t 0 ]; } - - terminal_input || + [ -t 0 ] || red="NO " green="OK " yellow="?? " norm= SHPEC_ROOT=${SHPEC_ROOT:-$( @@ -202,44 +213,42 @@ shpec() { (*) break esac done - - case "$1" in - ( * ) - matcher_files=$( - find "$SHPEC_ROOT/matchers" -name '*.sh' 2>/dev/null - ) - - for matcher_file in $matcher_files; do - . "$matcher_file" - done - - if [ $# -gt 0 ] ; then - files="${@}" - else - files=$( - find $SHPEC_ROOT -name '*_shpec.sh' - ) - fi - - for file in $files; do - . "$file" - done - - ( - [ -t 0 ] || red= green= yellow= norm= - echoe "${examples} ${norm}examples," \ - "${passed} ${green}passed${norm}" \ - "${failures} ${red}failures${norm}" \ - "${skipped} ${yellow}skipped${norm}" - ) - - times - - set -x - [ $failures -eq $expected_failures ] - exit - ;; - esac + + matcher_files=$( + find "$SHPEC_ROOT/matchers" -name '*.sh' 2>/dev/null + ) + + for matcher_file in $matcher_files; do + . "$matcher_file" + done + + if [ $# -gt 0 ] ; then + files="${@}" + else + files=$( + find $SHPEC_ROOT -name '*_shpec.sh' + ) + fi + + trap 'echo "Error processing ${_shpec_file:-unknown} file"; exit 1' 0 + + for _shpec_file in $files; do + . "${_shpec_file}" + done + + trap 0 + + ( + [ -t 0 ] || red= green= yellow= norm= + echoe "${examples} ${norm}examples," \ + "${passed} ${green}passed${norm}" \ + "${failures} ${red}failures${norm}" \ + "${skipped} ${yellow}skipped${norm}" + ) + + # times + + exit_with_expected_failures ) } From 9b1c1fbcd26f70ac45aabc7d3c7da155fc5e911a Mon Sep 17 00:00:00 2001 From: Henk Langeveld Date: Mon, 20 Apr 2015 01:11:00 +0200 Subject: [PATCH 14/21] Restore function `terminal_input()` --- bin/shpec | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/shpec b/bin/shpec index 1045561..77e76c5 100755 --- a/bin/shpec +++ b/bin/shpec @@ -164,6 +164,8 @@ exit_with_expected_failures() { exit 1 } +terminal_input(){ [ -t 0 ]; } + shpec() { ( set -u -e @@ -185,7 +187,7 @@ shpec() { yellow="\033[0;33m" norm="\033[0m" - [ -t 0 ] || + terminal_input || red="NO " green="OK " yellow="?? " norm= SHPEC_ROOT=${SHPEC_ROOT:-$( @@ -239,7 +241,7 @@ shpec() { trap 0 ( - [ -t 0 ] || red= green= yellow= norm= + terminal_input || red= green= yellow= norm= echoe "${examples} ${norm}examples," \ "${passed} ${green}passed${norm}" \ "${failures} ${red}failures${norm}" \ From 8e43a9a47f9872b3b2ca4abb967345bf13e1a1a4 Mon Sep 17 00:00:00 2001 From: Henk Langeveld Date: Mon, 20 Apr 2015 01:17:08 +0200 Subject: [PATCH 15/21] Fix indentation, split `-f` option processing Indentation was one level to high for a command substitution. `-f` option had assignment and shift in one line --- bin/shpec | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bin/shpec b/bin/shpec index 77e76c5..243a387 100755 --- a/bin/shpec +++ b/bin/shpec @@ -191,7 +191,7 @@ shpec() { red="NO " green="OK " yellow="?? " norm= SHPEC_ROOT=${SHPEC_ROOT:-$( - [ -d './shpec' ] && echo './shpec' || echo '.' + [ -d './shpec' ] && echo './shpec' || echo '.' )} while [ $# -gt 0 ] @@ -202,9 +202,10 @@ shpec() { echo "$VERSION" exit 0 ;; - ( -f ) + ( -f ) + shift + expected_failures=$1 shift - expected_failures=$1 shift ;; (--) shift break From 179b5d572b928ad1f23b6345403f193e70ea2420 Mon Sep 17 00:00:00 2001 From: Henk Langeveld Date: Mon, 20 Apr 2015 01:20:15 +0200 Subject: [PATCH 16/21] Rename var _v to _version --- shpec/shpec_shpec.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/shpec/shpec_shpec.sh b/shpec/shpec_shpec.sh index 1d43bf4..ceffb9e 100644 --- a/shpec/shpec_shpec.sh +++ b/shpec/shpec_shpec.sh @@ -138,18 +138,18 @@ line' end describe "commandline options" - _v=$(cat $SHPEC_ROOT/../VERSION) + _version=$(cat $SHPEC_ROOT/../VERSION) describe "--version" it "outputs the current version number" - message=$(shpec --version) - assert match "$message" "$_v" + message=$( shpec --version ) + assert match "$message" "$_version" end end describe "-v" it "outputs the current version number" - message=$(shpec -v) - assert match "$message" "$_v" + message=$( shpec -v ) + assert match "$message" "$_version" end end end From 4de1f08bc8a47ddb32ee8d3d9e60929943cb0801 Mon Sep 17 00:00:00 2001 From: Henk Langeveld Date: Mon, 20 Apr 2015 01:21:34 +0200 Subject: [PATCH 17/21] See if we can make travis run three shells --- .travis.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 717b4e2..37fc351 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,2 +1,5 @@ language: sh -script: bin/shpec -f 1 +script: + - time bash bin/shpec -f 1 shpec/shpec_shpec.sh + - time dash bin/shpec -f 1 shpec/shpec_shpec.sh + - time ksh bin/shpec -f 1 shpec/shpec_shpec.sh From 1bc3a779732294f910644eb788799d85e62e8cf5 Mon Sep 17 00:00:00 2001 From: Henk Langeveld Date: Mon, 20 Apr 2015 01:30:04 +0200 Subject: [PATCH 18/21] Add ksh --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 37fc351..0f06e26 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,3 +3,6 @@ script: - time bash bin/shpec -f 1 shpec/shpec_shpec.sh - time dash bin/shpec -f 1 shpec/shpec_shpec.sh - time ksh bin/shpec -f 1 shpec/shpec_shpec.sh +before_install: + - sudo apt-get update -qq + - sudo apt-get install -y ksh From 19938dba648f2c84bc2d397b13085bc7488dacde Mon Sep 17 00:00:00 2001 From: Henk Langeveld Date: Mon, 20 Apr 2015 01:36:53 +0200 Subject: [PATCH 19/21] Rename skip test to match new keyword. We renamed the keyword to `skip_next_assert` but did not change the name of the test. Fixed now. --- shpec/shpec_shpec.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shpec/shpec_shpec.sh b/shpec/shpec_shpec.sh index ceffb9e..2ca469b 100644 --- a/shpec/shpec_shpec.sh +++ b/shpec/shpec_shpec.sh @@ -161,7 +161,7 @@ line' end end - describe "skip" + describe "skip_next_assert" it "skips this failing test" skip_next_assert assert fail From b09d8ec7c5024faa0e057e6c187ae29b3ad000f7 Mon Sep 17 00:00:00 2001 From: chris Date: Mon, 20 Apr 2015 10:16:46 +1000 Subject: [PATCH 20/21] Split travis tests up --- .travis.yml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0f06e26..33a84a0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,15 @@ language: sh +env: + matrix: + - SHELL=bash + - SHELL=dash + - SHELL=ksh script: - - time bash bin/shpec -f 1 shpec/shpec_shpec.sh - - time dash bin/shpec -f 1 shpec/shpec_shpec.sh - - time ksh bin/shpec -f 1 shpec/shpec_shpec.sh + - time $SHELL bin/shpec -f 1 shpec/shpec_shpec.sh +cache: apt before_install: - - sudo apt-get update -qq - - sudo apt-get install -y ksh + - > + if ! type $SHELL > /dev/null; then + sudo apt-get update -qq + sudo apt-get install -y $SHELL + fi From 816e577c90ccd63bac5ed034589c6c196d20ac22 Mon Sep 17 00:00:00 2001 From: chris Date: Mon, 20 Apr 2015 14:44:56 +1000 Subject: [PATCH 21/21] Allow failures in zsh --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 33a84a0..444a863 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,10 @@ env: - SHELL=bash - SHELL=dash - SHELL=ksh + - SHELL=zsh +matrix: + allow_failures: + - env: SHELL=zsh script: - time $SHELL bin/shpec -f 1 shpec/shpec_shpec.sh cache: apt