aboutsummaryrefslogtreecommitdiff
path: root/unittests/platformagnostictests.py
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2023-03-23 08:29:24 -0400
committerJussi Pakkanen <jpakkane@gmail.com>2023-03-28 00:36:37 +0300
commit567d1fec9b6f2191535509a5eae29436a024bd70 (patch)
tree3472142a33a8e9a1cd132ffbad5953524e966cc3 /unittests/platformagnostictests.py
parent03498424d0bacab75f19c335ffdaa4efd8d512ed (diff)
downloadmeson-567d1fec9b6f2191535509a5eae29436a024bd70.zip
meson-567d1fec9b6f2191535509a5eae29436a024bd70.tar.gz
meson-567d1fec9b6f2191535509a5eae29436a024bd70.tar.bz2
Make backend option read-only
Diffstat (limited to 'unittests/platformagnostictests.py')
-rw-r--r--unittests/platformagnostictests.py27
1 files changed, 26 insertions, 1 deletions
diff --git a/unittests/platformagnostictests.py b/unittests/platformagnostictests.py
index fce115d..18540b5 100644
--- a/unittests/platformagnostictests.py
+++ b/unittests/platformagnostictests.py
@@ -17,13 +17,14 @@ import os
import tempfile
import subprocess
import textwrap
-from unittest import skipIf
+from unittest import skipIf, SkipTest
from pathlib import Path
from .baseplatformtests import BasePlatformTests
from .helpers import is_ci
from mesonbuild.mesonlib import is_linux
from mesonbuild.optinterpreter import OptionInterpreter, OptionException
+from run_tests import Backend
@skipIf(is_ci() and not is_linux(), "Run only on fast platforms")
class PlatformAgnosticTests(BasePlatformTests):
@@ -138,3 +139,27 @@ class PlatformAgnosticTests(BasePlatformTests):
dat = json.load(f)
for i in dat['installed']:
self.assertPathExists(os.path.join(self.installdir, i['file']))
+
+ def test_change_backend(self):
+ if self.backend != Backend.ninja:
+ raise SkipTest('Only useful to test if backend is ninja.')
+
+ testdir = os.path.join(self.python_test_dir, '7 install path')
+ self.init(testdir)
+
+ # no-op change works
+ self.setconf(f'--backend=ninja')
+ self.init(testdir, extra_args=['--reconfigure', '--backend=ninja'])
+
+ # Change backend option is not allowed
+ with self.assertRaises(subprocess.CalledProcessError) as cm:
+ self.setconf('-Dbackend=none')
+ self.assertIn("ERROR: Tried modify read only option 'backend'", cm.exception.stdout)
+
+ # Reconfigure with a different backend is not allowed
+ with self.assertRaises(subprocess.CalledProcessError) as cm:
+ self.init(testdir, extra_args=['--reconfigure', '--backend=none'])
+ self.assertIn("ERROR: Tried modify read only option 'backend'", cm.exception.stdout)
+
+ # Wipe with a different backend is allowed
+ self.init(testdir, extra_args=['--wipe', '--backend=none'])