summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2018-03-13 03:24:41 +0100
committerUlf Magnusson <ulfalizer@gmail.com>2018-03-13 05:04:44 +0100
commitdaac69dc05217d024fbe021447629fa2b3d95b70 (patch)
treef2149a160786eeb2919ec1713903bf262a9e6ed0 /tests
parentaf2935913650dd0517666dcf8a0d4e68f8d62e34 (diff)
Add a globbing source statement
'gsource' works like 'source', but takes a glob pattern and sources all matching files. Works as a no-op if no files match, and hence doubles as an include-if-exists function, similar to '-include' in 'make'. Add a 'grsource' statement as well, mirroring 'rsource'. Came up in https://github.com/ulfalizer/Kconfiglib/pull/40.
Diffstat (limited to 'tests')
-rw-r--r--tests/Klocation20
-rw-r--r--tests/sub/Klocation_grsourced11
-rw-r--r--tests/sub/Klocation_grsourced21
-rw-r--r--tests/sub/Klocation_gsourced11
-rw-r--r--tests/sub/Klocation_gsourced21
5 files changed, 24 insertions, 0 deletions
diff --git a/tests/Klocation b/tests/Klocation
index aa176b2..99a8ee0 100644
--- a/tests/Klocation
+++ b/tests/Klocation
@@ -49,9 +49,29 @@ config _RSOURCED
string
default "_rsourced"
+config _GSOURCED
+ string
+ default "_gsourced"
+
+config _GRSOURCED
+ string
+ default "_grsourced"
+
# Expands to "tests/Klocation_sourced"
source "$TESTS_DIR_FROM_ENV/Klocation$_SOURCED"
+
# Expands to "sub/Klocation_rsourced"
rsource "$SUB_DIR_FROM_ENV/Klocation$_RSOURCED"
+# Expands to "tests/*ub/Klocation_gsourced[12]", matching
+# tests/sub/Klocation_gsourced{1,2}
+gsource "$TESTS_DIR_FROM_ENV/*ub/Klocation$_GSOURCED[12]"
+
+# Expands to "sub/Klocation_grsourced[12]", matching
+# tests/sub/Klocation_grsourced{1,2}
+grsource "$SUB_DIR_FROM_ENV/Klocation$_GRSOURCED[12]"
+
+# No-op
+gsource "nonexisting file"
+
config MULTI_DEF
diff --git a/tests/sub/Klocation_grsourced1 b/tests/sub/Klocation_grsourced1
new file mode 100644
index 0000000..49dac36
--- /dev/null
+++ b/tests/sub/Klocation_grsourced1
@@ -0,0 +1 @@
+config MULTI_DEF
diff --git a/tests/sub/Klocation_grsourced2 b/tests/sub/Klocation_grsourced2
new file mode 100644
index 0000000..49dac36
--- /dev/null
+++ b/tests/sub/Klocation_grsourced2
@@ -0,0 +1 @@
+config MULTI_DEF
diff --git a/tests/sub/Klocation_gsourced1 b/tests/sub/Klocation_gsourced1
new file mode 100644
index 0000000..49dac36
--- /dev/null
+++ b/tests/sub/Klocation_gsourced1
@@ -0,0 +1 @@
+config MULTI_DEF
diff --git a/tests/sub/Klocation_gsourced2 b/tests/sub/Klocation_gsourced2
new file mode 100644
index 0000000..49dac36
--- /dev/null
+++ b/tests/sub/Klocation_gsourced2
@@ -0,0 +1 @@
+config MULTI_DEF