/
build_and_test.sh
executable file
·153 lines (125 loc) · 4.12 KB
/
build_and_test.sh
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!/usr/bin/env bash
##############################################################################
# Copyright (c) 2016-20, Lawrence Livermore National Security, LLC and Umpire
# project contributors. See the COPYRIGHT file for details.
#
# SPDX-License-Identifier: (MIT)
##############################################################################
set -o errexit
set -o nounset
option=${1:-""}
hostname="$(hostname)"
project_dir="$(pwd)"
build_root=${BUILD_ROOT:-""}
hostconfig=${HOST_CONFIG:-""}
spec=${SPEC:-""}
sys_type=${SYS_TYPE:-""}
py_env_path=${PYTHON_ENVIRONMENT_PATH:-""}
# Dependencies
if [[ "${option}" != "--build-only" && "${option}" != "--test-only" ]]
then
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo "~~~~~ Building Dependencies"
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
if [[ -z ${spec} ]]
then
echo "SPEC is undefined, aborting..."
exit 1
fi
prefix_opt=""
if [[ -d /dev/shm ]]
then
prefix="/dev/shm/${hostname}/${spec// /_}"
mkdir -p ${prefix}
prefix_opt="--prefix=${prefix}"
fi
python scripts/uberenv/uberenv.py --spec="${spec}"
fi
# Host config file
if [[ -z ${hostconfig} ]]
then
# If no host config file was provided, we assume it was generated.
# This means we are looking of a unique one in project dir.
hostconfigs=( $( ls "${project_dir}/"hc-*.cmake ) )
if [[ ${#hostconfigs[@]} == 1 ]]
then
hostconfig_path=${hostconfigs[0]}
echo "Found host config file: ${hostconfig_path}"
elif [[ ${#hostconfigs[@]} == 0 ]]
then
echo "No result for: ${project_dir}/hc-*.cmake"
echo "Spack generated host-config not found."
exit 1
else
echo "More than one result for: ${project_dir}/hc-*.cmake"
echo "${hostconfigs[@]}"
echo "Please specify one with HOST_CONFIG variable"
exit 1
fi
else
# Using provided host-config file.
hostconfig_path="${project_dir}/host-configs/${hostconfig}"
fi
# Build Directory
if [[ -z ${build_root} ]]
then
build_root=$(pwd)
fi
build_dir="${build_root}/build_${hostconfig//.cmake/}"
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo "~~~~~ Host-config: ${hostconfig_path}"
echo "~~~~~ Build Dir: ${build_dir}"
echo "~~~~~ Project Dir: ${project_dir}"
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo "~~~~ ENV ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
env
# Build
if [[ "${option}" != "--deps-only" && "${option}" != "--test-only" ]]
then
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo "~~~~~ Building Umpire"
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
# If building, then delete everything first
rm -rf ${build_dir} 2>/dev/null
mkdir -p ${build_dir} && cd ${build_dir}
cmake \
-C ${hostconfig_path} \
${project_dir}
cmake --build . -j
fi
# Test
if [[ "${option}" != "--build-only" ]]
then
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo "~~~~~ Testing Umpire"
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
if [[ ! -d ${build_dir} ]]
then
echo "ERROR: Build directory not found : ${build_dir}" && exit 1
fi
cd ${build_dir}
ctest --output-on-failure -T test 2>&1 | tee tests_output.txt
no_test_str="No tests were found!!!"
if [[ "$(tail -n 1 tests_output.txt)" == "${no_test_str}" ]]
then
echo "ERROR: No tests were found" && exit 1
fi
echo "Copying Testing xml reports for export"
tree Testing
cp Testing/*/Test.xml ${project_dir}
# Convert CTest xml to JUnit (on toss3 only)
if [[ ${sys_type} == *toss_3* ]]; then
if [[ -n ${py_env_path} ]]; then
. ${py_env_path}/bin/activate
python3 ${project_dir}/scripts/gitlab/convert_to_junit.py \
${project_dir}/Test.xml \
${project_dir}/scripts/gitlab/junit.xslt > ${project_dir}/junit.xml
else
echo "ERROR: needs python env with lxml, please set PYTHON_ENVIRONMENT_PATH"
fi
fi
if grep -q "Errors while running CTest" ./tests_output.txt
then
echo "ERROR: failure(s) while running CTest" && exit 1
fi
fi