Skip to content

Commit 876f661

Browse files
authored
[LIT] Rename substitution %basename_s to %{s:basename} (#111062)
Also added `%{t:stem}` as an alias for `%basename_t` and modified unit test to test these new substitutions.
1 parent e1434a8 commit 876f661

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

llvm/docs/CommandGuide/lit.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -535,15 +535,16 @@ TestRunner.py:
535535
%{fs-tmp-root} root component of file system paths pointing to the test's temporary directory
536536
%{fs-sep} file system path separator
537537
%t temporary file name unique to the test
538-
%basename_s The last path component of %s
539-
%basename_t The last path component of %t but without the ``.tmp`` extension
538+
%basename_t The last path component of %t but without the ``.tmp`` extension (deprecated, use ``%{t:stem}`` instead)
540539
%T parent directory of %t (not unique, deprecated, do not use)
541540
%% %
542541
%/s %s but ``\`` is replaced by ``/``
543542
%/S %S but ``\`` is replaced by ``/``
544543
%/p %p but ``\`` is replaced by ``/``
545544
%/t %t but ``\`` is replaced by ``/``
546545
%/T %T but ``\`` is replaced by ``/``
546+
%{s:basename} The last path component of %s
547+
%{t:stem} The last path component of %t but without the ``.tmp`` extension (alias for %basename_t)
547548
%{s:real} %s after expanding all symbolic links and substitute drives
548549
%{S:real} %S after expanding all symbolic links and substitute drives
549550
%{p:real} %p after expanding all symbolic links and substitute drives

llvm/test/TableGen/anonymous-location.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: llvm-tblgen --print-detailed-records %s | FileCheck %s -DFILE=%basename_s
1+
// RUN: llvm-tblgen --print-detailed-records %s | FileCheck %s -DFILE=%{s:basename}
22

33
class A<int a> {
44
int Num = a;

llvm/utils/lit/lit/TestRunner.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1399,7 +1399,9 @@ def getDefaultSubstitutions(test, tmpDir, tmpBase, normalize_slashes=False):
13991399

14001400
substitutions.append(("%{pathsep}", os.pathsep))
14011401
substitutions.append(("%basename_t", tmpBaseName))
1402-
substitutions.append(("%basename_s", sourceBaseName))
1402+
1403+
substitutions.append(("%{s:basename}", sourceBaseName))
1404+
substitutions.append(("%{t:stem}", tmpBaseName))
14031405

14041406
substitutions.extend(
14051407
[

llvm/utils/lit/tests/substitutions.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Basic test for substitutions.
22
#
3-
# RUN: echo %basename_s | FileCheck %s
4-
#
5-
# CHECK: substitutions.py
3+
# RUN: echo %{s:basename} | FileCheck %s --check-prefix=BASENAME
4+
# RUN: echo %{t:stem} %basename_t | FileCheck %s --check-prefix=TMPBASENAME
5+
6+
# BASENAME: substitutions.py
7+
# TMPBASENAME: [[FIRST:[^[:space:]]+]] [[FIRST]]

0 commit comments

Comments
 (0)