Skip to content

[TEST] PathUtils: round-trip CJK / spaces / >260-char paths through to_path (#9460) - #9528

Merged
timosachsenberg merged 1 commit into
OpenMS:developfrom
timosachsenberg:test/9460-pathutils-unicode
Jun 17, 2026
Merged

timosachsenberg merged 1 commit into
OpenMS:developfrom
timosachsenberg:test/9460-pathutils-unicode

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Jun 15, 2026 •

Copy link
Copy Markdown
Contributor

What

Extends PathUtils_test with byte-exact round-trip cases for OpenMS::to_path(const std::string&):

  • CJK (Japanese 日本語.mzML)
  • Embedded spaces / parentheses (my data file (run 1).mzML)
  • >260-char name (a 300-char filename — well past the historical Windows MAX_PATH of 260; constructing the path object must not truncate or throw, since that limit applies to filesystem operations, not to the path object)
  • Mixed CJK + Latin-1 diacritics with a space (测试 äö.featureXML)

The existing ä case is upgraded from a non-empty check to a full round-trip.

Why

Closes the §1 (Qt removal / infrastructure) [AUTO] task in the OpenMS 3.6.0 pre-release testing plan (#9460):

Extend PathUtils_test.cpp with CJK, embedded-space, and >260-char path cases. Pass: to_path returns a non-empty path that round-trips back to the original UTF-8 bytes.

Before this, PathUtils_test asserted only ASCII identity plus a single non-empty ä case. Since the Qt removal, all file I/O flows through to_path(), so the non-ASCII handling deserves an end-to-end guard.

The round-trip is asserted via path::u8string(), which is UTF-8 on every platform — unlike string(), which is lossy on the Windows ANSI code page. So these cases are meaningful cross-platform, not just on Linux. (The Windows-only ANSI-codepage / UNC sub-item from the issue is a separate task and not in scope here.)

Test plan

Tests only — no production code changed. Verified locally three ways:

  • the round-trip invariant proven with a standalone <filesystem> snippet first;
  • -fsyntax-only clean, then full target build green;
  • the test runs PASSED.

Part of #9460. Follows #9524, #9525, #9526.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Enhanced test coverage for UTF-8 path handling across platforms.
    • Added validation for non-ASCII character support in path round-tripping, including CJK text, spaces, parentheses, and long filenames.

…o_path (OpenMS#9460)

PathUtils_test only asserted ASCII identity plus one non-empty UTF-8 'ä' case.
Since the Qt removal all file I/O flows through OpenMS::to_path(const std::string&),
so the non-ASCII path handling needs an end-to-end guard.

Adds round-trip cases asserting that a valid UTF-8 string survives
to_path() -> path::u8string() byte-for-byte (u8string() is UTF-8 on every
platform, unlike string() which is lossy on the Windows ANSI code page):
- CJK (Japanese), embedded spaces/parentheses, a >300-char name (well past the
  historical Windows MAX_PATH of 260; path construction must not truncate/throw),
  and a mixed CJK + Latin-1-diacritic name. The existing 'ä' case is upgraded
  from a non-empty check to a full round-trip.

Verified: builds clean and the test runs PASSED.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

@timosachsenberg The following names might be missing from the AUTHORS file:

  • Timo Sachsenberg

Please consider applying the following patch:

--- AUTHORS	2026-06-15 15:20:29.838765240 +0000
+++ AUTHORS.new	2026-06-15 15:20:35.035769772 +0000
@@ -23,8 +23,8 @@
  - Chirag Dave
  - Chris Bauer
  - Chris Bielow
- - Christie Mathews
  - Christian Ehrlich
+ - Christie Mathews
  - Clemens Groepl
  - Cornelia Friedle
  - Daniel Jameson

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1f386c89-539e-435e-970b-6c6a50ef2e83

📥 Commits

Reviewing files that changed from the base of the PR and between aacd941 and d748503.

📒 Files selected for processing (1)
  • src/tests/class_tests/openms/source/PathUtils_test.cpp

📝 Walkthrough

Walkthrough

A local asUtf8 helper is added to PathUtils_test.cpp to losslessly convert std::filesystem::path::u8string() to std::string. The to_path test section is then extended with byte-exact UTF-8 round-trip assertions for CJK text, paths with spaces and parentheses, very long filenames, and mixed CJK/diacritics strings.

Changes

UTF-8 Round-Trip Test Coverage

Layer / File(s) Summary
asUtf8 helper and expanded to_path assertions
src/tests/class_tests/openms/source/PathUtils_test.cpp
Introduces asUtf8(std::filesystem::path) to extract byte-exact UTF-8 from u8string(), and adds TEST_EQUAL assertions verifying that to_path() round-trips CJK text, space/parenthesis-containing paths, long filenames, and mixed CJK/diacritics strings without byte loss.

Possibly related PRs

  • OpenMS/OpenMS#9452: Directly related — that PR fixes OpenMS::to_path non-ASCII/UTF-8 handling, and this PR adds the corresponding byte-exact round-trip test coverage for those fixes.

Suggested reviewers

  • jpfeuffer

🐰 Hop, hop through Unicode land,
CJK and diacritics, all close at hand,
asUtf8 checks each byte with care,
Round-trips complete without a hair,
The path is true — the rabbit declares! 🌸

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: extending PathUtils test cases with round-trip verification for CJK, spaces, and long paths (>260 characters).
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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