diff options
author | Robert Collins <robertc@robertcollins.net> | 2006-04-15 00:25:55 +1000 |
---|---|---|
committer | Robert Collins <robertc@robertcollins.net> | 2006-04-15 00:25:55 +1000 |
commit | 3bebe681fc9c80ced4cfdda1b8624dd64074e83a (patch) | |
tree | e55e3a186572e33059d99a60e40ef3a88bb4387a /shell | |
parent | 2ae3f76ff0c7dbadda0b3802dbc2b6baf867fb68 (diff) | |
download | subunit-3bebe681fc9c80ced4cfdda1b8624dd64074e83a.tar.gz |
Test the output of subunit_start_test.
Diffstat (limited to 'shell')
-rw-r--r-- | shell/share/subunit.sh | 5 | ||||
-rw-r--r-- | shell/test_shell.py | 8 | ||||
-rwxr-xr-x | shell/tests/test_function_output.sh | 43 | ||||
-rwxr-xr-x | shell/tests/test_source_library.sh | 27 |
4 files changed, 79 insertions, 4 deletions
diff --git a/shell/share/subunit.sh b/shell/share/subunit.sh index f0f21d8..0234737 100644 --- a/shell/share/subunit.sh +++ b/shell/share/subunit.sh @@ -17,4 +17,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # - +function subunit_start_test () { + # emit the current protocol start-marker for test test_name + echo "test: $1" +} diff --git a/shell/test_shell.py b/shell/test_shell.py index ddba251..cf891aa 100644 --- a/shell/test_shell.py +++ b/shell/test_shell.py @@ -30,13 +30,17 @@ import logging class ShellTests(subunit.ExecTestCase): - def test_shell(self): + def test_sourcing(self): """./tests/test_source_library.sh""" + def test_functions(self): + """./tests/test_function_output.sh""" + def test_suite(): result = TestSuite() - result.addTest(ShellTests('test_shell')) + result.addTest(ShellTests('test_sourcing')) + result.addTest(ShellTests('test_functions')) return result diff --git a/shell/tests/test_function_output.sh b/shell/tests/test_function_output.sh new file mode 100755 index 0000000..a57e6b9 --- /dev/null +++ b/shell/tests/test_function_output.sh @@ -0,0 +1,43 @@ +#!/bin/sh +# subunit shell bindings. +# Copyright (C) 2006 Robert Collins <robertc@robertcollins.net> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + + +# this script tests the output of the methods. As each is tested we start using +# it. +# So the first test manually implements the entire protocol, the next uses the +# start method and so on. +# it is assumed that we are running from the 'shell' tree root in the source +# of subunit, and that the library sourcing tests have all passed - if they +# have not, this test script may well fail strangely. + +# import the library. +. share/subunit.sh + +echo 'test: subunit_start_test output' +func_output=$(subunit_start_test "foo bar") +func_status=$? +if [ $func_status == 0 -a "x$func_output" = "xtest: foo bar" ]; then + echo 'success: subunit_start_test output' +else + echo 'failure: subunit_start_test output [' + echo 'got an error code or incorrect output:' + echo "exit: $func_status" + echo "output: '$func_output'" + echo ']' ; +fi diff --git a/shell/tests/test_source_library.sh b/shell/tests/test_source_library.sh index fdc5f5c..8fd10e6 100755 --- a/shell/tests/test_source_library.sh +++ b/shell/tests/test_source_library.sh @@ -25,5 +25,30 @@ # we expect to be run from the 'shell' tree root. echo 'test: shell bindings can be sourced' +# if any output occurs, this has failed to source cleanly +source_output=$(. share/subunit.sh 2>&1) +if [ $? == 0 -a "x$source_output" = "x" ]; then + echo 'success: shell bindings can be sourced' +else + echo 'failure: shell bindings can be sourced [' + echo 'got an error code or output during sourcing.:' + echo $source_output + echo ']' ; +fi + +# now source it for real . share/subunit.sh -echo 'success: shell bindings can be sourced' + +# we should have a test-start function +echo 'test: subunit_start_test exists' +found_type=$(type -t subunit_start_test) +status=$? +if [ $status == 0 -a "x$found_type" = "xfunction" ]; then + echo 'success: subunit_start_test exists' +else + echo 'failure: subunit_start_test exists [' + echo 'subunit_start_test is not a function:' + echo "type -t status: $status" + echo "output: $found_type" + echo ']' ; +fi |