Skip to content

feat(tests): add CTest labels for selective C++ test execution#1101

Closed
rgsl888prabhu wants to merge 2 commits intomainfrom
feat/ctest-labels
Closed

feat(tests): add CTest labels for selective C++ test execution#1101
rgsl888prabhu wants to merge 2 commits intomainfrom
feat/ctest-labels

Conversation

@rgsl888prabhu
Copy link
Copy Markdown
Collaborator

Summary

  • Add domain labels to all 31 C++ test executables so CI and developers can run only tests relevant to their changes
  • Extend ConfigureTest() CMake macro with an optional LABELS keyword — backward compatible, existing calls work unchanged
  • Generate and install a test_labels.txt manifest alongside test binaries
  • Update ci/run_ctests.sh to support CUOPT_TEST_LABELS env var for filtering (e.g. CUOPT_TEST_LABELS=routing runs only routing tests)

Label map

Label Tests Count
routing ROUTING_TEST, ROUTING_GES_TEST, VEHICLE_ORDER_TEST, VEHICLE_TYPES_TEST, OBJECTIVE_FUNCTION_TEST, RETAIL_L1TEST, ROUTING_L1TEST, ROUTING_UNIT_TEST, WAYPOINT_MATRIXTEST 9
solver All LP + MIP + QP + dual simplex + MPS parser tests (umbrella) 20
lp LP_UNIT_TEST, PDLP_TEST, C_API_TEST, DUAL_SIMPLEX_TEST 4
mip MIP_TEST, PROBLEM_TEST, ELIM_VAR_REMAP_TEST, STANDARDIZATION_TEST, MULTI_PROBE_TEST, INCUMBENT_CALLBACK_TEST, DOC_EXAMPLE_TEST, CUTS_TEST, UNIT_TEST, EMPTY_FIXED_PROBLEMS_TEST, PRESOLVE_TEST, MIP_TERMINATION_STATUS_TEST, DETERMINISM_TEST, HEURISTICS_HYPER_PARAMS_TEST 14
qp QP_UNIT_TEST 1
parser MPS_PARSER_TEST (also in solver) 1
grpc GRPC_CLIENT_TEST, GRPC_PIPE_SERIALIZATION_TEST, GRPC_INTEGRATION_TEST 3
cli CLI_TEST 1

Usage

# CI — run only routing tests
CUOPT_TEST_LABELS=routing ./ci/run_ctests.sh

# CI — run all solver tests (LP+MIP+QP+parser)
CUOPT_TEST_LABELS=solver ./ci/run_ctests.sh

# CI — run routing + solver tests
CUOPT_TEST_LABELS=routing,solver ./ci/run_ctests.sh

# Local dev — use CTest directly
ctest -L routing          # only routing
ctest -L mip              # only MIP
ctest                     # all (unchanged default)

# No env var set — runs everything (fully backward compatible)
./ci/run_ctests.sh

Design decisions

  • LP, MIP, QP, dual simplex, and MPS parser share a solver umbrella label because they compile into a single libcuopt.so with 31+ cross-includes — a change in one domain can break the others
  • Sub-domain labels (lp, mip, qp, parser) are kept for finer local dev iteration
  • Tests not in the manifest default to run (safe fallback for new tests)
  • Missing manifest file prints a warning and runs all tests

Test plan

  • Verify cmake --build succeeds and test_labels.txt is generated in the build directory
  • Run ctest -L routing and verify only routing tests execute
  • Run ctest -L solver and verify LP+MIP+QP+parser tests execute
  • Run CUOPT_TEST_LABELS=routing ./ci/run_ctests.sh and verify filtering
  • Run ./ci/run_ctests.sh (no env var) and verify all tests run unchanged
  • Verify full CI pipeline passes with no behavioral change (no CUOPT_TEST_LABELS set)

🤖 Generated with Claude Code

@rgsl888prabhu rgsl888prabhu requested review from a team as code owners April 14, 2026 20:40
…+ test execution

Add domain and tier labels to all 31 C++ test executables so that CI and
developers can run only the tests relevant to their changes.

