3 # Author: Chris Koeritz
6 # We do not want to "exit" from this file at all (nor from any file that it
7 # invokes either), since this script is intended for use by the bash 'source'
8 # command. If we exit, that will exit from the calling shell as well, which
9 # torpedoes whatever one was doing in that shell.
10 # There is a variable below called BADNESS that indicates when errors
11 # occurred during processing, and if it's not empty at the end of the script
12 # then we will consider this a failed run, and we will not set the test's
13 # sentinel variable which other scripts check to see if the environment
14 # was loaded properly.
16 # make sure whether they have defined the top-level location for us.
17 if [ ! -z "$1" ]; then
18 # first attempt is to use the first parameter, if one is provided. this should
19 # be an absolute path reference to this very file, from which we can deduce the
21 GRITTY_TESTING_TOP_LEVEL="$( cd "$( dirname "$1" )" && \pwd )"
22 # for this case, they also don't need to be stranded in a new shell, because we
23 # assume they have sourced this file instead of bashing it.
26 if [ -z "$GRITTY_TESTING_TOP_LEVEL" ]; then
27 # otherwise, if they didn't explicitly set the top-level directory, we will
28 # do it using some unix trickery.
29 if [[ "$0" =~ .*bash ]]; then
31 echo "This script was not launched properly with 'source'. The script should"
32 echo "be started like this: source prepare_tools.sh prepare_tools.sh"
33 echo "The double entry is required for bash's source command to find the path."
36 GRITTY_TESTING_TOP_LEVEL="$( cd "$( dirname "$0" 2>/dev/null )" && \pwd )"
38 # we assume they are managing this script more closely and do not need (or want) a bash sub-shell.
41 GRITTY_TESTING_TOP_LEVEL="$(echo "$GRITTY_TESTING_TOP_LEVEL" | sed -e 's/\/cygdrive\/\(.\)/\1:/')"
43 # the top-level directory for tests, i.e. the root of testing hierarchy.
44 export TESTKIT_ROOT="$GRITTY_TESTING_TOP_LEVEL"
46 # a bit of a dance to not pull in code too early...
47 export TESTKIT_BOOTSTRAPPING=true
48 source "$TESTKIT_ROOT/library/establish_environment.sh"
49 unset TESTKIT_BOOTSTRAPPING
50 # done with dancing, ready to pull in anything else from testkit.
52 #source "$TESTKIT_ROOT/library/helper_methods.sh"
54 # where the shunit library resides.
55 export SHUNIT_DIR="$TESTKIT_ROOT/shunit"
57 # establish the TMP variable if it's not already set.
59 if [ -z "$TMP" ]; then
61 if [ ! -d "$TMP" ]; then mkdir "$TMP"; fi
63 TMP="$(echo "$TMP" | sed -e 's/\/cygdrive\/\(.\)/\1:/')"
64 if [ ! -d "$TMP" ]; then
65 echo "The TMP directory was set as $TMP but cannot be created or found."
66 echo "If there is a file at that location, please move or delete it."
72 # commonly used environment variables...
74 # TEST_TEMP is a folder where we can generate a collection of junk files.
75 export TEST_TEMP="$TMP/testkit_logs_${USER}"
76 if [ ! -d "$TEST_TEMP" ]; then
80 # this variable points to the last output from a grid command.
81 export TESTKIT_OUTPUT_FILE="$TEST_TEMP/testkit_output.log"
82 export TESTKIT_TIMING_FILE="$TEST_TEMP/testkit_times.log"
83 export CONGLOMERATED_TESTKIT_OUTPUT="$TEST_TEMP/full_testkit_output.log"
87 # uncomment this to enable extra output.
92 # turn this printout off in non-debugging mode or if the terminal setting
93 # seems to indicate that we're running in a login environment (where any
94 # echoing to standard out can screw up scp and sftp for that account).
95 if [ ! -z "$DEBUGGING" -a -z "$SHOWED_SETTINGS_ALREADY" \
96 -a -z "$BADNESS" -a -z "$SILENT_RUNNING" -a "${TERM}" != "dumb" \
97 -a -z "$PBS_ENVIRONMENT" ]; then
98 echo "==========================================================="
99 echo "Testkit environment loaded."
100 var TESTKIT_ROOT TESTKIT_CFG_FILE TMP TEST_TEMP
101 echo "==========================================================="
104 if [ ! -z "$(uname -a | grep -i darwin)" -a -z "$BADNESS" ]; then
105 # add in the mac binaries if this is darwin.
106 export PATH="$TESTKIT_ROOT/bin/macosx:$PATH"
108 # no change, but we want to make sure sub-shells inherit the path.
112 if [ -z "$NO_SUBSHELL" -a -z "$BADNESS" ]; then
113 # at this point we go into a new interactive shell, so as to ensure the
114 # environment parameters stay right.
115 # the self-location code at the top doesn't work properly if this file is
116 # sourced into a current environment.
120 if [ ! -z "$BADNESS" ]; then
123 echo "There were errors in setting up the xsede tests--see above messages."
124 unset TESTKIT_SENTINEL TESTKIT_ROOT GRITTY_TESTING_TOP_LEVEL SHUNIT_DIR BADNESS
126 # if things were successful, we can finally set our indicator for the scripts to check.
127 export TESTKIT_SENTINEL=initialized