Skip to content

tests: make test_search_cpp robust to header paths containing "xxx" - #432

Open
limeytexan wants to merge 1 commit into
pypa:mainfrom
limeytexan:fix-test-search-cpp-header-paths
Open

limeytexan wants to merge 1 commit into
pypa:mainfrom
limeytexan:fix-test-search-cpp-header-paths

Conversation

@limeytexan

Copy link
Copy Markdown

TestConfig.test_search_cpp asserts that the preprocessor strips the comment /* xxx */ by searching the preprocessed output for the regex xxx. That search runs over every line of the output, including the line markers the preprocessor emits for implicitly included headers, e.g.

# 1 "/nix/store/9sfgm5hh368klnp22aa9xxx9an4wqnsk-glibc-2.42-67-dev/include/stdc-predef.h" 1 3 4

On Nix, store paths carry a content hash whose base-32 alphabet includes x, so any glibc build whose hash contains xxx makes the test fail even though the comment was stripped correctly:

>       assert match == 0
E       assert True == 0

The same thing can happen on any system where an include path contains the token. This change anchors the first pattern so that lines starting with # are ignored, which keeps the test's intent (comments are removed from the code) without depending on the contents of header paths. The second assertion, which deliberately matches the _configtest line marker, is unchanged.

Observed with distutils 83.0.0 on aarch64-linux, Python 3.14.6, gcc, glibc 2.42-67.

🤖 Generated with Claude Code

The test asserts that the preprocessor strips the comment `/* xxx */`
by searching every line of the preprocessed output for `xxx`. That
includes the line markers emitted for implicitly included headers, e.g.

    # 1 "/nix/store/9sfgm5hh368klnp22aa9xxx9an4wqnsk-glibc-2.42-67-dev/include/stdc-predef.h" 1 3 4

so an include path that happens to contain the token makes the test
fail even though the comment was stripped correctly. Anchor the pattern
so lines beginning with `#` are ignored; the second assertion, which
deliberately matches the `_configtest` line marker, is unchanged.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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