Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions Lib/test/test_tools/test_check_warnings.py
Original file line number Diff line number Diff line change
@@ -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()
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix ``Tools/build/check_warnings.py`` to work when ``--path-prefix``
is omitted.
1 change: 1 addition & 0 deletions Tools/build/check_warnings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
Expand Down
Loading