aboutsummaryrefslogtreecommitdiff
path: root/run_unittests.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2020-06-19 17:01:10 -0700
committerDylan Baker <dylan@pnwbakers.com>2020-08-01 22:00:06 -0700
commit591e6e94b9fccfc49ee7093cb21735a27fd64005 (patch)
tree2a1565a9d32ff9934bc43dfa4ab6c9ba29001f5c /run_unittests.py
parent5db3860abf6a27b0dd4653fa8c7143f4a70df7a7 (diff)
downloadmeson-591e6e94b9fccfc49ee7093cb21735a27fd64005.zip
meson-591e6e94b9fccfc49ee7093cb21735a27fd64005.tar.gz
meson-591e6e94b9fccfc49ee7093cb21735a27fd64005.tar.bz2
Put machine file and cmd line parsing in Environment
This creates a full set of option in environment that mirror those in coredata, this mirroring of the coredata structure is convenient because lookups int env (such as when initializing compilers) becomes a straight dict lookup, with no list iteration. It also means that all of the command line and machine files are read and stored in the correct order before they're ever accessed, simplifying the logic of using them.
Diffstat (limited to 'run_unittests.py')
-rwxr-xr-xrun_unittests.py61
1 files changed, 59 insertions, 2 deletions
diff --git a/run_unittests.py b/run_unittests.py
index 7bab408..21eabde 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -8030,7 +8030,7 @@ class NativeFileTests(BasePlatformTests):
for opt, value in [('testoption', 'some other val'), ('other_one', True),
('combo_opt', 'one'), ('array_opt', ['two']),
('integer_opt', 0)]:
- config = self.helper_create_native_file({'project options': {'sub:{}'.format(opt): value}})
+ config = self.helper_create_native_file({'sub:project options': {opt: value}})
with self.assertRaises(subprocess.CalledProcessError) as cm:
self.init(testcase, extra_args=['--native-file', config])
self.assertRegex(cm.exception.stdout, r'Incorrect value to [a-z]+ option')
@@ -8076,6 +8076,19 @@ class NativeFileTests(BasePlatformTests):
else:
self.fail('Did not find werror in build options?')
+ def test_builtin_options_env_overrides_conf(self):
+ testcase = os.path.join(self.common_test_dir, '2 cpp')
+ config = self.helper_create_native_file({'built-in options': {'pkg_config_path': '/foo'}})
+
+ self.init(testcase, extra_args=['--native-file', config], override_envvars={'PKG_CONFIG_PATH': '/bar'})
+ configuration = self.introspect('--buildoptions')
+ for each in configuration:
+ if each['name'] == 'pkg_config_path':
+ self.assertEqual(each['value'], ['/bar'])
+ break
+ else:
+ self.fail('Did not find pkg_config_path in build options?')
+
def test_builtin_options_subprojects(self):
testcase = os.path.join(self.common_test_dir, '102 subproject subdir')
config = self.helper_create_native_file({'built-in options': {'default_library': 'both', 'c_args': ['-Dfoo']}, 'sub:built-in options': {'default_library': 'static'}})
@@ -8185,6 +8198,22 @@ class NativeFileTests(BasePlatformTests):
else:
self.fail('Did not find bindir in build options?')
+ def test_builtin_options_paths_legacy(self):
+ testcase = os.path.join(self.common_test_dir, '1 trivial')
+ config = self.helper_create_native_file({
+ 'built-in options': {'default_library': 'static'},
+ 'paths': {'bindir': 'bar'},
+ })
+
+ self.init(testcase, extra_args=['--native-file', config])
+ configuration = self.introspect('--buildoptions')
+ for each in configuration:
+ if each['name'] == 'bindir':
+ self.assertEqual(each['value'], 'bar')
+ break
+ else:
+ self.fail('Did not find bindir in build options?')
+
class CrossFileTests(BasePlatformTests):
@@ -8431,7 +8460,15 @@ class CrossFileTests(BasePlatformTests):
cross = self.helper_create_cross_file({'built-in options': {'pkg_config_path': '/cross/path', 'cpp_std': 'c++17'}})
native = self.helper_create_cross_file({'built-in options': {'pkg_config_path': '/native/path', 'cpp_std': 'c++14'}})
- self.init(testcase, extra_args=['--cross-file', cross, '--native-file', native])
+ # Ensure that PKG_CONFIG_PATH is not set in the environment
+ with mock.patch.dict('os.environ'):
+ for k in ['PKG_CONFIG_PATH', 'PKG_CONFIG_PATH_FOR_BUILD']:
+ try:
+ del os.environ[k]
+ except KeyError:
+ pass
+ self.init(testcase, extra_args=['--cross-file', cross, '--native-file', native])
+
configuration = self.introspect('--buildoptions')
found = 0
for each in configuration:
@@ -8452,6 +8489,26 @@ class CrossFileTests(BasePlatformTests):
break
self.assertEqual(found, 4, 'Did not find all sections.')
+ def test_builtin_options_env_overrides_conf(self):
+ testcase = os.path.join(self.common_test_dir, '2 cpp')
+ config = self.helper_create_cross_file({'built-in options': {'pkg_config_path': '/foo'}})
+ cross = self.helper_create_cross_file({'built-in options': {'pkg_config_path': '/foo'}})
+
+ self.init(testcase, extra_args=['--native-file', config, '--cross-file', cross],
+ override_envvars={'PKG_CONFIG_PATH': '/bar', 'PKG_CONFIG_PATH_FOR_BUILD': '/dir'})
+ configuration = self.introspect('--buildoptions')
+ found = 0
+ for each in configuration:
+ if each['name'] == 'pkg_config_path':
+ self.assertEqual(each['value'], ['/bar'])
+ found += 1
+ elif each['name'] == 'build.pkg_config_path':
+ self.assertEqual(each['value'], ['/dir'])
+ found += 1
+ if found == 2:
+ break
+ self.assertEqual(found, 2, 'Did not find all sections.')
+
class TAPParserTests(unittest.TestCase):
def assert_test(self, events, **kwargs):