[gjs/wip/ptomato/tests: 6/12] build: Convert testCommandLine.sh to output TAP
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/wip/ptomato/tests: 6/12] build: Convert testCommandLine.sh to output TAP
- Date: Wed, 26 Oct 2016 08:01:43 +0000 (UTC)
commit 15bd3af986488e50f5485a81f5d61218a121bc0d
Author: Philip Chimento <philip chimento gmail com>
Date: Sat Oct 22 23:52:31 2016 -0700
build: Convert testCommandLine.sh to output TAP
It's nice to be able to see in the test output what exactly is failing.
Makefile-test.am | 3 -
test/testCommandLine.sh | 96 ++++++++++++++++++++++++++++-------------------
2 files changed, 57 insertions(+), 42 deletions(-)
---
diff --git a/Makefile-test.am b/Makefile-test.am
index 33104f7..359a357 100644
--- a/Makefile-test.am
+++ b/Makefile-test.am
@@ -139,9 +139,6 @@ TESTS += $(simple_tests)
LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/tap-driver.sh
LOG_COMPILER = $(top_srcdir)/test/run-test
-TEST_EXTENSIONS = .sh
-SH_LOG_COMPILER = sh
-
if CODE_COVERAGE_ENABLED
AM_TESTS_ENVIRONMENT += \
export GJS_UNIT_COVERAGE_OUTPUT=lcov; \
diff --git a/test/testCommandLine.sh b/test/testCommandLine.sh
index 417ab16..8ca2f78 100755
--- a/test/testCommandLine.sh
+++ b/test/testCommandLine.sh
@@ -1,4 +1,4 @@
-#!/bin/sh -e
+#!/bin/sh
gjs="$TOP_BUILDDIR"/gjs-console
@@ -13,65 +13,83 @@ if (ARGV.indexOf('--help') == -1)
System.exit(0);
EOF
-fail () {
- >&2 echo "FAIL: $1"
- exit 1
+total=0
+
+report () {
+ exit_code=$?
+ total=`expr $total + 1`
+ if test $exit_code -eq 0; then
+ echo "ok $total - $1"
+ else
+ echo "not ok $total - $1"
+ fi
+}
+
+report_xfail () {
+ exit_code=$?
+ total=`expr $total + 1`
+ if test $exit_code -ne 0; then
+ echo "ok $total - $1"
+ else
+ echo "not ok $total - $1"
+ fi
}
# gjs --help prints GJS help
-"$gjs" --help >/dev/null || \
- fail "--help should succeed"
-test -n "`"$gjs" --help`" || \
- fail "--help should print something"
+"$gjs" --help >/dev/null
+report "--help should succeed"
+test -n "`"$gjs" --help`"
+report "--help should print something"
# print GJS help even if it's not the first argument
-"$gjs" -I . --help >/dev/null || \
- fail "should succeed when --help is not first arg"
-test -n "`"$gjs" -I . --help`" || \
- fail "should print something when --help is not first arg"
+"$gjs" -I . --help >/dev/null
+report "should succeed when --help is not first arg"
+test -n "`"$gjs" -I . --help`"
+report "should print something when --help is not first arg"
# --help before a script file name prints GJS help
-"$gjs" --help help.js >/dev/null || \
- fail "--help should succeed before a script file"
-test -n "`"$gjs" --help help.js`" || \
- fail "--help should print something before a script file"
+"$gjs" --help help.js >/dev/null
+report "--help should succeed before a script file"
+test -n "`"$gjs" --help help.js`"
+report "--help should print something before a script file"
# --help before a -c argument prints GJS help
script='imports.system.exit(1)'
-"$gjs" --help -c "$script" >/dev/null || \
- fail "--help should succeed before -c"
-test -n "`"$gjs" --help -c "$script"`" || \
- fail "--help should print something before -c"
+"$gjs" --help -c "$script" >/dev/null
+report "--help should succeed before -c"
+test -n "`"$gjs" --help -c "$script"`"
+report "--help should print something before -c"
# --help after a script file name is passed to the script
-"$gjs" -I sentinel help.js --help || \
- fail "--help after script file should be passed to script"
-test -z "`"$gjs" -I sentinel help.js --help`" || \
- fail "--help after script file should not print anything"
+"$gjs" -I sentinel help.js --help
+report "--help after script file should be passed to script"
+test -z "`"$gjs" -I sentinel help.js --help`"
+report "--help after script file should not print anything"
# --help after a -c argument is passed to the script
script='if(ARGV[0] !== "--help") imports.system.exit(1)'
-"$gjs" -c "$script" --help || \
- fail "--help after -c should be passed to script"
-test -z "`"$gjs" -c "$script" --help`" || \
- fail "--help after -c should not print anything"
+"$gjs" -c "$script" --help
+report "--help after -c should be passed to script"
+test -z "`"$gjs" -c "$script" --help`"
+report "--help after -c should not print anything"
# -I after a program is not consumed by GJS
-if "$gjs" help.js --help -I sentinel; then
- fail "-I after script file should not be added to search path"
-fi
+"$gjs" help.js --help -I sentinel
+report_xfail "-I after script file should not be added to search path"
# --version works
-"$gjs" --version >/dev/null || \
- fail "--version should work"
-test -n "`"$gjs" --version`" || \
- fail "--version should print something"
+"$gjs" --version >/dev/null
+report "--version should work"
+test -n "`"$gjs" --version`"
+report "--version should print something"
# --version after a script goes to the script
script='if(ARGV[0] !== "--version") imports.system.exit(1)'
-"$gjs" -c "$script" --version || \
- fail "--version after -c should be passed to script"
-test -z "`"$gjs" -c "$script" --version`" || \
- fail "--version after -c should not print anything"
+"$gjs" -c "$script" --version
+report "--version after -c should be passed to script"
+test -z "`"$gjs" -c "$script" --version`"
+report "--version after -c should not print anything"
rm -f help.js
+
+echo "1..$total"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]