make(1): move tests for :H :E :R :T into separate files

This commit is contained in:
rillig 2020-08-23 15:09:15 +00:00
parent c3c39b1bcc
commit 81e2228996
10 changed files with 54 additions and 29 deletions

View File

@ -8,10 +8,6 @@ path_/usr/xbin=/opt/xbin/
paths=/bin /tmp / /no/such/dir /opt/xbin
PATHS=/BIN /TMP / /NO/SUCH/DIR /OPT/XBIN
The answer is 42
dirname of 'a/b/c def a.b.c a.b/c a a.a .gitignore a a.a' is 'a/b . . a.b . . . . .'
basename of 'a/b/c def a.b.c a.b/c a a.a .gitignore a a.a' is 'c def a.b.c c a a.a .gitignore a a.a'
suffix of 'a/b/c def a.b.c a.b/c a a.a .gitignore a a.a' is 'c b/c a gitignore a'
root of 'a/b/c def a.b.c a.b/c a a.a .gitignore a a.a' is 'a/b/c def a.b a a a a a'
S:
C:
@:

View File

@ -1,4 +1,4 @@
# $Id: modmisc.mk,v 1.43 2020/08/16 12:48:55 rillig Exp $
# $Id: modmisc.mk,v 1.44 2020/08/23 15:09:15 rillig Exp $
#
# miscellaneous modifier tests
@ -15,7 +15,7 @@ MOD_HOMES=S,/home/,/homes/,
MOD_OPT=@d@$${exists($$d):?$$d:$${d:S,/usr,/opt,}}@
MOD_SEP=S,:, ,g
all: modvar modvarloop modsysv mod-HTE emptyvar undefvar
all: modvar modvarloop modsysv emptyvar undefvar
all: mod-tu-space
all: mod-quote
all: mod-break-many-words
@ -46,13 +46,6 @@ modvarloop:
@echo "paths=${paths}"
@echo "PATHS=${paths:tu}"
PATHNAMES= a/b/c def a.b.c a.b/c a a.a .gitignore a a.a
mod-HTE:
@echo "dirname of '"${PATHNAMES:Q}"' is '"${PATHNAMES:H:Q}"'"
@echo "basename of '"${PATHNAMES:Q}"' is '"${PATHNAMES:T:Q}"'"
@echo "suffix of '"${PATHNAMES:Q}"' is '"${PATHNAMES:E:Q}"'"
@echo "root of '"${PATHNAMES:Q}"' is '"${PATHNAMES:R:Q}"'"
# When a modifier is applied to the "" variable, the result is discarded.
emptyvar:
@echo S:${:S,^$,empty,}

View File

@ -1 +1,10 @@
extension of 'a/b/c' is ''
extension of 'def' is ''
extension of 'a.b.c' is 'c'
extension of 'a.b/c' is 'b/c'
extension of 'a' is ''
extension of 'a.a' is 'a'
extension of '.gitignore' is 'gitignore'
extension of 'a' is ''
extension of 'a.a' is 'a'
exit status 0

View File

@ -1,9 +1,9 @@
# $NetBSD: varmod-extension.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
# $NetBSD: varmod-extension.mk,v 1.3 2020/08/23 15:09:15 rillig Exp $
#
# Tests for the :E variable modifier, which returns the filename extension
# of each word in the variable.
# TODO: Implementation
all:
@:;
.for path in a/b/c def a.b.c a.b/c a a.a .gitignore a a.a
@echo "extension of '"${path:Q}"' is '"${path:E:Q}"'"
.endfor

View File

@ -1 +1,10 @@
head (dirname) of 'a/b/c' is 'a/b'
head (dirname) of 'def' is '.'
head (dirname) of 'a.b.c' is '.'
head (dirname) of 'a.b/c' is 'a.b'
head (dirname) of 'a' is '.'
head (dirname) of 'a.a' is '.'
head (dirname) of '.gitignore' is '.'
head (dirname) of 'a' is '.'
head (dirname) of 'a.a' is '.'
exit status 0

View File

@ -1,9 +1,9 @@
# $NetBSD: varmod-head.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
# $NetBSD: varmod-head.mk,v 1.3 2020/08/23 15:09:15 rillig Exp $
#
# Tests for the :H variable modifier, which returns the dirname of
# each of the words in the variable value.
# TODO: Implementation
all:
@:;
.for path in a/b/c def a.b.c a.b/c a a.a .gitignore a a.a
@echo "head (dirname) of '"${path:Q}"' is '"${path:H:Q}"'"
.endfor

View File

@ -1 +1,10 @@
root of 'a/b/c' is 'a/b/c'
root of 'def' is 'def'
root of 'a.b.c' is 'a.b'
root of 'a.b/c' is 'a'
root of 'a' is 'a'
root of 'a.a' is 'a'
root of '.gitignore' is ''
root of 'a' is 'a'
root of 'a.a' is 'a'
exit status 0

View File

@ -1,9 +1,9 @@
# $NetBSD: varmod-root.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
# $NetBSD: varmod-root.mk,v 1.3 2020/08/23 15:09:15 rillig Exp $
#
# Tests for the :R variable modifier, which returns the filename root
# without the extension.
# TODO: Implementation
all:
@:;
.for path in a/b/c def a.b.c a.b/c a a.a .gitignore a a.a
@echo "root of '"${path:Q}"' is '"${path:R:Q}"'"
.endfor

View File

@ -1 +1,10 @@
tail (basename) of 'a/b/c' is 'c'
tail (basename) of 'def' is 'def'
tail (basename) of 'a.b.c' is 'a.b.c'
tail (basename) of 'a.b/c' is 'c'
tail (basename) of 'a' is 'a'
tail (basename) of 'a.a' is 'a.a'
tail (basename) of '.gitignore' is '.gitignore'
tail (basename) of 'a' is 'a'
tail (basename) of 'a.a' is 'a.a'
exit status 0

View File

@ -1,9 +1,9 @@
# $NetBSD: varmod-tail.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
# $NetBSD: varmod-tail.mk,v 1.3 2020/08/23 15:09:15 rillig Exp $
#
# Tests for the :T variable modifier, which returns the basename of each of
# the words in the variable value.
# TODO: Implementation
all:
@:;
.for path in a/b/c def a.b.c a.b/c a a.a .gitignore a a.a
@echo "tail (basename) of '"${path:Q}"' is '"${path:T:Q}"'"
.endfor