Get make distcheck working with Jelmers perl-install patch (and some minor trunk...
[third_party/subunit] / shell / tests / test_source_library.sh
1 #!/bin/bash
2 #  subunit shell bindings.
3 #  Copyright (C) 2006  Robert Collins <robertc@robertcollins.net>
4 #
5 #  This program is free software; you can redistribute it and/or modify
6 #  it under the terms of the GNU General Public License as published by
7 #  the Free Software Foundation; either version 2 of the License, or
8 #  (at your option) any later version.
9 #
10 #  This program is distributed in the hope that it will be useful,
11 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 #  GNU General Public License for more details.
14 #
15 #  You should have received a copy of the GNU General Public License
16 #  along with this program; if not, write to the Free Software
17 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18 #
19
20
21 # this script tests that we can source the subunit shell bindings successfully.
22 # It manually implements the control protocol so that it des not depend on the
23 # bindings being complete yet.
24
25 # we expect to be run from the tree root.
26
27 echo 'test: shell bindings can be sourced'
28 # if any output occurs, this has failed to source cleanly
29 source_output=$(. ${SHELL_SHARE}subunit.sh 2>&1)
30 if [ $? == 0 -a "x$source_output" = "x" ]; then
31   echo 'success: shell bindings can be sourced'
32 else
33   echo 'failure: shell bindings can be sourced ['
34   echo 'got an error code or output during sourcing.:'
35   echo $source_output
36   echo ']' ;
37 fi
38
39 # now source it for real
40 . ${SHELL_SHARE}subunit.sh
41
42 # we should have a start_test function
43 echo 'test: subunit_start_test exists'
44 found_type=$(type -t subunit_start_test)
45 status=$?
46 if [ $status == 0 -a "x$found_type" = "xfunction" ]; then
47   echo 'success: subunit_start_test exists'
48 else
49   echo 'failure: subunit_start_test exists ['
50   echo 'subunit_start_test is not a function:'
51   echo "type -t status: $status"
52   echo "output: $found_type"
53   echo ']' ;
54 fi
55
56 # we should have a pass_test function
57 echo 'test: subunit_pass_test exists'
58 found_type=$(type -t subunit_pass_test)
59 status=$?
60 if [ $status == 0 -a "x$found_type" = "xfunction" ]; then
61   echo 'success: subunit_pass_test exists'
62 else
63   echo 'failure: subunit_pass_test exists ['
64   echo 'subunit_pass_test is not a function:'
65   echo "type -t status: $status"
66   echo "output: $found_type"
67   echo ']' ;
68 fi
69
70 # we should have a fail_test function
71 echo 'test: subunit_fail_test exists'
72 found_type=$(type -t subunit_fail_test)
73 status=$?
74 if [ $status == 0 -a "x$found_type" = "xfunction" ]; then
75   echo 'success: subunit_fail_test exists'
76 else
77   echo 'failure: subunit_fail_test exists ['
78   echo 'subunit_fail_test is not a function:'
79   echo "type -t status: $status"
80   echo "output: $found_type"
81   echo ']' ;
82 fi
83
84 # we should have a error_test function
85 echo 'test: subunit_error_test exists'
86 found_type=$(type -t subunit_error_test)
87 status=$?
88 if [ $status == 0 -a "x$found_type" = "xfunction" ]; then
89   echo 'success: subunit_error_test exists'
90 else
91   echo 'failure: subunit_error_test exists ['
92   echo 'subunit_error_test is not a function:'
93   echo "type -t status: $status"
94   echo "output: $found_type"
95   echo ']' ;
96 fi
97
98 # we should have a skip_test function
99 echo 'test: subunit_skip_test exists'
100 found_type=$(type -t subunit_skip_test)
101 status=$?
102 if [ $status == 0 -a "x$found_type" = "xfunction" ]; then
103   echo 'success: subunit_skip_test exists'
104 else
105   echo 'failure: subunit_skip_test exists ['
106   echo 'subunit_skip_test is not a function:'
107   echo "type -t status: $status"
108   echo "output: $found_type"
109   echo ']' ;
110 fi
111