From bd01f2d8b0a1765e6b6d25c5453cb02d981cb6df Mon Sep 17 00:00:00 2001 From: Michael Brantley Date: Fri, 18 Sep 2026 08:28:48 +0100 Subject: [PATCH] Make test_search_cpp robust to header paths containing "xxx" 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 --- distutils/tests/test_config_cmd.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/distutils/tests/test_config_cmd.py b/distutils/tests/test_config_cmd.py index 86f8b82a..7d42e2dc 100644 --- a/distutils/tests/test_config_cmd.py +++ b/distutils/tests/test_config_cmd.py @@ -47,7 +47,9 @@ def test_search_cpp(self): ) # simple pattern searches - match = cmd.search_cpp(pattern='xxx', body='/* xxx */') + # Skip line-marker lines ('# 1 "/path/to/header.h"'); the header + # paths they contain may legitimately include the search token. + match = cmd.search_cpp(pattern=r'^(?!#).*xxx', body='/* xxx */') assert match == 0 match = cmd.search_cpp(pattern='_configtest', body='/* xxx */')