Clearpath configuration system generator testing
This repository contains test packages that version and validate the generated output of the
Clearpath generators (clearpath_generator_common, clearpath_generator_robot, and
clearpath_generator_gz). Each generator test package stores a set of reference samples and
compares them against freshly generated output to detect regressions.
| Package | Description |
|---|---|
clearpath_generator_base_tests |
Base test class (BaseGeneratorSampleTest) and shared utilities used by all generator test packages. |
clearpath_generator_common_tests |
Tests for clearpath_generator_common (bash, description, discovery server, SRDF, etc.). |
clearpath_generator_robot_tests |
Tests for clearpath_generator_robot (robot launch and parameter files). |
clearpath_generator_gz_tests |
Tests for clearpath_generator_gz (Gazebo launch and parameter files). |
Test samples originate from the clearpath_config package. The get_test_samples() utility
function in clearpath_generator_base_tests scans the clearpath_config sample directory for all
YAML files whose names contain test (e.g. test_a200, test_w200, test_all_dual_sensors).
Each generator test package has a samples/ directory that is checked into version control.
This directory contains the expected (reference) output for every test sample. When a generator
changes its output, these reference samples must be regenerated and committed.
Each generator test package provides a generate_samples executable that regenerates the
reference samples. By default, generated files are written into the package's samples/ directory.
# Common generator samples
ros2 run clearpath_generator_common_tests generate_samples
# Robot generator samples
ros2 run clearpath_generator_robot_tests generate_samples
# Gazebo generator samples
ros2 run clearpath_generator_gz_tests generate_samplesAn optional --out argument can be used to specify an alternative output directory:
ros2 run clearpath_generator_common_tests generate_samples --out /path/to/outputAfter generating, review the changes and commit the updated samples/ directory.
Tests are run through colcon test using ament_cmake_pytest. Each generator test package
registers its generator_tests.py as a pytest test. The tests execute in order:
test_generate_samples— Runs the generator against all test samples, writing output to a temporary directory (~/.clearpath/samples). Raises an exception if generation fails.test_number_of_samples_match— Compares the directory trees of the generated output and the installed reference samples to ensure no files or directories are missing or unexpected.test_samples_match— Performs a file-by-file diff between the generated output and the installed reference samples, reporting any content mismatches.
To run all generator tests:
colcon test --packages-select \
clearpath_generator_common_tests \
clearpath_generator_robot_tests \
clearpath_generator_gz_tests
colcon test-result --verboseWhen making changes to clearpath_common, clearpath_robot, or clearpath_simulator that affect
generator output, a corresponding branch with the same name must be created in the
clearpath_generator_tests repository with regenerated samples.
- Create a branch in the source repository (e.g.
clearpath_common) and make your changes. - Create a branch with the same name in
clearpath_generator_tests. - Build the workspace so the generator changes are installed.
- Regenerate samples for each affected generator:
ros2 run clearpath_generator_common_tests generate_samples ros2 run clearpath_generator_robot_tests generate_samples ros2 run clearpath_generator_gz_tests generate_samples
- Run the tests to verify the regenerated samples are consistent:
colcon test --packages-select \ clearpath_generator_common_tests \ clearpath_generator_robot_tests \ clearpath_generator_gz_tests colcon test-result --verbose - Review and commit the updated
samples/directories inclearpath_generator_tests. - Push both branches. The matching branch names allow CI and reviewers to pair the generator changes with their expected output.