Skip to content

Commit 80f0648

Browse files
committed
[clang-tidy][test] Make check_clang_tidy.py work with very long file paths
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
1 parent c950a72 commit 80f0648

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

clang-tools-extra/test/clang-tidy/check_clang_tidy.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import argparse
4646
import os
4747
import pathlib
48+
import platform
4849
import re
4950
import subprocess
5051
import sys
@@ -145,7 +146,10 @@ def __init__(self, args: argparse.Namespace, extra_args: List[str]) -> None:
145146
self.clang_extra_args.append("-resource-dir=%s" % self.resource_dir)
146147

147148
def read_input(self) -> None:
148-
with open(self.input_file_name, "r", encoding="utf-8") as input_file:
149+
file_name = self.input_file_name
150+
if platform.system() == "Windows":
151+
file_name = "\\\\?\\" + os.path.abspath(file_name)
152+
with open(file_name, "r", encoding="utf-8") as input_file:
149153
self.input_text = input_file.read()
150154

151155
def get_prefixes(self) -> None:

0 commit comments

Comments
 (0)