aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/wrap/wrap.py4
-rwxr-xr-xrun_unittests.py34
-rw-r--r--test cases/unit/73 wrap file url/meson.build4
-rw-r--r--test cases/unit/73 wrap file url/subprojects/foo-patch.tar.xzbin0 -> 228 bytes
-rw-r--r--test cases/unit/73 wrap file url/subprojects/foo.tar.xzbin0 -> 216 bytes
5 files changed, 39 insertions, 3 deletions
diff --git a/mesonbuild/wrap/wrap.py b/mesonbuild/wrap/wrap.py
index abbeb9e..0ebc2bc 100644
--- a/mesonbuild/wrap/wrap.py
+++ b/mesonbuild/wrap/wrap.py
@@ -335,9 +335,7 @@ class Resolver:
h = hashlib.sha256()
tmpfile = tempfile.NamedTemporaryFile(mode='wb', dir=self.cachedir, delete=False)
url = urllib.parse.urlparse(urlstring)
- if not url.hostname:
- raise WrapException('{} is not a valid URL'.format(urlstring))
- if url.hostname.endswith(whitelist_subdomain):
+ if url.hostname and url.hostname.endswith(whitelist_subdomain):
resp = open_wrapdburl(urlstring)
elif whitelist_subdomain in urlstring:
raise WrapException('{} may be a WrapDB-impersonating URL'.format(urlstring))
diff --git a/run_unittests.py b/run_unittests.py
index bd7266a..b2b2557 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -32,6 +32,7 @@ import threading
import urllib.error
import urllib.request
import zipfile
+import hashlib
from itertools import chain
from unittest import mock
from configparser import ConfigParser
@@ -5918,6 +5919,39 @@ c = ['{0}']
def test_ld_environment_variable_fortran(self):
self._check_ld('ld.gold', 'gold', 'fortran', 'GNU ld.gold')
+ def compute_sha256(self, filename):
+ with open(filename,"rb") as f:
+ return hashlib.sha256(f.read()).hexdigest();
+
+ def test_wrap_with_file_url(self):
+ testdir = os.path.join(self.unit_test_dir, '73 wrap file url')
+ source_filename = os.path.join(testdir, 'subprojects', 'foo.tar.xz')
+ patch_filename = os.path.join(testdir, 'subprojects', 'foo-patch.tar.xz')
+ wrap_filename = os.path.join(testdir, 'subprojects', 'foo.wrap')
+ source_hash = self.compute_sha256(source_filename)
+ patch_hash = self.compute_sha256(patch_filename)
+ wrap = textwrap.dedent("""\
+ [wrap-file]
+ directory = foo
+
+ source_url = file://{}
+ source_filename = foo.tar.xz
+ source_hash = {}
+
+ patch_url = file://{}
+ patch_filename = foo-patch.tar.xz
+ patch_hash = {}
+ """.format(source_filename, source_hash, patch_filename, patch_hash))
+ with open(wrap_filename, 'w') as f:
+ f.write(wrap)
+ self.init(testdir)
+ self.build()
+ self.run_tests()
+
+ windows_proof_rmtree(os.path.join(testdir, 'subprojects', 'packagecache'))
+ windows_proof_rmtree(os.path.join(testdir, 'subprojects', 'foo'))
+ os.unlink(wrap_filename)
+
def should_run_cross_arm_tests():
return shutil.which('arm-linux-gnueabihf-gcc') and not platform.machine().lower().startswith('arm')
diff --git a/test cases/unit/73 wrap file url/meson.build b/test cases/unit/73 wrap file url/meson.build
new file mode 100644
index 0000000..3bd3b25
--- /dev/null
+++ b/test cases/unit/73 wrap file url/meson.build
@@ -0,0 +1,4 @@
+project('test wrap with file url')
+
+exe = subproject('foo').get_variable('foo_exe')
+test('test1', exe)
diff --git a/test cases/unit/73 wrap file url/subprojects/foo-patch.tar.xz b/test cases/unit/73 wrap file url/subprojects/foo-patch.tar.xz
new file mode 100644
index 0000000..fdb026c
--- /dev/null
+++ b/test cases/unit/73 wrap file url/subprojects/foo-patch.tar.xz
Binary files differ
diff --git a/test cases/unit/73 wrap file url/subprojects/foo.tar.xz b/test cases/unit/73 wrap file url/subprojects/foo.tar.xz
new file mode 100644
index 0000000..2ed6ab4
--- /dev/null
+++ b/test cases/unit/73 wrap file url/subprojects/foo.tar.xz
Binary files differ