diff options
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 34997ce8e..7382f400c 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)) |
