From da89d944bbc3cca9fd36a4a360f94023134a9a8c Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 20 Mar 2020 09:51:01 +0200 Subject: Initial implementation of config directive for project-specific configuration --- tests/directive/config.testscript | 164 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 tests/directive/config.testscript (limited to 'tests/directive/config.testscript') 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 <+build/bootstrap.build + using config + EOI + + +cat <=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 <=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 <+build/bootstrap.build + using config + EOI + + +cat <=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 <=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 <+build/bootstrap.build + using config + EOI + + +cat <=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 <=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 +} -- cgit v1.1