Author: Arthur Eubanks Date: 2025-08-26T10:15:47-07:00 New Revision: 0cddf3e1aefc8d5f96e000a9c69d0fa596fdb04a
URL: https://github.com/llvm/llvm-project/commit/0cddf3e1aefc8d5f96e000a9c69d0fa596fdb04a DIFF: https://github.com/llvm/llvm-project/commit/0cddf3e1aefc8d5f96e000a9c69d0fa596fdb04a.diff LOG: [clang-tidy][test] Make check_clang_tidy.py work with very long file paths (#155318) http://github.com/llvm/llvm-project/pull/95220 added a test with a very long file path, which can fail if run on Windows with a long directory path. On Windows, there are file path length limits, which can be worked around by prefixing the (absolute) path with '\\?\': https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation --------- Co-authored-by: Reid Kleckner <[email protected]> Added: Modified: clang-tools-extra/test/clang-tidy/check_clang_tidy.py Removed: ################################################################################ diff --git a/clang-tools-extra/test/clang-tidy/check_clang_tidy.py b/clang-tools-extra/test/clang-tidy/check_clang_tidy.py index d225258c5d75d..d80a28044ea0a 100755 --- a/clang-tools-extra/test/clang-tidy/check_clang_tidy.py +++ b/clang-tools-extra/test/clang-tidy/check_clang_tidy.py @@ -45,6 +45,7 @@ import argparse import os import pathlib +import platform import re import subprocess import sys @@ -145,7 +146,12 @@ def __init__(self, args: argparse.Namespace, extra_args: List[str]) -> None: self.clang_extra_args.append("-resource-dir=%s" % self.resource_dir) def read_input(self) -> None: - with open(self.input_file_name, "r", encoding="utf-8") as input_file: + # Use a "\\?\" prefix on Windows to handle long file paths transparently: + # https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation + file_name = self.input_file_name + if platform.system() == "Windows": + file_name = "\\\\?\\" + os.path.abspath(file_name) + with open(file_name, "r", encoding="utf-8") as input_file: self.input_text = input_file.read() def get_prefixes(self) -> None: _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
