aboutsummaryrefslogtreecommitdiff
path: root/unittests/allplatformstests.py
diff options
context:
space:
mode:
authorDaan De Meyer <daan.j.demeyer@gmail.com>2022-07-15 14:10:31 +0200
committerXavier Claessens <xclaesse@gmail.com>2023-03-16 17:18:30 -0400
commitadb619db6110d14e8f56366dbc2ce271abc4558c (patch)
tree6be4f4c5658b5d3b53713e9bace0ff82f418e044 /unittests/allplatformstests.py
parente0792f48197ff03dab4692e22bd2b13552c53823 (diff)
downloadmeson-adb619db6110d14e8f56366dbc2ce271abc4558c.zip
meson-adb619db6110d14e8f56366dbc2ce271abc4558c.tar.gz
meson-adb619db6110d14e8f56366dbc2ce271abc4558c.tar.bz2
Stop using replace_if_different() for coredata pickle file
This was added in f774609 to only change the access time of the coredata file if the coredata struct actually changed. However, this doesn't work as pickle serializations aren't guaranteed to be stable. Instead, let's manually check if options have changed values and skip the save if they haven't changed. We also extend the associated unit test to cover all the option types and to ensure that configure does get executed if one of the options changes value.
Diffstat (limited to 'unittests/allplatformstests.py')
-rw-r--r--unittests/allplatformstests.py37
1 files changed, 32 insertions, 5 deletions
diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py
index 6d48019..844f909 100644
--- a/unittests/allplatformstests.py
+++ b/unittests/allplatformstests.py
@@ -4584,13 +4584,40 @@ class AllPlatformTests(BasePlatformTests):
def test_configure_same_noop(self):
testdir = os.path.join(self.unit_test_dir, '108 configure same noop')
- self.init(testdir, extra_args=['-Dopt=val'])
+ args = [
+ '-Dstring=val',
+ '-Dboolean=true',
+ '-Dcombo=two',
+ '-Dinteger=7',
+ '-Darray=[\'three\']',
+ '-Dfeature=disabled',
+ '--buildtype=plain',
+ '--prefix=/abc',
+ ]
+ self.init(testdir, extra_args=args)
- filename = os.path.join(self.privatedir, 'coredata.dat')
+ filename = Path(self.privatedir) / 'coredata.dat'
+
+ olddata = filename.read_bytes()
oldmtime = os.path.getmtime(filename)
- self.setconf(["-Dopt=val"])
- newmtime = os.path.getmtime(filename)
- self.assertEqual(oldmtime, newmtime)
+
+ for opt in ('-Dstring=val', '--buildtype=plain', '-Dfeature=disabled'):
+ self.setconf([opt])
+ newdata = filename.read_bytes()
+ newmtime = os.path.getmtime(filename)
+ self.assertEqual(olddata, newdata)
+ self.assertEqual(oldmtime, newmtime)
+ olddata = newdata
+ oldmtime = newmtime
+
+ for opt in ('-Dstring=abc', '--buildtype=release', '-Dfeature=enabled'):
+ self.setconf([opt])
+ newdata = filename.read_bytes()
+ newmtime = os.path.getmtime(filename)
+ self.assertNotEqual(olddata, newdata)
+ self.assertGreater(newmtime, oldmtime)
+ olddata = newdata
+ oldmtime = newmtime
def test_scripts_loaded_modules(self):
'''