Add regression test for Python dist.

pull/10280/head
Jussi Pakkanen 3 years ago
parent a0e7f93414
commit 2fcd3a4174
  1. 10
      unittests/allplatformstests.py
  2. 17
      unittests/pythontests.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]

@ -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)

Loading…
Cancel
Save