diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2020-03-20 09:51:01 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2020-03-20 09:51:01 +0200 |
commit | da89d944bbc3cca9fd36a4a360f94023134a9a8c (patch) | |
tree | 1c31738b128b0628ff2e82817e43df9f9461beb0 /tests/directive | |
parent | ce29e3d72ded432b9ac9354ac92c588142de9b89 (diff) |
Initial implementation of config directive for project-specific configuration
Diffstat (limited to 'tests/directive')
-rw-r--r-- | tests/directive/config.testscript | 164 |
1 files changed, 164 insertions, 0 deletions
diff --git a/tests/directive/config.testscript b/tests/directive/config.testscript new file mode 100644 index 0000000..d10f45d --- /dev/null +++ b/tests/directive/config.testscript @@ -0,0 +1,164 @@ +# file : tests/directive/config.testscript +# license : MIT; see accompanying LICENSE file + +buildfile = true +test.arguments = + +: default-value +: +{ + .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 + + # Unconfigured. + # + $* noop >'false' ; + $* noop config.test.fancy=true >'true' ; + + # Configured as default. + # + $* configure >'false' ; + cat ../build/config.build >>~/EOO/ ; + /.* + config.test.fancy = false + /.* + EOO + $* disfigure ; + + # Configured as specified. + # + $* configure config.test.fancy=true >'true' ; + $* noop >'true' ; + $* noop config.test.fancy=false >'false' ; + $* configure config.test.fancy=false >'false' ; + $* noop >'false' ; + $* configure config.test.fancy=true >'true' ; + $* disfigure ; + $* noop >'false' ; + + $* noop config.test.fancy=[null] >'[null]'; + + $* noop config.test.fancy=junk 2>>EOE != 0 + error: invalid bool value 'junk' in variable config.test.fancy + EOE +} + +: default-null +: +{ + .include ../common.testscript + + +cat <<EOI >+build/bootstrap.build + using config + EOI + + +cat <<EOI >=build/root.build + config [bool] config.test.fancy ?= [null] + 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 + + # Unconfigured. + # + $* noop >'[null]'; + $* noop config.test.fancy=true >'true' ; + + # Configured as default. + # + $* configure >'[null]'; + cat ../build/config.build >>~/EOO/ ; + /.* + config.test.fancy = [null] + /.* + EOO + $* disfigure ; + + # Configured as specified. + # + $* configure config.test.fancy=true >'true' ; + $* noop >'true' ; + $* noop config.test.fancy=false >'false' ; + $* noop config.test.fancy=[null] >'[null]'; + $* configure config.test.fancy=false >'false' ; + $* noop >'false' ; + $* disfigure ; + $* noop >'[null]'; + + $* noop config.test.fancy=junk 2>>EOE != 0 + error: invalid bool value 'junk' in variable config.test.fancy + EOE +} + + +: default-none +: +{ + .include ../common.testscript + + +cat <<EOI >+build/bootstrap.build + using config + EOI + + +cat <<EOI >=build/root.build + config [bool] config.test.fancy + 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 + + # Unconfigured. + # + $* noop >'undefined' ; + $* noop config.test.fancy=true >'true' ; + + # Configured as default. + # + $* configure >'undefined' ; + sed -n -e 's/(config.test.fancy)/\1/p' ../build/config.build ; + $* disfigure ; + + # Configured as specified. + # + $* configure config.test.fancy=true >'true' ; + $* noop >'true' ; + $* noop config.test.fancy=false >'false' ; + $* configure config.test.fancy=false >'false' ; + $* noop >'false' ; + $* disfigure ; + $* noop >'undefined' ; + + $* noop config.test.fancy=[null] >'[null]'; + + $* noop config.test.fancy=junk 2>>EOE != 0 + error: invalid bool value 'junk' in variable config.test.fancy + EOE +} |