Repository navigation
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·128 lines (115 loc) · 3.58 KB
/
Copy pathtest.sh
File metadata and controls
executable file
·128 lines (115 loc) · 3.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/bin/bash
#-----------------------BEGIN NOTICE -- DO NOT EDIT-----------------------------
# NASA Goddard Space Flight Center
# NASA Land Coupler (NLC)
# Version 0.5
#
# Copyright (c) 2022 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# All Rights Reserved.
# Licensed under Apache License 2.0.
#-------------------------END NOTICE -- DO NOT EDIT-----------------------------
# usage instructions
usage () {
printf "Usage: $0 [OPTIONS]...\n"
printf "\n"
printf "OPTIONS\n"
printf " --build-dir=BUILD_DIR\n"
printf " build directory\n"
printf " --tests-regex=REGEX, -R=REGEX\n"
printf " run tests matching the specified regular expression\n"
printf " --label-regex=REGEX, -L=REGEX\n"
printf " run tests with labels matching the specified regular expression\n"
printf " --verbose, -v\n"
printf " build with verbose output\n"
printf " --help, -h\n"
printf " print this help message\n"
printf "\n"
}
# print settings
settings () {
printf "Settings:\n"
printf "\n"
printf " NLC_DIR=${NLC_DIR}\n"
printf " BUILD_DIR=${BUILD_DIR}\n"
printf " TESTS_REGEX=${TESTS_REGEX}\n"
printf " LABEL_REGEX=${LABEL_REGEX}\n"
printf " SYSTEM=${SYSTEM}\n"
printf " ENV_AUTO=${ENV_AUTO}\n"
printf " VERBOSE=${VERBOSE}\n"
printf "\n"
}
# default settings
NLC_DIR=$(cd "$(dirname "$(readlink -f -n "${BASH_SOURCE[0]}" )" )" && pwd -P)
BUILD_DIR=${NLC_DIR}/build
SYSTEM=""
ENV_DIR="${NLC_DIR}/env"
ENV_AUTO=false
VERBOSE=false
TESTS_REGEX=""
LABEL_REGEX=""
# required arguments
if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
usage
exit 0
fi
# process arguments
while :; do
case $1 in
--help|-h) usage; exit 0 ;;
--build-dir=?*) BUILD_DIR=${1#*=} ;;
--build-dir) printf "ERROR: $1 requires an argument.\n"; usage; exit 1 ;;
--build-dir=) printf "ERROR: $1 requires an argument.\n"; usage; exit 1 ;;
--tests-regex=?*|-R=?*) TESTS_REGEX="${1#*=}" ;;
--tests-regex|-R) printf "ERROR: $1 requires an argument.\n"; usage; exit 1 ;;
--tests-regex=|-R=) printf "ERROR: $1 requires an argument.\n"; usage; exit 1 ;;
--label-regex=?*|-L=?*) LABEL_REGEX="${1#*=}" ;;
--label-regex|-L) printf "ERROR: $1 requires an argument.\n"; usage; exit 1 ;;
--label-regex=|-L=) printf "ERROR: $1 requires an argument.\n"; usage; exit 1 ;;
--verbose|-v) VERBOSE=true ;;
--verbose=?*) printf "ERROR: $1 argument ignored.\n"; usage; exit 1 ;;
--verbose=) printf "ERROR: $1 argument ignored.\n"; usage; exit 1 ;;
-?*) printf "ERROR: Unknown option $1\n"; usage; exit 1 ;;
*) break
esac
shift
done
set -eu
source scripts/setupenv.sh
# load saved configuration if it exists
if [ -f "${NLC_DIR}/.nlc_config.sh" ]; then
source "${NLC_DIR}/.nlc_config.sh"
else
printf "ERROR: NLC has not been configured.\n"
printf " Please run './configure.sh' before building.\n"
exit 1
fi
# auto modulefile
if [ "${ENV_AUTO}" = true ] ; then
auto_environment ${SYSTEM} ${ENV_DIR}
fi
# print settings
if [ "${VERBOSE}" = true ] ; then
settings
fi
# check for BUILD_DIR
if [ ! -d "${BUILD_DIR}" ]; then
printf "ERROR: Build directory missing\n"
printf " Please run './build.sh' before testing.\n"
exit 1
fi
# ctest settings
CTEST_SETTINGS=""
if [ "${VERBOSE}" = true ]; then
CTEST_SETTINGS="VERBOSE=1"
fi
if [ -n "${TESTS_REGEX}" ]; then
CTEST_SETTINGS="${CTEST_SETTINGS} -R ${TESTS_REGEX}"
fi
if [ -n "${LABEL_REGEX}" ]; then
CTEST_SETTINGS="${CTEST_SETTINGS} -L ${LABEL_REGEX}"
fi
# run tests
cd ${BUILD_DIR}
ctest --test-dir ${BUILD_DIR} -L nlc_test ${CTEST_SETTINGS}
exit 0