Skip to content

Conversation

aeubanks
Copy link
Contributor

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

…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
@llvmbot
Copy link
Member

llvmbot commented Aug 25, 2025

@llvm/pr-subscribers-clang-tidy

@llvm/pr-subscribers-clang-tools-extra

Author: Arthur Eubanks (aeubanks)

Changes

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


Full diff: https://github.com/llvm/llvm-project/pull/155318.diff

1 Files Affected:

  • (modified) clang-tools-extra/test/clang-tidy/check_clang_tidy.py (+5-1)
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..7c77e498f28f8 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,10 @@ 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:
+        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:

@nico
Copy link
Contributor

nico commented Aug 25, 2025

This is fine, but IMHO we should also rename the test to something shorter. Long paths are a pain in explorer.exe and other places too.

@aeubanks
Copy link
Contributor Author

This is fine, but IMHO we should also rename the test to something shorter. Long paths are a pain in explorer.exe and other places too.

the test name is kinda long, but the thing that's actually failing is the generated file name inside the test here. we could fix that test, but I'd rather just make this less of a problem in general

Copy link
Collaborator

@rnk rnk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with suggested comment

@aeubanks aeubanks merged commit 0cddf3e into llvm:main Aug 26, 2025
9 checks passed
@aeubanks aeubanks deleted the win branch August 26, 2025 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants