aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2022-03-23 09:10:50 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2022-03-23 09:10:50 +0200
commite6b40289f227428901e246149c25ffef18dd4491 (patch)
treee4951bb9e5ff40f63ad6f6bee0dd4a94f7dab755 /tests
parentc1c80c10a8d469b2659015429c7695f3dbd51ef2 (diff)
Make project configuration variables non-nullable by default
A project configuration variable with the NULL default value is naturally assumed nullable, for example: config [string] config.libhello.fallback_name ?= [null] Otherwise, to make a project configuration nullable we use the `null` variable attribute, for example: config [string, null] config.libhello.fallback_name ?= "World"
Diffstat (limited to 'tests')
-rw-r--r--tests/directive/config.testscript36
1 files changed, 33 insertions, 3 deletions
diff --git a/tests/directive/config.testscript b/tests/directive/config.testscript
index 4049fa0..fba858f 100644
--- a/tests/directive/config.testscript
+++ b/tests/directive/config.testscript
@@ -14,7 +14,7 @@ test.arguments =
EOI
+cat <<EOI >=build/root.build
- config [bool] config.test.fancy ?= false
+ config [bool, null] config.test.fancy ?= false
print ($defined(config.test.fancy) ? $config.test.fancy : undefined)
EOI
@@ -114,7 +114,6 @@ test.arguments =
EOE
}
-
: default-none
:
{
@@ -125,7 +124,7 @@ test.arguments =
EOI
+cat <<EOI >=build/root.build
- config [bool] config.test.fancy
+ config [bool, null] config.test.fancy
print ($defined(config.test.fancy) ? $config.test.fancy : undefined)
EOI
@@ -166,6 +165,37 @@ test.arguments =
EOE
}
+: non-nullable
+:
+{
+ .include ../common.testscript
+
+ +cat <<EOI >+build/bootstrap.build
+ using config
+ EOI
+
+ +cat <<EOI >=build/root.build
+ config [bool] config.test.fancy ?= false
+ print ($defined(config.test.fancy) ? $config.test.fancy : undefined)
+ EOI
+
+ # This must be a single, serial test since we are sharing config.build.
+ #
+ : test
+ :
+ cat <<EOI >=buildfile;
+ ./:
+ EOI
+
+ $* noop >'false' ;
+ $* noop config.test.fancy=false >'false' ;
+ $* noop config.test.fancy=true >'true' ;
+
+ $* noop config.test.fancy=[null] 2>>~/EOE/ != 0
+ /.+root.build:1:1: error: null value in non-nullable variable config\.test\.fancy/
+ EOE
+}
+
: report
:
{