From 2fcd3a417489ca456b57f87c9921f68d5872bb3a Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Mon, 11 Apr 2022 21:05:20 +0300 Subject: Add regression test for Python dist. --- unittests/allplatformstests.py | 10 +++++----- unittests/pythontests.py | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 5 deletions(-) (limited to 'unittests') diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py index 67c50e7..c3e78bf 100644 --- a/unittests/allplatformstests.py +++ b/unittests/allplatformstests.py @@ -83,7 +83,7 @@ def temp_filename(): except OSError: pass -def _git_init(project_dir): +def git_init(project_dir): # If a user has git configuration init.defaultBranch set we want to override that with tempfile.TemporaryDirectory() as d: out = git(['--version'], str(d))[1] @@ -1165,7 +1165,7 @@ class AllPlatformTests(BasePlatformTests): raise SkipTest('Dist is only supported with Ninja') try: - self.dist_impl(_git_init, _git_add_all) + self.dist_impl(git_init, _git_add_all) except PermissionError: # When run under Windows CI, something (virus scanner?) # holds on to the git files so cleaning up the dir @@ -1220,7 +1220,7 @@ class AllPlatformTests(BasePlatformTests): project_dir = os.path.join(tmpdir, 'a') shutil.copytree(os.path.join(self.unit_test_dir, '35 dist script'), project_dir) - _git_init(project_dir) + git_init(project_dir) self.init(project_dir) self.build('dist') @@ -2603,7 +2603,7 @@ class AllPlatformTests(BasePlatformTests): # Ensure that test project is in git even when running meson from tarball. srcdir = os.path.join(self.builddir, 'src') shutil.copytree(testdir, srcdir) - _git_init(srcdir) + git_init(srcdir) testdir = srcdir self.new_builddir() @@ -3602,7 +3602,7 @@ class AllPlatformTests(BasePlatformTests): shutil.copytree(os.path.join(self.unit_test_dir, '80 wrap-git'), srcdir) upstream = os.path.join(srcdir, 'subprojects', 'wrap_git_upstream') upstream_uri = Path(upstream).as_uri() - _git_init(upstream) + git_init(upstream) with open(os.path.join(srcdir, 'subprojects', 'wrap_git.wrap'), 'w', encoding='utf-8') as f: f.write(textwrap.dedent(''' [wrap-git] diff --git a/unittests/pythontests.py b/unittests/pythontests.py index 27716d7..d49107f 100644 --- a/unittests/pythontests.py +++ b/unittests/pythontests.py @@ -14,12 +14,17 @@ import os import unittest +import pathlib +import subprocess from run_tests import ( Backend ) +from .allplatformstests import git_init + from .baseplatformtests import BasePlatformTests +from mesonbuild.mesonlib import TemporaryDirectoryWinProof class PythonTests(BasePlatformTests): ''' @@ -43,3 +48,15 @@ class PythonTests(BasePlatformTests): with self.assertRaises(unittest.SkipTest): self.init(testdir, extra_args=['-Dpython=dir']) self.wipe() + + def test_dist(self): + with TemporaryDirectoryWinProof() as dirstr: + dirobj = pathlib.Path(dirstr) + mesonfile = dirobj / 'meson.build' + mesonfile.write_text('''project('test', 'c', version: '1') +pymod = import('python') +python = pymod.find_installation('python3', required: true) +''', encoding='utf-8') + git_init(dirstr) + self.init(dirstr) + subprocess.check_call(self.meson_command + ['dist', '-C', self.builddir], stdout=subprocess.DEVNULL) -- cgit v1.1