aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2022-04-11 21:05:20 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2022-04-13 21:27:22 +0300
commit2fcd3a417489ca456b57f87c9921f68d5872bb3a (patch)
treeae63b85dbde55a63a42cee6bd7162b0d2c43c3c0
parenta0e7f934148e35ce309ce998028e21f6df66e5cf (diff)
downloadmeson-2fcd3a417489ca456b57f87c9921f68d5872bb3a.zip
meson-2fcd3a417489ca456b57f87c9921f68d5872bb3a.tar.gz
meson-2fcd3a417489ca456b57f87c9921f68d5872bb3a.tar.bz2
Add regression test for Python dist.
-rw-r--r--unittests/allplatformstests.py10
-rw-r--r--unittests/pythontests.py17
2 files changed, 22 insertions, 5 deletions
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)