[PATCH] D111457: [test] Add lit helper for windows paths

Keith Smiley via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 28 16:05:33 PST 2022


keith updated this revision to Diff 411921.
keith marked 3 inline comments as done.
keith edited the summary of this revision.
keith added a comment.

Use the actual drive on windows, split out into fssrcroot and fstmproot


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111457

Files:
  llvm/docs/CommandGuide/lit.rst
  llvm/docs/TestingGuide.rst
  llvm/utils/lit/lit/TestRunner.py


Index: llvm/utils/lit/lit/TestRunner.py
===================================================================
--- llvm/utils/lit/lit/TestRunner.py
+++ llvm/utils/lit/lit/TestRunner.py
@@ -6,6 +6,7 @@
 import os, signal, subprocess, sys
 import re
 import stat
+import pathlib
 import platform
 import shutil
 import tempfile
@@ -1119,6 +1120,12 @@
                           ('%basename_t', baseName),
                           ('%T', tmpDir)])
 
+    substitutions.extend([
+        ('%{fssrcroot}', pathlib.Path(sourcedir).anchor),
+        ('%{fstmproot}', pathlib.Path(tmpBase).anchor),
+        ('%{fssep}', os.path.sep),
+    ])
+
     # "%/[STpst]" should be normalized.
     substitutions.extend([
             ('%/s', sourcepath.replace('\\', '/')),
Index: llvm/docs/TestingGuide.rst
===================================================================
--- llvm/docs/TestingGuide.rst
+++ llvm/docs/TestingGuide.rst
@@ -569,6 +569,18 @@
 
    Expands to the path separator, i.e. ``:`` (or ``;`` on Windows).
 
+``${fssrcroot}``
+   Expands to the root component of file system paths for the source directory,
+   i.e. ``/`` on Unix systems or ``C:\`` (or another drive) on Windows.
+
+``${fstmproot}``
+   Expands to the root component of file system paths for the test's temporary
+   directory, i.e. ``/`` on Unix systems or ``C:\`` (or another drive) on
+   Windows.
+
+``${fssep}``
+   Expands to the file system separator, i.e. ``/`` or ``\`` on Windows.
+
 ``%/s, %/S, %/t, %/T:``
 
   Act like the corresponding substitution above but replace any ``\``
Index: llvm/docs/CommandGuide/lit.rst
===================================================================
--- llvm/docs/CommandGuide/lit.rst
+++ llvm/docs/CommandGuide/lit.rst
@@ -523,6 +523,9 @@
  %S                      source dir (directory of the file currently being run)
  %p                      same as %S
  %{pathsep}              path separator
+ %{fssrcroot}            root component of file system paths pointing to the LLVM checkout
+ %{fstmproot}            root component of file system paths pointing to the test's temporary directory
+ %{fssep}                file system path separator
  %t                      temporary file name unique to the test
  %basename_t             The last path component of %t but without the ``.tmp`` extension
  %T                      parent directory of %t (not unique, deprecated, do not use)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111457.411921.patch
Type: text/x-patch
Size: 2413 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220301/64e0a0be/attachment.bin>


More information about the llvm-commits mailing list