Skip to content

Commit 4e95628

Browse files
author
Your Name
committed
Reduce test output verbosity for colcon test results
Show minimal output when all tests pass. On failure, parse JUnit XMLs from test_results/ (skipping CTest XMLs that contain entire roslaunch logs) and display only assertion errors and tracebacks.
1 parent aae9c95 commit 4e95628

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

.helper_bash_functions

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,33 @@ colcon_build() { START_DIR=$(pwd) && \
2626
}
2727
colcon_build_this() { colcon_build "$(find_cmake_project_names_from_dir .)"; }
2828
rosdep_install() { rosdep install --from-paths src --ignore-src -r -y ; }
29+
_show_test_failures() {
30+
python3 - "$@" <<'PYEOF'
31+
import sys, xml.etree.ElementTree as ET
32+
from pathlib import Path
33+
for d in sys.argv[1:]:
34+
for p in sorted(Path(d).rglob("*.xml")):
35+
for tc in ET.parse(p).iter("testcase"):
36+
for f in list(tc.iter("failure")) + list(tc.iter("error")):
37+
tag = "FAIL" if f.tag == "failure" else "ERROR"
38+
print(f"\n {tag}: {tc.get('classname', '')}.{tc.get('name', '')}")
39+
if f.text:
40+
lines = f.text.strip().splitlines()
41+
for l in lines[:20]:
42+
print(f" {l}")
43+
if len(lines) > 20:
44+
print(f" ... ({len(lines) - 20} more lines)")
45+
PYEOF
46+
}
2947
colcon_test_these_packages() { THIS_DIR=$(pwd)
3048
cd ${CATKIN_WS_PATH}
3149
colcon_build_no_deps $1
3250
source install/setup.bash && \
3351
colcon test --packages-select $1
3452
for pkg in $1; do
35-
colcon test-result --verbose --test-result-base "build/$pkg"
53+
if ! colcon test-result --test-result-base "build/$pkg/test_results"; then
54+
_show_test_failures "build/$pkg/test_results"
55+
fi
3656
done
3757
cd $THIS_DIR
3858

0 commit comments

Comments
 (0)