-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathrun_unit_tests.sh
More file actions
executable file
·62 lines (54 loc) · 2.84 KB
/
Copy pathrun_unit_tests.sh
File metadata and controls
executable file
·62 lines (54 loc) · 2.84 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
#!/usr/bin/env bash
set -uo pipefail
# Integration unit test script.
CONFIG=${CONFIG:-bl-x86_64-linux}
LOG_DIR=${LOG_DIR:-_logs/logs_ut}
SUMMARY_FILE=${SUMMARY_FILE:-_logs/ut_summary.md}
mkdir -p "${LOG_DIR}" || true
declare -A UT_TARGET_GROUPS=(
[baselibs]="@score_baselibs//score/... -- \
-@score_baselibs//score/language/safecpp/aborts_upon_exception:abortsuponexception_toolchain_test \
-@score_baselibs//score/containers:dynamic_array_test \
-@score_baselibs//score/mw/log/configuration:* \
-@score_baselibs//score/json/examples:*"
[communication]="@score_communication//score/mw/com/impl/... -- \
-@score_communication//score/mw/com/impl:unit_test_runtime_single_exec \
-@score_communication//score/mw/com/impl/configuration:config_parser_test \
-@score_communication//score/mw/com/impl/configuration:configuration_test \
-@score_communication//score/mw/com/impl/tracing/configuration:tracing_filter_config_parser_test"
[persistency]="@score_persistency//:unit_tests" # ok
[orchestrator]="@score_orchestrator//src/..." # ok
[kyron]="@score_kyron//:unit_tests" # ok
[feo]="@score_feo//... --build_tests_only" # ok (flag required or error from docs)
)
# Markdown table header
echo -e "Status\tPassed\tFailed\tSkipped\tTotal\tGroup\tDuration(s)" >> "${SUMMARY_FILE}"
for group in "${!UT_TARGET_GROUPS[@]}"; do
targets="${UT_TARGET_GROUPS[$group]}"
command="bazel test --config="${CONFIG}" ${targets}"
echo "==========================================="
echo "Running unit tests for group: $group"
echo "${command}"
echo "==========================================="
start_ts=$(date +%s)
out=$(bazel test --test_summary=testcase --test_output=errors --nocache_test_results --config="${CONFIG}" ${targets} 2>&1 | tee "${LOG_DIR}/ut_${group}_output.log")
build_status=${PIPESTATUS[0]}
end_ts=$(date +%s)
duration=$(( end_ts - start_ts ))
# Parse bazel output
tests_passed=$(echo "$out" | grep -Eo '[0-9]+ passing' | grep -Eo '[0-9]+' | head -n1)
tests_failed=$(echo "$out" | grep -Eo '[0-9]+ failing' | grep -Eo '[0-9]+' | head -n1)
tests_skipped=$(echo "$out" | grep -Eo '[0-9]+ skipped' | grep -Eo '[0-9]+' | head -n1)
tests_executed=$(echo "$out" | grep -Eo '[0-9]+ test cases' | grep -Eo '[0-9]+' | head -n1)
if [[ ${build_status} -eq 0 ]]; then
status_symbol="✅"
else
status_symbol="❌"
fi
# Append as a markdown table row
echo -e "${status_symbol}\t${tests_passed}\t${tests_failed}\t${tests_skipped}\t${tests_executed}\t${group}\t${duration}s" >> "${SUMMARY_FILE}"
echo "==========================================="
echo -e "\n\n"
done
# Align the summary table columns
column -t -s $'\t' "${SUMMARY_FILE}" > "${SUMMARY_FILE}.tmp" && mv "${SUMMARY_FILE}.tmp" "${SUMMARY_FILE}"