Labels:
  - Domain: routing, solver (LP+MIP+QP umbrella), lp, mip, qp, grpc, parser, cli
  - Tier: tier1 (fast unit tests), tier2 (slow integration/benchmarks)

Changes:
  - Extend ConfigureTest() CMake macro with optional LABELS keyword argument
  - Add register_test_labels() helper and CUOPT_TEST_LABEL_ENTRIES global
    property to generate an installed test_labels.txt manifest
  - Add labels to every ConfigureTest call and manual add_test call
  - Update ci/run_ctests.sh to support CUOPT_TEST_LABELS env var for
    filtering (e.g. CUOPT_TEST_LABELS=routing runs only routing tests)
  - Fully backward compatible: no labels set means all tests run
- Remove tier1/tier2 labels — keep only domain labels for simplicity
- Add solver label to MPS_PARSER_TEST so CUOPT_TEST_LABELS=solver
  includes it alongside LP/MIP/QP tests
- Update run_ctests.sh docs to reflect final label set
@rgsl888prabhu rgsl888prabhu deleted the feat/ctest-labels branch April 14, 2026 20:43
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 14, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 39ed8fd4-3301-4f42-884b-82bc660ff0f9

📥 Commits

Reviewing files that changed from the base of the PR and between e3e7510 and 867c4c6.

📒 Files selected for processing (11)
  • ci/run_ctests.sh
  • cpp/libmps_parser/tests/CMakeLists.txt
  • cpp/tests/CMakeLists.txt
  • cpp/tests/distance_engine/CMakeLists.txt
  • cpp/tests/dual_simplex/CMakeLists.txt
  • cpp/tests/linear_programming/CMakeLists.txt
  • cpp/tests/linear_programming/grpc/CMakeLists.txt
  • cpp/tests/mip/CMakeLists.txt
  • cpp/tests/qp/CMakeLists.txt
  • cpp/tests/routing/CMakeLists.txt
  • cpp/tests/utilities/CMakeLists.txt

📝 Walkthrough

Walkthrough

Adds CTest label metadata to many CMake test registrations and generates an installed test_labels.txt manifest; updates CI script ci/run_ctests.sh with a local should_run_test() to skip or run gtests based on the CUOPT_TEST_LABELS environment variable and the installed manifest.

Changes

Cohort / File(s) Summary
CI Test Execution
ci/run_ctests.sh
Added should_run_test() to decide run vs skip based on CUOPT_TEST_LABELS and ${GTEST_DIR}/test_labels.txt; loop updated to call it for each *_TEST binary; C_API_TEST execution now gated by should_run_test.
CMake test manifest & helpers
cpp/tests/CMakeLists.txt
Introduced global CUOPT_TEST_LABEL_ENTRIES, register_test_labels() helper, extended ConfigureTest to accept LABELS, set CTest LABELS property when provided, emit test_labels.txt into build dir and install it to bin/gtests/libcuopt (testing component).
Individual test label additions (solver / lp / qp / mip)
cpp/tests/dual_simplex/CMakeLists.txt, cpp/tests/linear_programming/CMakeLists.txt, cpp/tests/qp/CMakeLists.txt, cpp/tests/mip/CMakeLists.txt
Added LABELS arguments to ConfigureTest invocations (e.g., solver lp, solver qp, solver mip) and registered those labels via the new helper; C_API_TEST explicitly set to solver;lp.
Routing & domain-specific labels
cpp/tests/routing/CMakeLists.txt, cpp/tests/distance_engine/CMakeLists.txt, cpp/tests/utilities/CMakeLists.txt, cpp/libmps_parser/tests/CMakeLists.txt
Added LABELS routing, LABELS cli, and LABELS parser to respective test registrations and registered the labels.
GRPC tests
cpp/tests/linear_programming/grpc/CMakeLists.txt
Set LABELS "grpc" and registered labels for GRPC_CLIENT_TEST, GRPC_PIPE_SERIALIZATION_TEST, and GRPC_INTEGRATION_TEST.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding CTest labels for selective C++ test execution.
Description check ✅ Passed The description is comprehensive and directly related to the changeset, covering objectives, design decisions, usage examples, and test plan.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/ctest-labels

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

1 participant