|
|
|
@ -30,7 +30,7 @@ import functools |
|
|
|
|
import io |
|
|
|
|
import operator |
|
|
|
|
import threading |
|
|
|
|
import zipfile |
|
|
|
|
import zipfile, tarfile |
|
|
|
|
import hashlib |
|
|
|
|
from itertools import chain |
|
|
|
|
from unittest import mock |
|
|
|
@ -146,6 +146,9 @@ def _git_init(project_dir): |
|
|
|
|
'user.name', 'Author Person'], cwd=project_dir) |
|
|
|
|
subprocess.check_call(['git', 'config', |
|
|
|
|
'user.email', 'teh_coderz@example.com'], cwd=project_dir) |
|
|
|
|
_git_add_all(project_dir) |
|
|
|
|
|
|
|
|
|
def _git_add_all(project_dir): |
|
|
|
|
subprocess.check_call('git add *', cwd=project_dir, shell=True, |
|
|
|
|
stdout=subprocess.DEVNULL) |
|
|
|
|
subprocess.check_call(['git', 'commit', '-a', '-m', 'I am a project'], cwd=project_dir, |
|
|
|
@ -2846,7 +2849,7 @@ class AllPlatformTests(BasePlatformTests): |
|
|
|
|
raise unittest.SkipTest('Dist is only supported with Ninja') |
|
|
|
|
|
|
|
|
|
try: |
|
|
|
|
self.dist_impl(_git_init) |
|
|
|
|
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 |
|
|
|
@ -2915,10 +2918,10 @@ class AllPlatformTests(BasePlatformTests): |
|
|
|
|
path = os.path.join(project_dir, 'subprojects', name) |
|
|
|
|
os.makedirs(path) |
|
|
|
|
with open(os.path.join(path, 'meson.build'), 'w') as ofile: |
|
|
|
|
ofile.write("project('{}')".format(name)) |
|
|
|
|
ofile.write("project('{}', version: '1.0')".format(name)) |
|
|
|
|
return path |
|
|
|
|
|
|
|
|
|
def dist_impl(self, vcs_init, include_subprojects=True): |
|
|
|
|
def dist_impl(self, vcs_init, vcs_add_all=None, include_subprojects=True): |
|
|
|
|
# Create this on the fly because having rogue .git directories inside |
|
|
|
|
# the source tree leads to all kinds of trouble. |
|
|
|
|
with tempfile.TemporaryDirectory() as project_dir: |
|
|
|
@ -2929,6 +2932,7 @@ class AllPlatformTests(BasePlatformTests): |
|
|
|
|
test('dist test', e) |
|
|
|
|
subproject('vcssub', required : false) |
|
|
|
|
subproject('tarballsub', required : false) |
|
|
|
|
subproject('samerepo', required : false) |
|
|
|
|
''')) |
|
|
|
|
with open(os.path.join(project_dir, 'distexe.c'), 'w') as ofile: |
|
|
|
|
ofile.write(textwrap.dedent('''\ |
|
|
|
@ -2948,6 +2952,8 @@ class AllPlatformTests(BasePlatformTests): |
|
|
|
|
vcs_init(self.create_dummy_subproject(project_dir, 'vcssub')) |
|
|
|
|
self.create_dummy_subproject(project_dir, 'tarballsub') |
|
|
|
|
self.create_dummy_subproject(project_dir, 'unusedsub') |
|
|
|
|
if vcs_add_all: |
|
|
|
|
vcs_add_all(self.create_dummy_subproject(project_dir, 'samerepo')) |
|
|
|
|
self.init(project_dir) |
|
|
|
|
self.build('dist') |
|
|
|
|
self.assertPathExists(xz_distfile) |
|
|
|
@ -2960,24 +2966,46 @@ class AllPlatformTests(BasePlatformTests): |
|
|
|
|
self.assertPathExists(zip_checksumfile) |
|
|
|
|
|
|
|
|
|
if include_subprojects: |
|
|
|
|
# Verify that without --include-subprojects we have files from |
|
|
|
|
# the main project and also files from subprojects part of the |
|
|
|
|
# main vcs repository. |
|
|
|
|
z = zipfile.ZipFile(zip_distfile) |
|
|
|
|
self.assertEqual(sorted(['disttest-1.4.3/', |
|
|
|
|
'disttest-1.4.3/meson.build', |
|
|
|
|
'disttest-1.4.3/distexe.c']), |
|
|
|
|
expected = ['disttest-1.4.3/', |
|
|
|
|
'disttest-1.4.3/meson.build', |
|
|
|
|
'disttest-1.4.3/distexe.c'] |
|
|
|
|
if vcs_add_all: |
|
|
|
|
expected += ['disttest-1.4.3/subprojects/', |
|
|
|
|
'disttest-1.4.3/subprojects/samerepo/', |
|
|
|
|
'disttest-1.4.3/subprojects/samerepo/meson.build'] |
|
|
|
|
self.assertEqual(sorted(expected), |
|
|
|
|
sorted(z.namelist())) |
|
|
|
|
|
|
|
|
|
# Verify that with --include-subprojects we now also have files |
|
|
|
|
# from tarball and separate vcs subprojects. But not files from |
|
|
|
|
# unused subprojects. |
|
|
|
|
self._run(self.meson_command + ['dist', '--formats', 'zip', '--include-subprojects'], |
|
|
|
|
workdir=self.builddir) |
|
|
|
|
z = zipfile.ZipFile(zip_distfile) |
|
|
|
|
self.assertEqual(sorted(['disttest-1.4.3/', |
|
|
|
|
'disttest-1.4.3/subprojects/', |
|
|
|
|
'disttest-1.4.3/meson.build', |
|
|
|
|
'disttest-1.4.3/distexe.c', |
|
|
|
|
'disttest-1.4.3/subprojects/tarballsub/', |
|
|
|
|
'disttest-1.4.3/subprojects/vcssub/', |
|
|
|
|
'disttest-1.4.3/subprojects/tarballsub/meson.build', |
|
|
|
|
'disttest-1.4.3/subprojects/vcssub/meson.build']), |
|
|
|
|
expected += ['disttest-1.4.3/subprojects/tarballsub/', |
|
|
|
|
'disttest-1.4.3/subprojects/tarballsub/meson.build', |
|
|
|
|
'disttest-1.4.3/subprojects/vcssub/', |
|
|
|
|
'disttest-1.4.3/subprojects/vcssub/meson.build'] |
|
|
|
|
self.assertEqual(sorted(expected), |
|
|
|
|
sorted(z.namelist())) |
|
|
|
|
if vcs_add_all: |
|
|
|
|
# Verify we can distribute separately subprojects in the same vcs |
|
|
|
|
# repository as the main project. |
|
|
|
|
subproject_dir = os.path.join(project_dir, 'subprojects', 'samerepo') |
|
|
|
|
self.new_builddir() |
|
|
|
|
self.init(subproject_dir) |
|
|
|
|
self.build('dist') |
|
|
|
|
xz_distfile = os.path.join(self.distdir, 'samerepo-1.0.tar.xz') |
|
|
|
|
xz_checksumfile = xz_distfile + '.sha256sum' |
|
|
|
|
self.assertPathExists(xz_distfile) |
|
|
|
|
self.assertPathExists(xz_checksumfile) |
|
|
|
|
tar = tarfile.open(xz_distfile, "r:xz") |
|
|
|
|
self.assertEqual(sorted(['samerepo-1.0', |
|
|
|
|
'samerepo-1.0/meson.build']), |
|
|
|
|
sorted([i.name for i in tar])) |
|
|
|
|
|
|
|
|
|
def test_rpath_uses_ORIGIN(self): |
|
|
|
|
''' |
|
|
|
|