Skip to content

[TEST] ExternalProcess: cover spaces in the executable path and arguments (#9460) - #9531

Merged
timosachsenberg merged 1 commit into
OpenMS:developfrom
timosachsenberg:test/9460-externalprocess-spaces
Jun 16, 2026
Merged

timosachsenberg merged 1 commit into
OpenMS:developfrom
timosachsenberg:test/9460-externalprocess-spaces

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Jun 15, 2026 •

Copy link
Copy Markdown
Contributor

What

Adds an ExternalProcess_test case (non-Windows) that:

  1. writes an executable script to a path containing a space (…/open ms space dir/my script.sh),
  2. runs it via ExternalProcess::run with a single argument that itself contains spaces ("one two three"),
  3. asserts the process launches (RETURNSTATE::SUCCESS), its stdout is captured intact (MARKER_STDOUT_OK), and the spaced argument arrived as one argument (arg=[one two three]), i.e. it was not shell-split.

Why

Closes the §1 (Qt removal: QProcess → boost::process) [AUTO] task in the OpenMS 3.6.0 pre-release testing plan (#9460):

Add an arg-quoting / spaces-in-exe-path case to ExternalProcess_test. Pass: a path with spaces runs and stdout is captured intact.

The existing section only ran PATH-resolved tools (ls/cmd) with whitespace-free args, so neither the spaces-in-exe-path pitfall (think C:\Program Files\… / /opt/My Tool/…) nor single-argument quoting was exercised. boost::process receives argv as a vector, so no shell re-quoting should occur — this pins that contract.

Windows is guarded out (#ifndef OPENMS_WINDOWSPLATFORM): launching a freshly-written .bat through ExternalProcess needs a cmd shim, and the existing cmd-based section already covers the Windows lane — matching the file's existing platform branching.

Test plan

Tests only — no production code changed. Verified locally: -fsyntax-only clean, full build green, test runs PASSED (both new assertions ok). The case confirms ExternalProcess already handles spaces correctly (no bug surfaced — it's a regression guard).

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

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Enhanced test coverage for handling file paths and arguments containing spaces in external process execution.

…ents (OpenMS#9460)

ExternalProcess_test only ran PATH-resolved tools (ls/cmd) with simple args.
Adds a case (non-Windows) that creates an executable script at a path containing
a space and runs it with a single argument that itself contains spaces, then
asserts:
- the spaces-in-path executable launches (RETURNSTATE::SUCCESS) and its stdout is
  captured intact, and
- the spaced argument arrives as ONE argument (arg=[one two three]), i.e. it is
  not shell-split -- boost::process receives argv as a vector.

Windows is guarded out (launching a freshly-written .bat needs a cmd shim; the
existing cmd-based section covers it).

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:38:29.783226260 +0000
+++ AUTHORS.new	2026-06-15 15:38:35.001709761 +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: fc419c0a-4b04-4360-9fd5-c82f68c556f7

📥 Commits

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

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

📝 Walkthrough

Walkthrough

A new [EXTRA] test section is added to ExternalProcess_test.cpp covering execution of a script located in a directory path containing spaces, with a space-containing argument. Two standard headers (<filesystem>, <fstream>) are added. The section is non-Windows only; Windows is marked NOT_TESTABLE.

Changes

ExternalProcess spaces-in-path test

Layer / File(s) Summary
Spaces-in-path test section and supporting headers
src/tests/class_tests/openms/source/ExternalProcess_test.cpp
Adds <filesystem> and <fstream> includes; introduces a non-Windows test section that creates a temp dir with spaces in its path, writes and permissions a shell script, runs ExternalProcess with a spaced argument, captures stdout/stderr via callbacks, asserts success and argument integrity, and removes the temp dir. Windows path is marked NOT_TESTABLE.

🐇 A path full of spaces, a test full of cheer,
The script runs with gaps and the args are still clear!
No shell splits the argument, no marker goes missing,
ExternalProcess handles it — absolutely hissing!
✨ Hopping along, the bunny approves. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.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 and specifically describes the main change: adding a test case that covers spaces in executable paths and arguments for ExternalProcess.
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