From d56e9c1d4c3e6f560382ac71fa2419b2a9bef1cb Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Sun, 7 Jun 2015 16:57:46 +0200 Subject: Do not require $srctree to be set for non-kernel projects. (It was never required if you explicitly passed a 'base_dir', but it's a bit silly to have to do that too.) This is a bug. I expected os.path.expandvars() to replace references non-set environment variables with nothing, but it leaves them as is. Work around it by letting base_dir = None be special and the default. It uses $srctree if set and the current directory otherwise. This has the following advantages: - It avoids having to reimplement a different version of os.path.expandvars() and special-casing "" to mean the current directory. - It means '$' can appear in paths. (Though it probably never will.) Maybe the expansion behavior could be removed too, but keep it for now to be backwards compatible. --- testsuite.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'testsuite.py') diff --git a/testsuite.py b/testsuite.py index 3407e0a..3a2ee0b 100644 --- a/testsuite.py +++ b/testsuite.py @@ -1234,6 +1234,15 @@ def run_selftests(): verify_value("UNAME_RELEASE", os.uname()[2]) + # Expansion of environment variables in Config.__init__'s base_dir + # parameter. Just make sure we don't crash when Kbase_dir 'source's a file + # from the same directory. + + os.environ["EnV_VaR1"] = "Kconfigl" + os.environ["EnV_VaR2"] = "ib/tests" + kconfiglib.Config("Kconfiglib/tests/Kbase_dir", + base_dir = "$EnV_VaR1$EnV_VaR2/") + # # .config reading and writing # -- cgit v1.2.3