]> git.wincent.com - WOTest.git/blob - RunTests.sh
Fix object-to-pointer comparisons on Leopard
[WOTest.git] / RunTests.sh
1 #!/bin/sh
2
3 # RunTests.sh
4 # WOTest
5 #
6 # Created by Wincent Colaiuta on 01 March 2006.
7 #
8 # Copyright 2006-2007 Wincent Colaiuta.
9 # This program is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, either version 3 of the License, or
12 # (at your option) any later version.
13 #
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
21 #
22
23 #
24 # Defaults
25 #
26
27 # test bundle path relative to this script
28 TEST_BUNDLE="WOTestSelfTests.bundle"
29
30 # WOTest.framework path relative to this script
31 TEST_FRAMEWORK="../../../../WOTest.framework"
32
33 #
34 # Functions
35 #
36
37 check_error_status()
38 {
39   ERR=$?
40   if [ $ERR -ne 0 ]; then
41     FAILURE=$ERR
42   fi
43 }
44
45 #
46 # Main
47 #
48
49 set -e
50
51 STARTING_DIRECTORY=`/bin/pwd`
52 builtin echo "Saved current working directory: ${STARTING_DIRECTORY}"
53
54 SCRIPT_DIRECTORY=$(/usr/bin/dirname "$0")
55 builtin echo "Changing to script directory: ${SCRIPT_DIRECTORY}"
56 cd "${SCRIPT_DIRECTORY}"
57 SCRIPT_DIRECTORY=$(/bin/pwd)
58 builtin echo "Script directory with symlinks resolved: ${SCRIPT_DIRECTORY}"
59
60 if [ "${DYLD_FRAMEWORK_PATH}" != "" ]; then
61   SAVE_DLYD_FRAMEWORK_PATH=`declare -p DYLD_FRAMEWORK_PATH`
62   builtin echo "Saved old DYLD_FRAMEWORK_PATH: ${SAVE_DLYD_FRAMEWORK_PATH}"
63 else
64   SAVE_DLYD_FRAMEWORK_PATH=""
65 fi
66
67 DYLD_FRAMEWORK_PATH=$(/usr/bin/dirname "${SCRIPT_DIRECTORY}/${TEST_FRAMEWORK}")
68 cd "${DYLD_FRAMEWORK_PATH}"
69 export DYLD_FRAMEWORK_PATH=$(/bin/pwd)
70 cd -
71 builtin echo "DYLD_FRAMEWORK_PATH set to ${DYLD_FRAMEWORK_PATH}"
72
73 builtin echo "Launching test runner for bundle: ${SCRIPT_DIRECTORY}/${TEST_BUNDLE}"
74 "${SCRIPT_DIRECTORY}/${TEST_FRAMEWORK}/Versions/A/Resources/WOTestRunner" --test-bundle="${SCRIPT_DIRECTORY}/${TEST_BUNDLE}"
75 check_error_status
76 builtin echo "Test run complete"
77
78 builtin echo "Restoring old DYLD_FRAMEWORK_PATH"
79 eval "${SAVE_DLYD_FRAMEWORK_PATH}"
80
81 builtin echo "Returning to old working directory"
82 cd "${STARTING_DIRECTORY}"
83
84 if [ $FAILURE ]; then
85   exit $FAILURE
86 else
87   exit 0
88 fi