This is an attempt to fix clang test failures due to 'nonportable-include-path'
warnings on Windows when a path to llvm-project's base directory contains some
uppercase letters.
For example, for 'clang/test/PCH/enum.c' test running from 'J:\MyDir\llvm-project'
lit generates the following command for the first RUN line:
"j:\mydir\build\bin\clang.exe" "-cc1" "-internal-isystem" "j:\mydir\build\lib\clang\1.12.0\include" "-nostdsysteminc" "-include" "j:\mydir\llvm-project\clang\test\PCH/enum.h" "-fsyntax-only" "j:\mydir\llvm-project\clang\test\PCH\enum.c"
which produces the following warning causing the test to fail:
<built-in>:1:10: warning: non-portable path to file '"J:\MyDir\llvm-project\clang\test\PCH/enum.h"'; specified path differs in case from file name on disk [-Wnonportable-include-path] #include "j:\mydir\llvm-project\clang\test\PCH/enum.h" ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "J:\MyDir\llvm-project\clang\test\PCH/enum.h" 1 warning generated.
The problem caused by two issues:
- discovery.py loads site config in lower case causing all the paths
based on file and requested within the config file to be in lowercase as well,
- neither os.path.abspath() nor os.path.realpath() (both used to obtain paths of
config files, sources, object directories, etc) do not return paths in correct
case for Windows (at least consistently for all python versions).
As os.path library doesn't seem to provide any relaible way to restore
case for paths on Windows, this patch proposes to use pathlib.resolve().
pathlib is a part of Python 3.4 [0] while llvm lit requires Python 3.6 [1].
Note: I noticed the same problem reported in D78169, but the suggestion
to use Python 3.8. doesn't seem working (at least for my setup).
[0] https://docs.python.org/3/library/pathlib.html
[1] https://llvm.org/docs/GettingStarted.html