From e944f4c9500b824b8fc790f8f73bd20be8e33484 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Fri, 16 Jun 2023 07:06:09 -0700 Subject: [PATCH] Revert "[lit] Avoid os.path.realpath in lit.py due to MAX_PATH limitations on Windows" This reverts commit c1cf459cbd79cc7d6ca834390649fb9185a4b237. Reverting to permit time to explore the underlying issue. This change regressed the clang-PPC64-AIX and m68k-linux-cross builders. Differential Revision: https://reviews.llvm.org/D153138 Reviewed By: compnerd --- llvm/utils/lit/lit/TestRunner.py | 6 +++--- llvm/utils/lit/lit/builtin_commands/diff.py | 2 +- llvm/utils/lit/lit/discovery.py | 13 +++++++------ llvm/utils/lit/tests/Inputs/config-map-discovery/driver.py | 2 +- .../utils/lit/tests/Inputs/config-map-discovery/lit.alt.cfg | 2 +- llvm/utils/lit/tests/Inputs/use-llvm-tool-required/lit.cfg | 2 +- llvm/utils/lit/tests/Inputs/use-llvm-tool/lit.cfg | 2 +- 7 files changed, 15 insertions(+), 14 deletions(-) diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py index aaed0d2..2467061 100644 --- a/llvm/utils/lit/lit/TestRunner.py +++ b/llvm/utils/lit/lit/TestRunner.py @@ -74,7 +74,7 @@ class ShellEnvironment(object): if os.path.isabs(newdir): self.cwd = newdir else: - self.cwd = os.path.abspath(os.path.join(self.cwd, newdir)) + self.cwd = os.path.realpath(os.path.join(self.cwd, newdir)) class TimeoutHelper(object): @@ -427,7 +427,7 @@ def executeBuiltinMkdir(cmd, cmd_shenv): dir = to_unicode(dir) if kIsWindows else to_bytes(dir) cwd = to_unicode(cwd) if kIsWindows else to_bytes(cwd) if not os.path.isabs(dir): - dir = os.path.abspath(os.path.join(cwd, dir)) + dir = os.path.realpath(os.path.join(cwd, dir)) if parent: lit.util.mkdir_p(dir) else: @@ -473,7 +473,7 @@ def executeBuiltinRm(cmd, cmd_shenv): path = to_unicode(path) if kIsWindows else to_bytes(path) cwd = to_unicode(cwd) if kIsWindows else to_bytes(cwd) if not os.path.isabs(path): - path = os.path.abspath(os.path.join(cwd, path)) + path = os.path.realpath(os.path.join(cwd, path)) if force and not os.path.exists(path): continue try: diff --git a/llvm/utils/lit/lit/builtin_commands/diff.py b/llvm/utils/lit/lit/builtin_commands/diff.py index 87bcad7..3a91920 100644 --- a/llvm/utils/lit/lit/builtin_commands/diff.py +++ b/llvm/utils/lit/lit/builtin_commands/diff.py @@ -281,7 +281,7 @@ def main(argv): try: for file in args: if file != "-" and not os.path.isabs(file): - file = os.path.abspath(os.path.join(os.getcwd(), file)) + file = os.path.realpath(os.path.join(os.getcwd(), file)) if flags.recursive_diff: if file == "-": diff --git a/llvm/utils/lit/lit/discovery.py b/llvm/utils/lit/lit/discovery.py index 1924b54..5bfe1eb 100644 --- a/llvm/utils/lit/lit/discovery.py +++ b/llvm/utils/lit/lit/discovery.py @@ -56,7 +56,8 @@ def getTestSuite(item, litConfig, cache): # configuration to load instead. config_map = litConfig.params.get("config_map") if config_map: - target = config_map.get(os.path.normcase(os.path.abspath(cfgpath))) + cfgpath = os.path.realpath(cfgpath) + target = config_map.get(os.path.normcase(cfgpath)) if target: cfgpath = target @@ -66,16 +67,16 @@ def getTestSuite(item, litConfig, cache): cfg = TestingConfig.fromdefaults(litConfig) cfg.load_from_path(cfgpath, litConfig) - source_root = os.path.abspath(cfg.test_source_root or path) - exec_root = os.path.abspath(cfg.test_exec_root or path) + source_root = os.path.realpath(cfg.test_source_root or path) + exec_root = os.path.realpath(cfg.test_exec_root or path) return Test.TestSuite(cfg.name, source_root, exec_root, cfg), () def search(path): # Check for an already instantiated test suite. - full_path = os.path.normcase(os.path.abspath(path)) - res = cache.get(full_path) + real_path = os.path.realpath(path) + res = cache.get(real_path) if res is None: - cache[full_path] = res = search1(path) + cache[real_path] = res = search1(path) return res # Canonicalize the path. diff --git a/llvm/utils/lit/tests/Inputs/config-map-discovery/driver.py b/llvm/utils/lit/tests/Inputs/config-map-discovery/driver.py index 9d0f628..d22b84d 100644 --- a/llvm/utils/lit/tests/Inputs/config-map-discovery/driver.py +++ b/llvm/utils/lit/tests/Inputs/config-map-discovery/driver.py @@ -3,7 +3,7 @@ import os import sys main_config = sys.argv[1] -main_config = os.path.abspath(main_config) +main_config = os.path.realpath(main_config) main_config = os.path.normcase(main_config) config_map = {main_config: sys.argv[2]} diff --git a/llvm/utils/lit/tests/Inputs/config-map-discovery/lit.alt.cfg b/llvm/utils/lit/tests/Inputs/config-map-discovery/lit.alt.cfg index 80b202e..c7b303f 100644 --- a/llvm/utils/lit/tests/Inputs/config-map-discovery/lit.alt.cfg +++ b/llvm/utils/lit/tests/Inputs/config-map-discovery/lit.alt.cfg @@ -5,5 +5,5 @@ config.suffixes = ['.txt'] config.test_format = lit.formats.ShTest() import os -config.test_exec_root = os.path.abspath(os.path.dirname(__file__)) +config.test_exec_root = os.path.realpath(os.path.dirname(__file__)) config.test_source_root = os.path.join(config.test_exec_root, "tests") diff --git a/llvm/utils/lit/tests/Inputs/use-llvm-tool-required/lit.cfg b/llvm/utils/lit/tests/Inputs/use-llvm-tool-required/lit.cfg index 44d997d..e41207b 100644 --- a/llvm/utils/lit/tests/Inputs/use-llvm-tool-required/lit.cfg +++ b/llvm/utils/lit/tests/Inputs/use-llvm-tool-required/lit.cfg @@ -7,7 +7,7 @@ config.test_source_root = None config.test_exec_root = None import os.path -config.llvm_tools_dir = os.path.abspath(os.path.dirname(__file__)) +config.llvm_tools_dir = os.path.realpath(os.path.dirname(__file__)) import lit.llvm lit.llvm.initialize(lit_config, config) diff --git a/llvm/utils/lit/tests/Inputs/use-llvm-tool/lit.cfg b/llvm/utils/lit/tests/Inputs/use-llvm-tool/lit.cfg index 244253a..8fe62d9 100644 --- a/llvm/utils/lit/tests/Inputs/use-llvm-tool/lit.cfg +++ b/llvm/utils/lit/tests/Inputs/use-llvm-tool/lit.cfg @@ -7,7 +7,7 @@ config.test_source_root = None config.test_exec_root = None import os.path -this_dir = os.path.abspath(os.path.dirname(__file__)) +this_dir = os.path.realpath(os.path.dirname(__file__)) config.llvm_tools_dir = os.path.join(this_dir, "build") import lit.llvm -- 2.7.4