[PATCH] D103014: [lit] Attempt for fix tests failing because of 'warning: non-portable path to file'

Kristina Bessonova via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 4 07:21:47 PDT 2021


krisb updated this revision to Diff 349866.
krisb retitled this revision from "[lit] Make LLVM_LIT_PATH_FUNCTION to use pathlib" to "[lit] Attempt for fix tests failing because of 'warning: non-portable path to file'".
krisb edited the summary of this revision.
krisb added a comment.
Herald added a subscriber: delcypher.

Resolve `__file__` path first, avoid normcasing site config paths in discovery.py.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103014/new/

https://reviews.llvm.org/D103014

Files:
  llvm/cmake/modules/AddLLVM.cmake
  llvm/utils/lit/lit/discovery.py


Index: llvm/utils/lit/lit/discovery.py
===================================================================
--- llvm/utils/lit/lit/discovery.py
+++ llvm/utils/lit/lit/discovery.py
@@ -53,8 +53,7 @@
         config_map = litConfig.params.get('config_map')
         if config_map:
             cfgpath = os.path.realpath(cfgpath)
-            cfgpath = os.path.normcase(cfgpath)
-            target = config_map.get(cfgpath)
+            target = config_map.get(os.path.normcase(cfgpath))
             if target:
                 cfgpath = target
 
Index: llvm/cmake/modules/AddLLVM.cmake
===================================================================
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -1549,9 +1549,11 @@
 # use it and can't be in a lit module. Use with make_paths_relative().
 string(CONCAT LLVM_LIT_PATH_FUNCTION
   "# Allow generated file to be relocatable.\n"
+  "from pathlib import Path\n"
   "def path(p):\n"
   "    if not p: return ''\n"
-  "    return os.path.join(os.path.dirname(os.path.abspath(__file__)), p)\n"
+  "    abs = Path(__file__).resolve().parent / p\n"
+  "    return str(abs.resolve())\n"
   )
 
 # This function provides an automatic way to 'configure'-like generate a file


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103014.349866.patch
Type: text/x-patch
Size: 1247 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210604/c914d49a/attachment.bin>


More information about the llvm-commits mailing list