Skip to content

CatchShardTestsImpl: quote TEST_BINARY so paths with spaces work - #3231

Open
lee3Q wants to merge 3 commits into
catchorg:develfrom
lee3Q:fix/shard-tests-quote-binary
Open

lee3Q wants to merge 3 commits into
catchorg:develfrom
lee3Q:fix/shard-tests-quote-binary

Conversation

@lee3Q

@lee3Q lee3Q commented Nov 5, 2026

Copy link
Copy Markdown

The generated shard CTest file wrote TEST_BINARY into add_test unquoted. With a test executable in a directory whose name contains spaces, CTest split the path at the first space and the shard tests were reported as Not Run. This change writes the path as a CMake bracket argument, using a delimiter that does not occur in the path (so a path containing ]==] or ${...} also reaches CTest unchanged).

TEST_SPEC and REPORTER_SPEC handling is not changed.

Tests: a new helper test copies SelfTest into a directory containing spaces, ]==] and ${NOT_A_VARIABLE}, generates the shard file and checks that the listed command starts with that exact path. It is labeled uses-python like the neighboring Python helper tests, and it only lists tests (it does not run the copied binary).

Checks run (Linux, GCC 11.4, CMake 3.22.1, Python 3.10.12), by an independent reviewer:

  • Without the fix the new test fails (the command is missing from the generated listing), and a real run from a spaced path gives CTest exit 8 with the shards Not Run.
  • With the fix the new test passes and the full helper-test set (86 tests) passes. A separate runtime check with four matching tests across two shards passed.
  • A binary path containing a semicolon stays one argument.

Known limits: a literal backslash in a Linux file name does not produce a runnable command with or without this change (CTest normalizes the path); I did not test Windows. Not run: Windows, macOS, multi-config generators, the CMake 3.10 minimum.

An AI coding assistant helped write and test this change.

lee3Q added 3 commits November 6, 2026 02:10
Generate the shard test command with TEST_BINARY as a bracket argument so paths with spaces or special characters reach CTest unchanged.
Run the new check with the other Python helper tests and label it uses-python.
…aracters

Copy SelfTest into a directory with spaces, a closing bracket sequence and a dollar-brace text, generate the shard tests, and check the listed command.
@codecov

codecov Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.38%. Comparing base (a1a991f) to head (71f34a2).
⚠️ Report is 3 commits behind head on devel.

Additional details and impacted files
@@            Coverage Diff             @@
##            devel    #3231      +/-   ##
==========================================
- Coverage   91.41%   91.38%   -0.03%     
==========================================
  Files         205      205              
  Lines        9106     9106              
==========================================
- Hits         8324     8321       -3     
- Misses        782      785       +3     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@horenmar horenmar added the Extras Touches utility scripts outside of Catch2 proper, e.g. CMake integration. label Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Extras Touches utility scripts outside of Catch2 proper, e.g. CMake integration.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants