Skip to content

internal/testutil/daemon.New: cleanup test paths#52311

Merged
thaJeztah merged 1 commit intomoby:masterfrom
thaJeztah:strip_special_chars
Apr 7, 2026
Merged

internal/testutil/daemon.New: cleanup test paths#52311
thaJeztah merged 1 commit intomoby:masterfrom
thaJeztah:strip_special_chars

Conversation

@thaJeztah
Copy link
Copy Markdown
Member

@thaJeztah thaJeztah commented Apr 5, 2026

relates to:

remove special characters (like double or single quotes) from name to prevent creating filesystem paths that can cause errors when parsing through scripts.

Test-names (t.Name()) for sub-tests allow free-form names to be used, for example:

t.Run("engine restart shouldn't kill alive containers", func(t *testing.T) {

Which would result in the quote (') to be included in the filename, which is valid, but can cause issues when processing with shell scripts;

find bundles -path '*/root/*overlay2' -prune -o -type f \( -name '*-report.json' -o -name '*.log' -o -name '*.out' -o -name '*.prof' -o -name '*-report.xml' \) -print | xargs sudo tar -czf /tmp/reports.tar.gz
[...]
xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option

This patch adds a sanitizedTestName utility that replaces special characters with an underscore to prevent such issues.

- What I did

- How I did it

- How to verify it

- Human readable description for the release notes

- A picture of a cute animal (not mandatory but encouraged)

@thaJeztah
Copy link
Copy Markdown
Member Author

AH! Windows ... Windows ...

=== FAIL: internal/testutil/daemon TestSanitizeTestName/ends-with-dash- (0.00s)
    daemon_test.go:85: got "TestSanitizeTestName\\ends-with-dash-", want "TestSanitizeTestName/ends-with-dash-"

remove special characters (like double or single quotes) from name to prevent
creating filesystem paths that can cause errors when parsing through scripts.

Test-names (t.Name()) for sub-tests allow free-form names to be used, for example:

    t.Run("engine restart shouldn't kill alive containers", func(t *testing.T) {

Which would result in the quote (') to be included in the filename,
which is valid, but can cause issues when processing with shell scripts;

    find bundles -path '*/root/*overlay2' -prune -o -type f \( -name '*-report.json' -o -name '*.log' -o -name '*.out' -o -name '*.prof' -o -name '*-report.xml' \) -print | xargs sudo tar -czf /tmp/reports.tar.gz
    [...]
    xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option

This patch adds a `sanitizedTestName` utility that replaces special characters
with an underscore to prevent such issues.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah thaJeztah force-pushed the strip_special_chars branch from c05a9a7 to f42ff6a Compare April 5, 2026 10:53
@thaJeztah thaJeztah merged commit e594fdc into moby:master Apr 7, 2026
205 of 206 checks passed
@thaJeztah thaJeztah deleted the strip_special_chars branch April 7, 2026 07:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI began to fail on 2026-04-03: xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option

2 participants