Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/scripts/github-actions/collect-test-logs.sh
3992 views
1
#!/usr/bin/env bash
2
# Collects failed test logs from Bazel testlogs directory
3
# Reads targets from build/failures/_run2.txt if present, otherwise _run1.txt
4
5
set -euxo pipefail
6
7
TESTLOGS_ROOT=$(bazel info bazel-testlogs)
8
9
LIST_FILE=""
10
if [ -s build/failures/_run2.txt ]; then
11
LIST_FILE="build/failures/_run2.txt"
12
elif [ -s build/failures/_run1.txt ]; then
13
LIST_FILE="build/failures/_run1.txt"
14
else
15
exit 0
16
fi
17
18
echo "Failures to collect from $LIST_FILE:"
19
cat "$LIST_FILE"
20
21
while IFS= read -r target; do
22
[ -z "$target" ] && continue
23
24
# Convert //path/to:target to path/to/target
25
rel_path=$(tr ':' '/' <<< "${target#//}")
26
27
log_source="$TESTLOGS_ROOT/${rel_path}/test.log"
28
29
if [ -f "$log_source" ]; then
30
# Convert path separators to underscores for safe filename
31
safe_name="${target#//}"
32
safe_name="${safe_name//[\/:]/_}"
33
echo "Copying log for $target..."
34
cp "$log_source" "build/failures/${safe_name}.log"
35
else
36
echo "Warning: No log found for $target at $log_source" >&2
37
fi
38
done < "$LIST_FILE"
39
40