Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions easybuild/tools/filetools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1535,9 +1535,8 @@ def create_patch_info(patch_spec):
def validate_patch_spec(patch_spec):
allowed_patch_exts = ['.patch' + x for x in ('',) + ZIPPED_PATCH_EXTS]
if not any(patch_spec.endswith(x) for x in allowed_patch_exts):
msg = "Use of patch file with filename that doesn't end with correct extension: %s " % patch_spec
msg += "(should be any of: %s)" % (', '.join(allowed_patch_exts))
_log.deprecated(msg, '5.0')
raise EasyBuildError("Wrong patch spec (%s), extension type should be any of %s." %
(patch_spec, ', '.join(allowed_patch_exts)))


def apply_patch(patch_file, dest, fn=None, copy=False, level=None, use_git_am=False, use_git=False):
Expand Down
16 changes: 3 additions & 13 deletions test/framework/filetools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1646,25 +1646,15 @@ def test_create_patch_info(self):
self.assertEqual(ft.create_patch_info({'name': 'foo.txt', 'copy': 'subdir', 'alt_location': 'alt'}),
{'name': 'foo.txt', 'copy': 'subdir', 'alt_location': 'alt'})

self.allow_deprecated_behaviour()
self.mock_stderr(True)
self.assertEqual(ft.create_patch_info('foo.txt'), {'name': 'foo.txt'})
stderr = self.get_stderr()
self.mock_stderr(False)
self.disallow_deprecated_behaviour()
expected_warning = "Use of patch file with filename that doesn't end with correct extension: foo.txt "
expected_warning += "(should be any of: .patch, .patch.bz2, .patch.gz, .patch.xz)"
fail_msg = "Warning '%s' should appear in stderr output: %s" % (expected_warning, stderr)
self.assertIn(expected_warning, stderr, fail_msg)

# deprecation warning is treated as an error in context of unit test suite
expected_error = expected_warning.replace('(', '\\(').replace(')', '\\)')
expected_error = r"Wrong patch spec \(foo.txt\), extension type should be any of .patch, .patch.bz2, "
expected_error += ".patch.gz, .patch.xz."
self.assertErrorRegex(EasyBuildError, expected_error, ft.create_patch_info, 'foo.txt')

# faulty input
error_msg = "Wrong patch spec"
self.assertErrorRegex(EasyBuildError, error_msg, ft.create_patch_info, None)
self.assertErrorRegex(EasyBuildError, error_msg, ft.create_patch_info, {'copy': 'subdir'})
self.assertErrorRegex(EasyBuildError, error_msg, ft.create_patch_info, {'name': 'foo.txt'})
self.assertErrorRegex(EasyBuildError, error_msg, ft.create_patch_info, {'name': 'foo.txt', 'random': 'key'})
self.assertErrorRegex(EasyBuildError, error_msg, ft.create_patch_info,
{'name': 'foo.txt', 'copy': 'subdir', 'sourcepath': 'subdir'})
Expand Down