aboutsummaryrefslogtreecommitdiff
path: root/source/1.0/bin/gen_test_results.sh
diff options
context:
space:
mode:
authorkate.ward <kate.ward@forestent.com>2008-10-21 23:29:23 +0000
committerkate.ward <kate.ward@forestent.com>2008-10-21 23:29:23 +0000
commit2f3cad903fae5df19c6c8ac0ce2e72bae2fdde50 (patch)
tree11826144c06d936c40f7c4abaacfaaea9dcb17b2 /source/1.0/bin/gen_test_results.sh
parent20d0678445135ae8077257e0e8abf54a1769ca3d (diff)
downloadshflags-2f3cad903fae5df19c6c8ac0ce2e72bae2fdde50.tar.gz
created versions library and gen_test_results.sh, and updated several other things as a result
Diffstat (limited to 'source/1.0/bin/gen_test_results.sh')
-rwxr-xr-xsource/1.0/bin/gen_test_results.sh78
1 files changed, 78 insertions, 0 deletions
diff --git a/source/1.0/bin/gen_test_results.sh b/source/1.0/bin/gen_test_results.sh
new file mode 100755
index 0000000..7597b10
--- /dev/null
+++ b/source/1.0/bin/gen_test_results.sh
@@ -0,0 +1,78 @@
+#! /bin/sh
+# $Id$
+# vim:et:ft=sh:sts=2:sw=2
+#
+# Copyright 2008 Kate Ward. All Rights Reserved.
+# Released under the LGPL (GNU Lesser General Public License)
+#
+# Author: kate.ward@forestent.com (Kate Ward)
+#
+# This script runs the provided unit tests and sends the output to the
+# appropriate file.
+#
+
+# treat unset variables as an error
+set -u
+
+die()
+{
+ [ $# -gt 0 ] && echo "error: $@" >&2
+ exit 1
+}
+
+relToAbsPath()
+{
+ path_=$1
+
+ # prepend current directory to relative paths
+ echo "${path_}" |grep '^/' >/dev/null || path_="`pwd`/${path_}"
+
+ # clean up the path
+ old_=${path_}
+ while true; do
+ new_=`echo "${old_}" |sed 's/[^/]*\/\.\.\/*//g;s/\/\.\//\//'`
+ [ "${old_}" = "${new_}" ] && break
+ old_=${new_}
+ done
+
+ echo "${new_}"
+ unset path_ old_ new_
+}
+
+BASE_DIR="`dirname $0`/.."
+BASE_DIR=`relToAbsPath "${BASE_DIR}"`
+
+LIB_DIR="${BASE_DIR}/lib"
+SRC_DIR="${BASE_DIR}/src"
+
+# load libraries
+. ${SRC_DIR}/shflags || die 'unable to load shflags library'
+. ${LIB_DIR}/versions || die 'unable to load versions library'
+
+os_name=`versions_osName |sed 's/ /_/g'`
+os_version=`versions_osVersion`
+
+DEFINE_boolean force false 'force overwrite' f
+DEFINE_string output_dir "`pwd`" 'output dir' d
+DEFINE_string output_file "${os_name}-${os_version}.txt" 'output file' o
+FLAGS "$@" || exit $?; shift ${FLAGS_ARGC}
+
+# determine output filename
+output="${FLAGS_output_dir:+${FLAGS_output_dir}/}${FLAGS_output_file}"
+output=`relToAbsPath "${output}"`
+
+# checks
+if [ -f "${output}" ]; then
+ if [ ${FLAGS_force} -eq ${FLAGS_TRUE} ]; then
+ rm -f "${output}"
+ else
+ echo "not overwriting '${output}'" >&2
+ exit ${FLAGS_ERROR}
+ fi
+fi
+
+# run tests
+( cd "${SRC_DIR}"; ./shflags_test.sh 2>&1 |tee "${output}" )
+
+echo >&2
+echo "output written to '${output}'" >&2