From 92bd7664d64a45324900a5935d6e0af7ca60b922 Mon Sep 17 00:00:00 2001 From: esadomer <54475303+esadomer@users.noreply.github.com> Date: Tue, 13 Oct 2026 19:50:34 +0300 Subject: [PATCH 1/2] gh-159338: Default the warning checker's optional path prefix to an empty string --- Lib/test/test_tools/test_check_warnings.py | 30 ++++++++++++++++++++++ Tools/build/check_warnings.py | 1 + 2 files changed, 31 insertions(+) create mode 100644 Lib/test/test_tools/test_check_warnings.py diff --git a/Lib/test/test_tools/test_check_warnings.py b/Lib/test/test_tools/test_check_warnings.py new file mode 100644 index 000000000000000..e8745b421784062 --- /dev/null +++ b/Lib/test/test_tools/test_check_warnings.py @@ -0,0 +1,30 @@ +import importlib +import unittest +from pathlib import Path +from test.support import captured_stdout, os_helper + +from test.test_tools import imports_under_tool, skip_if_missing + + +skip_if_missing("build") +with imports_under_tool("build"): + check_warnings = importlib.import_module("check_warnings") + + +class CheckWarningsTests(unittest.TestCase): + def test_cli_without_path_prefix(self): + with os_helper.temp_dir() as directory: + output = Path(directory, "compiler.txt") + output.write_text("source.c:1:2: warning: example [-Wunused]\n", + encoding="utf-8") + ignore = Path(directory, "ignore.txt") + ignore.write_text("source.c 1\n", encoding="utf-8") + args = ["-c", str(output), "-i", str(ignore), "-t", "gcc"] + with captured_stdout(): + self.assertEqual(check_warnings.main(args), 0) + self.assertEqual(check_warnings.main( + args + ["--fail-on-regression"]), 0) + + +if __name__ == "__main__": + unittest.main() diff --git a/Tools/build/check_warnings.py b/Tools/build/check_warnings.py index 44ccf9708ad72f0..c568bdf82ed3003 100644 --- a/Tools/build/check_warnings.py +++ b/Tools/build/check_warnings.py @@ -267,6 +267,7 @@ def main(argv: list[str] | None = None) -> int: "-p", "--path-prefix", type=str, + default="", help="Path prefix to remove from the start of file paths" " in compiler output", ) From ee32a4871ed99d4723e9148a66f7f862c635dbbd Mon Sep 17 00:00:00 2001 From: esadomer <54475303+esadomer@users.noreply.github.com> Date: Tue, 13 Oct 2026 20:09:00 +0300 Subject: [PATCH 2/2] gh-159338: Add NEWS entry for warnings-default-path-prefix --- .../Tools-Demos/2026-10-13-20-08-59.gh-issue-159338.wPthPr.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Tools-Demos/2026-10-13-20-08-59.gh-issue-159338.wPthPr.rst diff --git a/Misc/NEWS.d/next/Tools-Demos/2026-10-13-20-08-59.gh-issue-159338.wPthPr.rst b/Misc/NEWS.d/next/Tools-Demos/2026-10-13-20-08-59.gh-issue-159338.wPthPr.rst new file mode 100644 index 000000000000000..c2c22559b171f17 --- /dev/null +++ b/Misc/NEWS.d/next/Tools-Demos/2026-10-13-20-08-59.gh-issue-159338.wPthPr.rst @@ -0,0 +1,2 @@ +Fix ``Tools/build/check_warnings.py`` to work when ``--path-prefix`` +is omitted.