aboutsummaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorL. E. Segovia <amy@amyspark.me>2022-10-08 21:14:37 +0000
committerEli Schwartz <eschwartz93@gmail.com>2023-02-20 11:05:06 -0500
commit088727164de8496c4bada040c2f4690e42f66b69 (patch)
tree26baacb88fd6761363be89bf2b0aa0ea78bfe628 /unittests
parentc2b0ca0fb9d7e6850874ae7c1c755982676f593d (diff)
downloadmeson-088727164de8496c4bada040c2f4690e42f66b69.zip
meson-088727164de8496c4bada040c2f4690e42f66b69.tar.gz
meson-088727164de8496c4bada040c2f4690e42f66b69.tar.bz2
interpreter/mesonmain: Add build_options method
This method allows meson.build to introspect on the changed options. It works by merely exposing the same set of data that is logged by MesonApp._generate. Fixes #10898
Diffstat (limited to 'unittests')
-rw-r--r--unittests/allplatformstests.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py
index 64ac749..a38b839 100644
--- a/unittests/allplatformstests.py
+++ b/unittests/allplatformstests.py
@@ -1948,6 +1948,33 @@ class AllPlatformTests(BasePlatformTests):
self.assertEqual(item['value'], ['b', 'c'])
self.assertEqual(item['choices'], ['b', 'c', 'd'])
+ def test_options_listed_in_build_options(self) -> None:
+ """Detect when changed options become listed in build options."""
+ testdir = os.path.join(self.unit_test_dir, '110 list build options')
+
+ out = self.init(testdir)
+ for line in out.splitlines():
+ if line.startswith('Message: Build options:'):
+ self.assertNotIn('-Dauto_features=auto', line)
+ self.assertNotIn('-Doptional=auto', line)
+
+ self.wipe()
+ self.mac_ci_delay()
+
+ out = self.init(testdir, extra_args=['-Dauto_features=disabled', '-Doptional=enabled'])
+ for line in out.splitlines():
+ if line.startswith('Message: Build options:'):
+ self.assertIn('-Dauto_features=disabled', line)
+ self.assertIn('-Doptional=enabled', line)
+
+ self.setconf('-Doptional=disabled')
+ out = self.build()
+ for line in out.splitlines():
+ if line.startswith('Message: Build options:'):
+ self.assertIn('-Dauto_features=disabled', line)
+ self.assertNotIn('-Doptional=enabled', line)
+ self.assertIn('-Doptional=disabled', line)
+
def test_subproject_promotion(self):
testdir = os.path.join(self.unit_test_dir, '12 promote')
workdir = os.path.join(self.builddir, 'work')