diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2018-05-13 10:36:58 -0400 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek.chauhan@gmail.com> | 2018-06-06 20:02:37 +0000 |
commit | 3f66846b0237bd8db73a5b4f3bdb56afa02754ea (patch) | |
tree | 9bc87549b162f87311464e17e72e3a25670625cf | |
parent | 7c4736d27f4c5d7844a44addc0305e4354440074 (diff) | |
download | meson-3f66846b0237bd8db73a5b4f3bdb56afa02754ea.zip meson-3f66846b0237bd8db73a5b4f3bdb56afa02754ea.tar.gz meson-3f66846b0237bd8db73a5b4f3bdb56afa02754ea.tar.bz2 |
Add unit test for option precedence
Closes #3456.
-rwxr-xr-x | run_unittests.py | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/run_unittests.py b/run_unittests.py index 313b07c..f17b69b 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -2155,6 +2155,33 @@ recommended as it can lead to undefined behaviour on some platforms''') self.assertEqual(obj.compiler_options['c_args'].value, ['foo bar', 'one', 'two']) self.wipe() + # Setting a 2nd time the same option should override the first value + try: + self.init(testdir, extra_args=['--bindir=foo', '--bindir=bar', + '-Dbuildtype=plain', '-Dbuildtype=release', + '-Db_sanitize=address', '-Db_sanitize=thread', + '-Dc_args=foo', '-Dc_args=bar']) + obj = mesonbuild.coredata.load(self.builddir) + self.assertEqual(obj.builtins['bindir'].value, 'bar') + self.assertEqual(obj.builtins['buildtype'].value, 'release') + self.assertEqual(obj.base_options['b_sanitize'].value, 'thread') + self.assertEqual(obj.compiler_options['c_args'].value, ['bar']) + self.setconf(['--bindir=bar', '--bindir=foo', + '-Dbuildtype=release', '-Dbuildtype=plain', + '-Db_sanitize=thread', '-Db_sanitize=address', + '-Dc_args=bar', '-Dc_args=foo']) + obj = mesonbuild.coredata.load(self.builddir) + self.assertEqual(obj.builtins['bindir'].value, 'foo') + self.assertEqual(obj.builtins['buildtype'].value, 'plain') + self.assertEqual(obj.base_options['b_sanitize'].value, 'address') + self.assertEqual(obj.compiler_options['c_args'].value, ['foo']) + self.wipe() + except KeyError: + # Ignore KeyError, it happens on CI for compilers that does not + # support b_sanitize. We have to test with a base option because + # they used to fail this test with Meson 0.46 an earlier versions. + pass + def test_compiler_options_documented(self): ''' Test that C and C++ compiler options and base options are documented in @@ -2176,7 +2203,6 @@ recommended as it can lead to undefined behaviour on some platforms''') self.assertIn(opt, md) self.assertNotIn('b_unknown', md) - class FailureTests(BasePlatformTests): ''' Tests that test failure conditions. Build files here should be dynamically |