Skip to content

Commit 03155f2

Browse files
authored
Merge pull request #4247 from branfosj/patch
enforce correct extentions for patch files
2 parents b963350 + 01d0cea commit 03155f2

File tree

2 files changed

+5
-16
lines changed

2 files changed

+5
-16
lines changed

easybuild/tools/filetools.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,9 +1528,8 @@ def create_patch_info(patch_spec):
15281528
def validate_patch_spec(patch_spec):
15291529
allowed_patch_exts = ['.patch' + x for x in ('',) + ZIPPED_PATCH_EXTS]
15301530
if not any(patch_spec.endswith(x) for x in allowed_patch_exts):
1531-
msg = "Use of patch file with filename that doesn't end with correct extension: %s " % patch_spec
1532-
msg += "(should be any of: %s)" % (', '.join(allowed_patch_exts))
1533-
_log.deprecated(msg, '5.0')
1531+
raise EasyBuildError("Wrong patch spec (%s), extension type should be any of %s." %
1532+
(patch_spec, ', '.join(allowed_patch_exts)))
15341533

15351534

15361535
def apply_patch(patch_file, dest, fn=None, copy=False, level=None, use_git=False):

test/framework/filetools.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,25 +1646,15 @@ def test_create_patch_info(self):
16461646
self.assertEqual(ft.create_patch_info({'name': 'foo.txt', 'copy': 'subdir', 'alt_location': 'alt'}),
16471647
{'name': 'foo.txt', 'copy': 'subdir', 'alt_location': 'alt'})
16481648

1649-
self.allow_deprecated_behaviour()
1650-
self.mock_stderr(True)
1651-
self.assertEqual(ft.create_patch_info('foo.txt'), {'name': 'foo.txt'})
1652-
stderr = self.get_stderr()
1653-
self.mock_stderr(False)
1654-
self.disallow_deprecated_behaviour()
1655-
expected_warning = "Use of patch file with filename that doesn't end with correct extension: foo.txt "
1656-
expected_warning += "(should be any of: .patch, .patch.bz2, .patch.gz, .patch.xz)"
1657-
fail_msg = "Warning '%s' should appear in stderr output: %s" % (expected_warning, stderr)
1658-
self.assertIn(expected_warning, stderr, fail_msg)
1659-
1660-
# deprecation warning is treated as an error in context of unit test suite
1661-
expected_error = expected_warning.replace('(', '\\(').replace(')', '\\)')
1649+
expected_error = r"Wrong patch spec \(foo.txt\), extension type should be any of .patch, .patch.bz2, "
1650+
expected_error += ".patch.gz, .patch.xz."
16621651
self.assertErrorRegex(EasyBuildError, expected_error, ft.create_patch_info, 'foo.txt')
16631652

16641653
# faulty input
16651654
error_msg = "Wrong patch spec"
16661655
self.assertErrorRegex(EasyBuildError, error_msg, ft.create_patch_info, None)
16671656
self.assertErrorRegex(EasyBuildError, error_msg, ft.create_patch_info, {'copy': 'subdir'})
1657+
self.assertErrorRegex(EasyBuildError, error_msg, ft.create_patch_info, {'name': 'foo.txt'})
16681658
self.assertErrorRegex(EasyBuildError, error_msg, ft.create_patch_info, {'name': 'foo.txt', 'random': 'key'})
16691659
self.assertErrorRegex(EasyBuildError, error_msg, ft.create_patch_info,
16701660
{'name': 'foo.txt', 'copy': 'subdir', 'sourcepath': 'subdir'})

0 commit comments

Comments
 (0)