aboutsummaryrefslogtreecommitdiff
path: root/run_unittests.py
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2020-02-16 21:58:58 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2020-02-22 06:49:34 +0530
commitb0061257c93da955397da05fb0783801f67cd54d (patch)
tree4e71407cb23a8d32e3dc94ae6c711a29831b9b89 /run_unittests.py
parent225d842e4c5aa5159c4e706f071dba4a9fdb0958 (diff)
downloadmeson-b0061257c93da955397da05fb0783801f67cd54d.zip
meson-b0061257c93da955397da05fb0783801f67cd54d.tar.gz
meson-b0061257c93da955397da05fb0783801f67cd54d.tar.bz2
unit tests: Add a test for reconfigure causing no-op build
meson setup && ninja && touch meson.build && ninja should only reconfigure but not cause anything to be rebuilt.
Diffstat (limited to 'run_unittests.py')
-rwxr-xr-xrun_unittests.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/run_unittests.py b/run_unittests.py
index 7a22903..500b5eb 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -1701,6 +1701,29 @@ class BasePlatformTests(unittest.TestCase):
path_basename = PurePath(path).parts[-1]
self.assertEqual(PurePath(path_basename), PurePath(basename), msg)
+ def assertReconfiguredBuildIsNoop(self):
+ 'Assert that we reconfigured and then there was nothing to do'
+ ret = self.build()
+ self.assertIn('The Meson build system', ret)
+ if self.backend is Backend.ninja:
+ for line in ret.split('\n'):
+ if line in self.no_rebuild_stdout:
+ break
+ else:
+ raise AssertionError('build was reconfigured, but was not no-op')
+ elif self.backend is Backend.vs:
+ # Ensure that some target said that no rebuild was done
+ # XXX: Note CustomBuild did indeed rebuild, because of the regen checker!
+ self.assertIn('ClCompile:\n All outputs are up-to-date.', ret)
+ self.assertIn('Link:\n All outputs are up-to-date.', ret)
+ # Ensure that no targets were built
+ self.assertNotRegex(ret, re.compile('ClCompile:\n [^\n]*cl', flags=re.IGNORECASE))
+ self.assertNotRegex(ret, re.compile('Link:\n [^\n]*link', flags=re.IGNORECASE))
+ elif self.backend is Backend.xcode:
+ raise unittest.SkipTest('Please help us fix this test on the xcode backend')
+ else:
+ raise RuntimeError('Invalid backend: {!r}'.format(self.backend.name))
+
def assertBuildIsNoop(self):
ret = self.build()
if self.backend is Backend.ninja:
@@ -2536,6 +2559,20 @@ class AllPlatformTests(BasePlatformTests):
meson_exe_dat2 = glob(os.path.join(self.privatedir, 'meson_exe*.dat'))
self.assertListEqual(meson_exe_dat1, meson_exe_dat2)
+ def test_noop_changes_cause_no_rebuilds(self):
+ '''
+ Test that no-op changes to the build files such as mtime do not cause
+ a rebuild of anything.
+ '''
+ testdir = os.path.join(self.common_test_dir, '6 linkshared')
+ self.init(testdir)
+ self.build()
+ # Immediately rebuilding should not do anything
+ self.assertBuildIsNoop()
+ # Changing mtime of meson.build should not rebuild anything
+ self.utime(os.path.join(testdir, 'meson.build'))
+ self.assertReconfiguredBuildIsNoop()
+
def test_source_changes_cause_rebuild(self):
'''
Test that changes to sources and headers cause rebuilds, but not