From 0d4bd61d7836006db2d5d811a864228ffc18083d Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Wed, 18 Jan 2017 07:56:57 +0000 Subject: [PATCH] Re-add mechanism to override LIT options using enviroment variables. There was a dumb mistake in the original commit that has now been fixed git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@292351 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/libcxx/test/config.py | 44 +++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/test/libcxx/test/config.py b/test/libcxx/test/config.py index 7299dbead..1dd4338c7 100644 --- a/test/libcxx/test/config.py +++ b/test/libcxx/test/config.py @@ -85,20 +85,31 @@ class Configuration(object): val = default return val - def get_lit_bool(self, name, default=None): - conf = self.get_lit_conf(name) - if conf is None: - return default - if isinstance(conf, bool): - return conf - if not isinstance(conf, str): - raise TypeError('expected bool or string') - if conf.lower() in ('1', 'true'): - return True - if conf.lower() in ('', '0', 'false'): - return False - self.lit_config.fatal( - "parameter '{}' should be true or false".format(name)) + def get_lit_bool(self, name, default=None, env_var=None): + def check_value(value, var_name): + if value is None: + return default + if isinstance(value, bool): + return value + if not isinstance(value, str): + raise TypeError('expected bool or string') + if value.lower() in ('1', 'true'): + return True + if value.lower() in ('', '0', 'false'): + return False + self.lit_config.fatal( + "parameter '{}' should be true or false".format(var_name)) + + conf_val = self.get_lit_conf(name) + if env_var is not None and env_var in os.environ and \ + os.environ[env_var] is not None: + val = os.environ[env_var] + if conf_val is not None: + self.lit_config.warning( + 'Environment variable %s=%s is overriding explicit ' + '--param=%s=%s' % (env_var, val, name, conf_val)) + return check_value(val, env_var) + return check_value(conf_val, name) def make_static_lib_name(self, name): """Return the full filename for the specified library name""" @@ -845,10 +856,9 @@ class Configuration(object): if platform.system() != 'Darwin': modules_flags += ['-Xclang', '-fmodules-local-submodule-visibility'] supports_modules = self.cxx.hasCompileFlag(modules_flags) - enable_modules_default = supports_modules and \ - os.environ.get('LIBCXX_USE_MODULES') is not None enable_modules = self.get_lit_bool('enable_modules', - enable_modules_default) + default=False, + env_var='LIBCXX_ENABLE_MODULES') if enable_modules and not supports_modules: self.lit_config.fatal( '-fmodules is enabled but not supported by the compiler')