Skip to content

Preserve CTest target identity in JUnit results - #1002

Merged
wjwwood merged 4 commits into
ros2:rollingfrom
Quchaosheng:fix-unique-junit-test-names
Sep 29, 2026
Merged

wjwwood merged 4 commits into
ros2:rollingfrom
Quchaosheng:fix-unique-junit-test-names

Conversation

@Quchaosheng

Copy link
Copy Markdown
Contributor

Description

Pass the unique CTest target name from add_launch_test() to the JUnit serializer and prefix each generated testcase.classname with it. This keeps distinct generated or parameterized launch tests from collapsing into the same Jenkins test history.

Fixes ros2/ros2#1855
Related to osrf/buildfarm-tools#262

Testing

  • colcon build for launch_testing and launch_testing_ament_cmake
  • colcon test: 99 launch_testing tests passed
  • colcon test: 2 launch_testing_ament_cmake tests passed
  • Verified generated XML contains the CTest target in every testcase.classname

Generative AI

Codex was used to investigate the issue, implement the change, and run the tests.

@Quchaosheng

Copy link
Copy Markdown
Contributor Author

A gentle first ping on this one. The branch has been unchanged since 09-12, it has no conflicts, and both checks pass; the only thing missing is a review. If the approach needs rework, or if this is not something you want in rolling, say so and I will adjust or drop it.

@wjwwood wjwwood removed their assignment Sep 29, 2026
Jenkins's JUnit plugin splits testcase classname on the last '.'
into (packageName, className), and the default report grouping is
by packageName.  Prefixing puts the CTest target in front of the
package name, so every target becomes its own package and the
grouping under ${PROJECT_NAME} is lost.

Append the target to the class name instead, separated by two
underscores, so packageName stays the package.  getFullName(), the
key used to look up the previous result, still changes with the
target, so failure age stays per-target.

Replace '.' with '_' in the target: add_launch_test() defaults
TARGET to the test file name, and a '.py' segment would introduce
another dot.

Signed-off-by: 渠超胜 <[email protected]>
@Quchaosheng
Quchaosheng force-pushed the fix-unique-junit-test-names branch from b0e6b0c to 5b14988 Compare September 29, 2026 02:14
@Quchaosheng

Quchaosheng commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor Author

Both fixed in 5b14988. The target now goes on the end of the class name, so it comes out as test_xml_output.TestHost__.

I went with appending rather than putting it after <package_name>, because that doesn't actually help. getPackageName() splits classname on the last '.', so <package_name>.<test_name>. still leaves "test_xml_output.<test_name>" as the package name and ${PROJECT_NAME} doesn't group. Appending is the only one of the two that leaves the last dot where it is.

Uniqueness is unaffected: getFullName() is classname + '.' + name, and that's the key getPreviousResult() resolves through getCase(), so age still tracks per CTest target.

For the .py I normalized in the serializer rather than add_launch_test.cmake. _classname_suffix() replaces '.' with '_', so a default TARGET of test_foo.py becomes TestHost__test_foo_py. Stripping only the extension wouldn't be enough, the dot is what breaks the split, and junitxml.py is the one place that knows '.' is the package separator.

Also renamed classname_prefix to classname_suffix, since it doesn't prefix any more.

Added test_classname_suffix_keeps_package_grouping to pin the package name for every target spelling.

@Quchaosheng
Quchaosheng requested a review from wjwwood September 29, 2026 02:33
@wjwwood

wjwwood commented Sep 29, 2026

Copy link
Copy Markdown
Member

Pulls: #1002
Gist: https://gist.githubusercontent.com/wjwwood/05996524a7130d70f920a0e6cf5513a1/raw/1dcb3b8968bb83ead1cbd6b1f1bd60b2b4dc0c00/ros2.repos
BUILD args: --packages-up-to launch_testing launch_testing_ament_cmake launch_ros test_launch_ros
TEST args: --packages-select launch_testing launch_testing_ament_cmake launch_ros test_launch_ros
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/20555

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

@wjwwood
wjwwood merged commit 58e2a72 into ros2:rolling Sep 29, 2026
2 checks passed
@miguelgonrod

Copy link
Copy Markdown

Hi! thanks for taking a look at this. I have a question. This change needs to be made in all repositories with junit tests or just in this one?

@Quchaosheng

Copy link
Copy Markdown
Contributor Author

Just this one. The change is in launch_testing's JUnit serializer, so packages pick it up from the launch_testing they build against. Nothing to edit in the other repos, and anything pinned to an older launch_testing keeps the old classname until it bumps.

add_launch_test() already knew the unique CTest target name, it just never reached the serializer. Distinct generated or parameterized tests ended up sharing a testcase.classname and collapsed into one entry in Jenkins history.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🧑‍🌾 Buildfarm: Investigate non-unique test names in JUnit results causing incorrect Jenkins test history and age

3 participants