aboutsummaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2023-06-25 02:44:34 -0400
committerEli Schwartz <eschwartz@archlinux.org>2023-06-25 15:38:31 -0400
commit25f5f3554de6c80ace9ed211fa8c851505d95770 (patch)
tree08f394dfd0fbbfc001afd1803cb8b07a58998a99 /unittests
parentcd6c3ca55e6a3d6e4b40bac3aa3324c467285095 (diff)
downloadmeson-25f5f3554de6c80ace9ed211fa8c851505d95770.zip
meson-25f5f3554de6c80ace9ed211fa8c851505d95770.tar.gz
meson-25f5f3554de6c80ace9ed211fa8c851505d95770.tar.bz2
tests: move script loaded modules test to platform-agnostic
We have the same platform startup logic here for all platforms and I do not believe it's important to test this on the slow CI machines.
Diffstat (limited to 'unittests')
-rw-r--r--unittests/allplatformstests.py30
-rw-r--r--unittests/platformagnostictests.py31
2 files changed, 31 insertions, 30 deletions
diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py
index 6405360..360360c 100644
--- a/unittests/allplatformstests.py
+++ b/unittests/allplatformstests.py
@@ -41,7 +41,7 @@ from mesonbuild.mesonlib import (
BuildDirLock, MachineChoice, is_windows, is_osx, is_cygwin, is_dragonflybsd,
is_sunos, windows_proof_rmtree, python_command, version_compare, split_args, quote_arg,
relpath, is_linux, git, search_version, do_conf_file, do_conf_str, default_prefix,
- MesonException, EnvironmentException, OptionKey, ExecutableSerialisation, EnvironmentVariables,
+ MesonException, EnvironmentException, OptionKey,
windows_proof_rm
)
from mesonbuild.programs import ExternalProgram
@@ -4678,31 +4678,3 @@ class AllPlatformTests(BasePlatformTests):
self.assertNotEqual(olddata, newdata)
olddata = newdata
oldmtime = newmtime
-
- def test_scripts_loaded_modules(self):
- '''
- Simulate a wrapped command, as done for custom_target() that capture
- 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.
- '''
- es = ExecutableSerialisation(python_command + ['-c', 'exit(0)'], env=EnvironmentVariables())
- p = Path(self.builddir, 'exe.dat')
- with p.open('wb') as f:
- pickle.dump(es, f)
- cmd = self.meson_command + ['--internal', 'test_loaded_modules', '--unpickle', str(p)]
- p = subprocess.run(cmd, stdout=subprocess.PIPE)
- all_modules = json.loads(p.stdout.splitlines()[0])
- meson_modules = [m for m in all_modules if m.startswith('mesonbuild')]
- expected_meson_modules = [
- 'mesonbuild',
- 'mesonbuild._pathlib',
- 'mesonbuild.utils',
- 'mesonbuild.utils.core',
- 'mesonbuild.mesonmain',
- 'mesonbuild.mlog',
- 'mesonbuild.scripts',
- 'mesonbuild.scripts.meson_exe',
- 'mesonbuild.scripts.test_loaded_modules'
- ]
- self.assertEqual(sorted(expected_meson_modules), sorted(meson_modules))
diff --git a/unittests/platformagnostictests.py b/unittests/platformagnostictests.py
index 1dc8eb0..a3ff715 100644
--- a/unittests/platformagnostictests.py
+++ b/unittests/platformagnostictests.py
@@ -14,6 +14,7 @@
import json
import os
+import pickle
import tempfile
import subprocess
import textwrap
@@ -22,7 +23,7 @@ from pathlib import Path
from .baseplatformtests import BasePlatformTests
from .helpers import is_ci
-from mesonbuild.mesonlib import is_linux
+from mesonbuild.mesonlib import EnvironmentVariables, ExecutableSerialisation, is_linux, python_command
from mesonbuild.optinterpreter import OptionInterpreter, OptionException
from run_tests import Backend
@@ -198,3 +199,31 @@ class PlatformAgnosticTests(BasePlatformTests):
with self.assertRaises(subprocess.CalledProcessError) as cm:
self.init(testdir, extra_args=['--wipe'])
self.assertIn('Directory is not empty', cm.exception.stdout)
+
+ def test_scripts_loaded_modules(self):
+ '''
+ Simulate a wrapped command, as done for custom_target() that capture
+ 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.
+ '''
+ es = ExecutableSerialisation(python_command + ['-c', 'exit(0)'], env=EnvironmentVariables())
+ p = Path(self.builddir, 'exe.dat')
+ with p.open('wb') as f:
+ pickle.dump(es, f)
+ cmd = self.meson_command + ['--internal', 'test_loaded_modules', '--unpickle', str(p)]
+ p = subprocess.run(cmd, stdout=subprocess.PIPE)
+ all_modules = json.loads(p.stdout.splitlines()[0])
+ meson_modules = [m for m in all_modules if m.startswith('mesonbuild')]
+ expected_meson_modules = [
+ 'mesonbuild',
+ 'mesonbuild._pathlib',
+ 'mesonbuild.utils',
+ 'mesonbuild.utils.core',
+ 'mesonbuild.mesonmain',
+ 'mesonbuild.mlog',
+ 'mesonbuild.scripts',
+ 'mesonbuild.scripts.meson_exe',
+ 'mesonbuild.scripts.test_loaded_modules'
+ ]
+ self.assertEqual(sorted(expected_meson_modules), sorted(meson_modules))