permission mods
[feisty_meow.git] / scripts / clam / target_runner.sh
1 #!/bin/bash
2 ##############
3 # Name   : target_runner.sh
4 # Author : Chris Koeritz
5 # Rights : Copyright (C) 2012-$now by Feisty Meow Concerns, Ltd.
6 ##############
7 # This script is free software; you can modify/redistribute it under the terms
8 # of the GNU General Public License. [ http://www.gnu.org/licenses/gpl.html ]
9 # Feel free to send updates to: [ fred@gruntose.com ]
10 ##############
11 #
12 # Runs the programs listed in clam's RUN_TARGETS and reports any errors seen.
13
14 #echo entering target_runner with variables:
15 #echo -e "\tRUN_TARGETS=${RUN_TARGETS}"
16 #echo -e "\tDIRTY_FILE=${DIRTY_FILE}"
17 #echo -e "\tSUBMAKE_FLAG=${SUBMAKE_FLAG}"
18 #echo -e "\tFAILURE_FILE=${FAILURE_FILE}"
19 #echo -e "\tRUN_ALL_TESTS=${RUN_ALL_TESTS}"
20
21 if [ ! -z "${RUN_TARGETS}" -a ! -z "${RUN_ALL_TESTS}" ]; then
22   if [ -f "${DIRTY_FILE}" -o -f "${SUBMAKE_FLAG}" ]; then
23     total_exitval=0;
24     for program_name in ${RUN_TARGETS}; do
25       base=$(basename $program_name);
26       if [ "$OP_SYSTEM" == "WIN32" ]; then
27         # extra step to force win32 applications to stay held in our grip,
28         # since they will float off and appear to have stopped when
29         # run by cygwin.  but by grabbing the i/o stream, we know it's
30         # running until it's done.
31         "$program_name" 2>&1 | cat
32         # we care about the exit status of the first process in the pipe,
33         # which is the app being run.
34         exitval=${PIPESTATUS[0]}
35       else
36         "$program_name"
37         exitval=$?;
38       fi
39       if [ $exitval -ne 0 ]; then
40         echo "ERROR: $program_name exits with $exitval at $(date)";
41         total_exitval=$(($total_exitval + 1));
42       fi;
43     done;
44     if [ $total_exitval -ne 0 ]; then
45       echo "FAILURE: $total_exitval errors occurred in RUN_TARGETS.";
46       echo yep >"${FAILURE_FILE}";
47       exit 1;
48     fi;
49   fi;
50 fi
51