-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathbuild_and_test.sh
More file actions
executable file
·128 lines (100 loc) · 3.34 KB
/
build_and_test.sh
File metadata and controls
executable file
·128 lines (100 loc) · 3.34 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
128
#!/usr/bin/env bash
###############################################################################
# Copyright (c) 2021, Lawrence Livermore National Security, LLC
# and LvArray project contributors. See the LICENCE file for details.
#
# SPDX-License-Identifier: (BSD-3-Clause)
###############################################################################
set -o errexit
set -o nounset
option=${1:-""}
hostname="$(hostname)"
project_dir="$(pwd)"
hostconfig=${HOST_CONFIG:-""}
name=${NAME}
spec=${SPEC:-""}
build_type=${BUILD_TYPE}
# 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}/${name}"
mkdir -p ${prefix}
prefix_opt="--prefix=${prefix}"
fi
python scripts/uberenv/uberenv.py --spec="${spec}" ${prefix_opt}
fi
# Host config file
# We are looking for a unique host config in project dir.
hostconfigs=( $( ls "${project_dir}/"*@*.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
build_dir="${project_dir}/build_"
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo "~~~~~ Project Dir: ${project_dir}"
echo "~~~~~ Host-config: ${hostconfig_path}"
echo "~~~~~ Build Dir: ${build_dir}"
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
# Build
for buildType in ${build_type}
do
cd ${project_dir}
if [[ "${option}" != "--deps-only" && "${option}" != "--test-only" ]]
then
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo "~~~~~ Building LvArray"
echo "~~~~~ Build Type: ${buildType}"
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
python scripts/config-build.py -hc ${hostconfig_path} -bt ${buildType} -bp ${build_dir}
cd ${build_dir}
cmake --build . -j
fi
# Test
if [[ "${option}" != "--build-only" ]]
then
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo "~~~~~ Testing LvArray"
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}
if grep -q "Errors while running CTest" ./tests_output.txt
then
echo "ERROR: failure(s) while running CTest" && exit 1
fi
fi
done