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:
benjamin-otte
2021-04-16 18:18:46 +02:00
committed by Paolo Bonzini
parent dba79292df
commit 4146c44723
2 changed files with 7 additions and 7 deletions

View File

@@ -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

View File

@@ -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