diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2022-09-13 09:38:19 -0400 |
---|---|---|
committer | Eli Schwartz <eschwartz93@gmail.com> | 2022-09-28 19:36:13 -0400 |
commit | 2dfd952eb99590878430510644ffe99dd4a6a41d (patch) | |
tree | 53001a096d997511a8d12a44cf5019a2ff8d5a2b /unittests/allplatformstests.py | |
parent | a58ec322b3a9a07af83ea268341c16f972f52791 (diff) | |
download | meson-2dfd952eb99590878430510644ffe99dd4a6a41d.zip meson-2dfd952eb99590878430510644ffe99dd4a6a41d.tar.gz meson-2dfd952eb99590878430510644ffe99dd4a6a41d.tar.bz2 |
Move classes used by scripts to their own module
Those classes are used by wrapper scripts and we should not have to
import the rest of mesonlib, build.py, and all their dependencies for
that.
This renames mesonlib/ directory to utils/ and add a mesonlib.py module
that imports everything from utils/ to not have to change `import
mesonlib` everywhere. It allows to import utils.core without importing
the rest of mesonlib.
Diffstat (limited to 'unittests/allplatformstests.py')
-rw-r--r-- | unittests/allplatformstests.py | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py index 34997ce..7382f40 100644 --- a/unittests/allplatformstests.py +++ b/unittests/allplatformstests.py @@ -12,7 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -from mesonbuild.mesonlib.universal import windows_proof_rm import subprocess import re import json @@ -42,7 +41,8 @@ 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 + MesonException, EnvironmentException, OptionKey, ExecutableSerialisation, EnvironmentVariables, + windows_proof_rm ) from mesonbuild.compilers.mixins.clang import ClangCompiler @@ -4409,3 +4409,31 @@ class AllPlatformTests(BasePlatformTests): self.setconf(["-Dopt=val"]) newmtime = os.path.getmtime(filename) self.assertEqual(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 'meson' in m] + 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)) |