diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2024-04-14 12:58:30 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2025-02-13 15:26:44 +0200 |
commit | 518c732ea9b0f1975f6f28accff3286be4106538 (patch) | |
tree | 2be9544828545a2f9f0676efc6eb82ac197ec4bd /unittests/linuxliketests.py | |
parent | ea678ed82938ceac00682b2695b57193d36b71b4 (diff) | |
download | meson-optionrefactor3.zip meson-optionrefactor3.tar.gz meson-optionrefactor3.tar.bz2 |
Make all Meson level options overridable per subproject.optionrefactor3
Diffstat (limited to 'unittests/linuxliketests.py')
-rw-r--r-- | unittests/linuxliketests.py | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/unittests/linuxliketests.py b/unittests/linuxliketests.py index a8608c2..2b56436 100644 --- a/unittests/linuxliketests.py +++ b/unittests/linuxliketests.py @@ -1867,3 +1867,56 @@ class LinuxlikeTests(BasePlatformTests): def test_top_options_in_sp(self): testdir = os.path.join(self.unit_test_dir, '124 pkgsubproj') self.init(testdir) + + def check_has_flag(self, compdb, src, argument): + for i in compdb: + if src in i['file']: + self.assertIn(argument, i['command']) + return + self.assertTrue(False, f'Source {src} not found in compdb') + + def test_persp_options(self): + testdir = os.path.join(self.unit_test_dir, '123 persp options') + self.init(testdir, extra_args='-Doptimization=1') + compdb = self.get_compdb() + mainsrc = 'toplevel.c' + sub1src = 'sub1.c' + sub2src = 'sub2.c' + self.check_has_flag(compdb, mainsrc, '-O1') + self.check_has_flag(compdb, sub1src, '-O1') + self.check_has_flag(compdb, sub2src, '-O1') + + # Set subproject option to O2 + self.setconf(['-Dround=2', '-D', 'sub2:optimization=3']) + compdb = self.get_compdb() + self.check_has_flag(compdb, mainsrc, '-O1') + self.check_has_flag(compdb, sub1src, '-O1') + self.check_has_flag(compdb, sub2src, '-O3') + + # Change an already set override. + self.setconf(['-Dround=3', '-D', 'sub2:optimization=2']) + compdb = self.get_compdb() + self.check_has_flag(compdb, mainsrc, '-O1') + self.check_has_flag(compdb, sub1src, '-O1') + self.check_has_flag(compdb, sub2src, '-O2') + + # Set top level option to O3 + self.setconf(['-Dround=4', '-D:optimization=3']) + compdb = self.get_compdb() + self.check_has_flag(compdb, mainsrc, '-O3') + self.check_has_flag(compdb, sub1src, '-O1') + self.check_has_flag(compdb, sub2src, '-O2') + + # Unset subproject + self.setconf(['-Dround=5', '-U', 'sub2:optimization']) + compdb = self.get_compdb() + self.check_has_flag(compdb, mainsrc, '-O3') + self.check_has_flag(compdb, sub1src, '-O1') + self.check_has_flag(compdb, sub2src, '-O1') + + # Set global value + self.setconf(['-Dround=6', '-D', 'optimization=2']) + compdb = self.get_compdb() + self.check_has_flag(compdb, mainsrc, '-O3') + self.check_has_flag(compdb, sub1src, '-O2') + self.check_has_flag(compdb, sub2src, '-O2') |