diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2019-11-17 03:41:12 +0100 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2019-11-17 05:32:59 +0100 |
| commit | de45874719772a40f1d8d244e2f5a6c6036415ac (patch) | |
| tree | adee2494dba26c340c81d3689e43db546221dcd3 /testsuite.py | |
| parent | faa1d2199801a19d7eef3caba8f0519a224ada2f (diff) | |
Make header strings customizable via the environment
If no header string is specified in write_(min_)config() or
write_autoconf(), use the values of the environment variables
KCONFIG_CONFIG_HEADER and KCONFIG_AUTOHEADER_HEADER, respectively, if
set. KCONFIG_AUTOHEADER_HEADER is consistent with KCONFIG_AUTOHEADER
(the header path), which will be added soon.
Using environment variables avoids having to add separate flags to each
tool that writes configuration files or headers.
Like for $prefix and $CONFIG_, store the values of the environment
variables when the Kconfig instance is created, and expose them via
Kconfig.config_header and Kconfig.header_header. This if flexible and
avoids gotchas when working with multiple Kconfig instances.
Also remove the old default header and make the default no header. Less
advertising, but it felt a bit silly to add workarounds to keep it.
Came up in https://github.com/ulfalizer/Kconfiglib/pull/80.
Diffstat (limited to 'testsuite.py')
| -rw-r--r-- | testsuite.py | 49 |
1 files changed, 43 insertions, 6 deletions
diff --git a/testsuite.py b/testsuite.py index 6fd8d83..fc61a16 100644 --- a/testsuite.py +++ b/testsuite.py @@ -1926,12 +1926,12 @@ tests/Krecursive2:1 c = Kconfig("Kconfiglib/tests/Kescape") # Test the default value - c.write_config(config_test_file + "_from_def", header="") + c.write_config(config_test_file + "_from_def") verify_file_contents(config_test_file + "_from_def", r'''CONFIG_STRING="\"\\"''' "\n") # Write our own value c.syms["STRING"].set_value(r'''\"a'\\''') - c.write_config(config_test_file + "_from_user", header="") + c.write_config(config_test_file + "_from_user") verify_file_contents(config_test_file + "_from_user", r'''CONFIG_STRING="\\\"a'\\\\"''' "\n") @@ -1977,7 +1977,7 @@ tests/Krecursive2:1 c = Kconfig("Kconfiglib/tests/Korder") - c.write_autoconf(config_test_file, header="") + c.write_autoconf(config_test_file) verify_file_contents(config_test_file, """ #define CONFIG_O 0 #define CONFIG_R 1 @@ -1996,7 +1996,7 @@ tests/Krecursive2:1 c.syms["R2"].set_value("-1") c.syms["N"].set_value("-1") c.syms["G"].set_value("-1") - c.write_min_config(config_test_file, header="") + c.write_min_config(config_test_file) verify_file_contents(config_test_file, """ CONFIG_O=-1 CONFIG_R=-1 @@ -2006,6 +2006,44 @@ CONFIG_N=-1 CONFIG_G=-1 """[1:]) + # Test header strings in configuration files and headers + + os.environ["KCONFIG_CONFIG_HEADER"] = "config header from env.\n" + os.environ["KCONFIG_AUTOHEADER_HEADER"] = "header header from env.\n" + + c = Kconfig("Kconfiglib/tests/Kheader") + c.write_config(config_test_file, header="config header from param\n") + verify_file_contents(config_test_file, """\ +config header from param +CONFIG_FOO=y +""") + c.write_min_config(config_test_file, header="min. config header from param\n") + verify_file_contents(config_test_file, """\ +min. config header from param +""") + c.write_config(config_test_file) + verify_file_contents(config_test_file, """\ +config header from env. +CONFIG_FOO=y +""") + c.write_min_config(config_test_file) + verify_file_contents(config_test_file, """\ +config header from env. +""") + c.write_autoconf(config_test_file, header="header header from param\n") + verify_file_contents(config_test_file, """\ +header header from param +#define CONFIG_FOO 1 +""") + c.write_autoconf(config_test_file) + verify_file_contents(config_test_file, """\ +header header from env. +#define CONFIG_FOO 1 +""") + + del os.environ["KCONFIG_CONFIG_HEADER"] + del os.environ["KCONFIG_AUTOHEADER_HEADER"] + print("Testing Kconfig fetching and separation") @@ -3148,8 +3186,7 @@ def equal_configs(): return False else: with f: - # [1:] strips the default header - our = f.readlines()[1:] + our = f.readlines() if their == our: return True |
