llvm-capstone/clang/test/Lexer/case-insensitive-include-win.c
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

17 lines
748 B
C

// Most Microsoft-specific testing should go in case-insensitive-include-ms.c
// This file should only include code that really needs a Windows host OS to
// run.
// Note: We must use the real path here, because the logic to detect case
// mismatches must resolve the real path to figure out the original casing.
// If we use %t and we are on a substitute drive S: mapping to C:\subst,
// then we will compare "S:\test.dir\FOO.h" to "C:\subst\test.dir\foo.h"
// and avoid emitting the diagnostic because the structure is different.
// REQUIRES: system-windows
// RUN: mkdir -p %t.dir
// RUN: touch %t.dir/foo.h
// RUN: not %clang_cl /FI \\?\%{t:real}.dir\FOO.h /WX -fsyntax-only %s 2>&1 | FileCheck %s
// CHECK: non-portable path to file '"\\?\