[gjs] build: Convert testCommandLine.sh to output TAP
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs] build: Convert testCommandLine.sh to output TAP
- Date: Wed, 30 Nov 2016 06:21:38 +0000 (UTC)
commit 5be2bb7d166e0bae62d5d9ea18fc404030c6dab9
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.
https://bugzilla.gnome.org/show_bug.cgi?id=775205
Makefile-test.am | 3 -
test/testCommandLine.sh | 107 +++++++++++++++++++++++++++-------------------
2 files changed, 63 insertions(+), 47 deletions(-)
---
diff --git a/Makefile-test.am b/Makefile-test.am
index 53a3040..0580162 100644
--- a/Makefile-test.am
+++ b/Makefile-test.am
@@ -128,9 +128,6 @@ LOG_COMPILER = $(top_srcdir)/test/run-test
AM_LOG_FLAGS =
endif !DBUS_TESTS
-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 89ada6c..7717ac0 100755
--- a/test/testCommandLine.sh
+++ b/test/testCommandLine.sh
@@ -1,4 +1,4 @@
-#!/bin/sh -e
+#!/bin/sh
gjs="$TOP_BUILDDIR"/gjs-console
@@ -13,72 +13,91 @@ 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
# Temporary behaviour: still consume the argument, but give a warning
-# if "$gjs" help.js --help -I sentinel; then
-# fail "-I after script file should not be added to search path"
+# "$gjs" help.js --help -I sentinel
+# report_xfail "-I after script file should not be added to search path"
# fi
-"$gjs" help.js --help -I sentinel 2>&1 | grep -q 'Gjs-WARNING.*--include-path' || \
- fail "-I after script should succeed but give a warning"
-"$gjs" -c 'imports.system.exit(0)' --coverage-prefix=foo --coverage-output=foo 2>&1 | grep -q
'Gjs-WARNING.*--coverage-prefix' || \
- fail "--coverage-prefix after script should succeed but give a warning"
-"$gjs" -c 'imports.system.exit(0)' --coverage-prefix=foo --coverage-output=foo 2>&1 | grep -q
'Gjs-WARNING.*--coverage-output' || \
- fail "--coverage-output after script should succeed but give a warning"
+"$gjs" help.js --help -I sentinel 2>&1 | grep -q 'Gjs-WARNING.*--include-path'
+report "-I after script should succeed but give a warning"
+"$gjs" -c 'imports.system.exit(0)' --coverage-prefix=foo --coverage-output=foo 2>&1 | grep -q
'Gjs-WARNING.*--coverage-prefix'
+report "--coverage-prefix after script should succeed but give a warning"
+"$gjs" -c 'imports.system.exit(0)' --coverage-prefix=foo --coverage-output=foo 2>&1 | grep -q
'Gjs-WARNING.*--coverage-output'
+report "--coverage-output after script should succeed but give a warning"
# --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]