Saleem Abdulrasool 05d613ea93 [lit][clang] Avoid realpath on Windows due to MAX_PATH limitations
Running lit tests on Windows can fail because its use of
`os.path.realpath` expands substitute drives, which are used to keep
paths short and avoid hitting MAX_PATH limitations.

Changes lit logic to:

Use `os.path.abspath` on Windows, where `MAX_PATH` is a concern that we
can work around using substitute drives, which `os.path.realpath` would
resolve.

Use `os.path.realpath` on Unix, where the current directory always has
symlinks resolved, so it is impossible to preserve symlinks in the
presence of relative paths, and so we must make sure that all code paths
use real paths.

Also updates clang's `FileManager::getCanonicalName` and `ExtractAPI`
code to avoid resolving substitute drives (i.e. resolving to a path
under a different root).

How tested: built with `-DLLVM_ENABLE_PROJECTS=clang` and built `check-all` on both Windows

Differential Revision: https://reviews.llvm.org/D154130
Reviewed By: @benlangmuir

Patch by Tristan Labelle <tristan@thebrowser.company>!
2023-08-01 11:00:27 -07:00

31 lines
825 B
Plaintext
Executable File

#!@Python3_EXECUTABLE@
# -*- coding: utf-8 -*-
import os
import sys
config_map = {}
def map_config(source_dir, site_config):
global config_map
source_dir = os.path.abspath(source_dir)
source_dir = os.path.normcase(source_dir)
site_config = os.path.normpath(site_config)
config_map[source_dir] = site_config
# Set up some builtin parameters, so that by default the LLVM test suite
# configuration file knows how to find the object tree.
builtin_parameters = { 'build_mode' : '@BUILD_MODE@' }
@LLVM_LIT_CONFIG_MAP@
builtin_parameters['config_map'] = config_map
# Make sure we can find the lit package.
llvm_source_root = path(r'@LLVM_SOURCE_DIR@')
sys.path.insert(0, os.path.join(llvm_source_root, 'utils', 'lit'))
if __name__=='__main__':
from lit.main import main
main(builtin_parameters)