mirror of
https://github.com/mesonbuild/meson.git
synced 2026-06-24 08:48:03 +00:00
Improve error messages for wrap-redirect file
While discussing error messages on IRC with xclaesse, we found 448b11cb7f which improves one of the error messages, but leaves out the others. This commit updates them, too.
This commit is contained in:
committed by
Paolo Bonzini
parent
dba79292df
commit
4146c44723
@@ -253,15 +253,15 @@ class PackageDefinition:
|
||||
for i, p in enumerate(fname.parts):
|
||||
if i % 2 == 0:
|
||||
if p == '..':
|
||||
raise WrapException('wrap-redirect filename cannot contain ".."')
|
||||
raise WrapException(f"wrap-redirect filename {values['filename']!r} cannot contain '..'")
|
||||
else:
|
||||
if p != 'subprojects':
|
||||
raise WrapException('wrap-redirect filename must be in the form foo/subprojects/bar.wrap')
|
||||
raise WrapException(f"wrap-redirect filename {values['filename']!r} must be in the form foo/subprojects/bar.wrap")
|
||||
if fname.suffix != '.wrap':
|
||||
raise WrapException('wrap-redirect filename must be a .wrap file')
|
||||
raise WrapException(f"wrap-redirect filename {values['filename']!r} must be a .wrap file")
|
||||
fname = Path(subprojects_dir, fname)
|
||||
if not fname.is_file():
|
||||
raise WrapException(f'wrap-redirect {fname} filename does not exist')
|
||||
raise WrapException(f"wrap-redirect filename {values['filename']!r} does not exist")
|
||||
wrap = PackageDefinition.from_wrap_file(str(fname), subproject)
|
||||
wrap.original_filename = filename
|
||||
wrap.redirected = True
|
||||
|
||||
@@ -4649,7 +4649,7 @@ class AllPlatformTests(BasePlatformTests):
|
||||
[wrap-redirect]
|
||||
filename = foo/subprojects/real.wrapper
|
||||
'''))
|
||||
with self.assertRaisesRegex(WrapException, 'wrap-redirect filename must be a .wrap file'):
|
||||
with self.assertRaisesRegex(WrapException, "wrap-redirect filename 'foo/subprojects/real.wrapper' must be a .wrap file"):
|
||||
PackageDefinition.from_wrap_file(redirect_wrap)
|
||||
|
||||
# Invalid redirect, filename cannot be in parent directory
|
||||
@@ -4658,7 +4658,7 @@ class AllPlatformTests(BasePlatformTests):
|
||||
[wrap-redirect]
|
||||
filename = ../real.wrap
|
||||
'''))
|
||||
with self.assertRaisesRegex(WrapException, 'wrap-redirect filename cannot contain ".."'):
|
||||
with self.assertRaisesRegex(WrapException, "wrap-redirect filename '../real.wrap' cannot contain '..'"):
|
||||
PackageDefinition.from_wrap_file(redirect_wrap)
|
||||
|
||||
# Invalid redirect, filename must be in foo/subprojects/real.wrap
|
||||
@@ -4667,7 +4667,7 @@ class AllPlatformTests(BasePlatformTests):
|
||||
[wrap-redirect]
|
||||
filename = foo/real.wrap
|
||||
'''))
|
||||
with self.assertRaisesRegex(WrapException, 'wrap-redirect filename must be in the form foo/subprojects/bar.wrap'):
|
||||
with self.assertRaisesRegex(WrapException, "wrap-redirect filename 'foo/real.wrap' must be in the form foo/subprojects/bar.wrap"):
|
||||
PackageDefinition.from_wrap_file(redirect_wrap)
|
||||
|
||||
# Correct redirect
|
||||
|
||||
Reference in New Issue
Block a user