aboutsummaryrefslogtreecommitdiff
path: root/unittests/platformagnostictests.py
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2023-06-25 02:49:33 -0400
committerEli Schwartz <eschwartz@archlinux.org>2023-06-26 13:08:57 -0400
commit620bdf5895131f9e58da4c980a28dc96986d0b57 (patch)
tree084152f85bfb8558cb616f504b6aa97502a4837d /unittests/platformagnostictests.py
parent25f5f3554de6c80ace9ed211fa8c851505d95770 (diff)
downloadmeson-620bdf5895131f9e58da4c980a28dc96986d0b57.zip
meson-620bdf5895131f9e58da4c980a28dc96986d0b57.tar.gz
meson-620bdf5895131f9e58da4c980a28dc96986d0b57.tar.bz2
add profiling startup import check and testcase to count it
Diffstat (limited to 'unittests/platformagnostictests.py')
-rw-r--r--unittests/platformagnostictests.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/unittests/platformagnostictests.py b/unittests/platformagnostictests.py
index a3ff715..bbc34c9 100644
--- a/unittests/platformagnostictests.py
+++ b/unittests/platformagnostictests.py
@@ -206,6 +206,9 @@ class PlatformAgnosticTests(BasePlatformTests):
output. The script will print all python modules loaded and we verify
that it contains only an acceptable subset. Loading too many modules
slows down the build when many custom targets get wrapped.
+
+ This list must not be edited without a clear rationale for why it is
+ acceptable to do so!
'''
es = ExecutableSerialisation(python_command + ['-c', 'exit(0)'], env=EnvironmentVariables())
p = Path(self.builddir, 'exe.dat')
@@ -227,3 +230,27 @@ class PlatformAgnosticTests(BasePlatformTests):
'mesonbuild.scripts.test_loaded_modules'
]
self.assertEqual(sorted(expected_meson_modules), sorted(meson_modules))
+
+ def test_setup_loaded_modules(self):
+ '''
+ Execute a very basic meson.build and capture a list of all python
+ modules loaded. We verify that it contains only an acceptable subset.
+ Loading too many modules slows down `meson setup` startup time and
+ gives a perception that meson is slow.
+
+ Adding more modules to the default startup flow is not an unreasonable
+ thing to do as new features are added, but keeping track of them is
+ good.
+ '''
+ testdir = os.path.join(self.unit_test_dir, '113 empty project')
+
+ self.init(testdir)
+ self._run(self.meson_command + ['--internal', 'regenerate', '--profile-self', testdir, self.builddir])
+ with open(os.path.join(self.builddir, 'meson-logs', 'profile-startup-modules.json')) as f:
+ data = json.load(f)['meson']
+
+ with open(os.path.join(testdir, 'expected_mods.json')) as f:
+ expected = json.load(f)['meson']['modules']
+
+ self.assertEqual(data['modules'], expected)
+ self.assertEqual(data['count'], 98)