diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2020-09-29 22:24:56 -0400 |
---|---|---|
committer | Xavier Claessens <xavier.claessens@collabora.com> | 2020-10-13 17:55:16 -0400 |
commit | 3a0182378612bc764667328805b11bc92db696c2 (patch) | |
tree | f640f6c2c0499b2c657bfee85ddb52054ad3d79d /run_unittests.py | |
parent | 173c115834e37acf2a66fd00fa4010e5765c39a9 (diff) | |
download | meson-3a0182378612bc764667328805b11bc92db696c2.zip meson-3a0182378612bc764667328805b11bc92db696c2.tar.gz meson-3a0182378612bc764667328805b11bc92db696c2.tar.bz2 |
wrap: Add 'redirect' type and use it when auto promote
Diffstat (limited to 'run_unittests.py')
-rwxr-xr-x | run_unittests.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/run_unittests.py b/run_unittests.py index cfab11b..f6adcee 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -69,6 +69,8 @@ import mesonbuild.modules.pkgconfig from mesonbuild.mtest import TAPParser, TestResult +from mesonbuild.wrap.wrap import PackageDefinition, WrapException + from run_tests import ( Backend, FakeBuild, FakeCompilerOptions, ensure_backend_detects_changes, exe_suffix, get_backend_commands, @@ -5166,6 +5168,52 @@ recommended as it is not supported on some platforms''') out = self.init(testdir) self.assertNotRegex(out, r'WARNING') + def test_wrap_redirect(self): + redirect_wrap = os.path.join(self.builddir, 'redirect.wrap') + real_wrap = os.path.join(self.builddir, 'foo/subprojects/real.wrap') + os.makedirs(os.path.dirname(real_wrap)) + + # Invalid redirect, filename must have .wrap extension + with open(redirect_wrap, 'w') as f: + f.write(textwrap.dedent(''' + [wrap-redirect] + filename = foo/subprojects/real.wrapper + ''')) + with self.assertRaisesRegex(WrapException, 'wrap-redirect filename must be a .wrap file'): + PackageDefinition(redirect_wrap) + + # Invalid redirect, filename cannot be in parent directory + with open(redirect_wrap, 'w') as f: + f.write(textwrap.dedent(''' + [wrap-redirect] + filename = ../real.wrap + ''')) + with self.assertRaisesRegex(WrapException, 'wrap-redirect filename cannot contain ".."'): + PackageDefinition(redirect_wrap) + + # Invalid redirect, filename must be in foo/subprojects/real.wrap + with open(redirect_wrap, 'w') as f: + f.write(textwrap.dedent(''' + [wrap-redirect] + filename = foo/real.wrap + ''')) + with self.assertRaisesRegex(WrapException, 'wrap-redirect filename must be in the form foo/subprojects/bar.wrap'): + wrap = PackageDefinition(redirect_wrap) + + # Correct redirect + with open(redirect_wrap, 'w') as f: + f.write(textwrap.dedent(''' + [wrap-redirect] + filename = foo/subprojects/real.wrap + ''')) + with open(real_wrap, 'w') as f: + f.write(textwrap.dedent(''' + [wrap-git] + url = http://invalid + ''')) + wrap = PackageDefinition(redirect_wrap) + self.assertEqual(wrap.get('url'), 'http://invalid') + class FailureTests(BasePlatformTests): ''' Tests that test failure conditions. Build files here should be dynamically |