-
Notifications
You must be signed in to change notification settings - Fork 204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
enhance copy_files: single file target, error on empty input list, verbose mode #3483
Conversation
easybuild/tools/filetools.py
Outdated
elif len(paths) == 1 and target_single_file: | ||
copy_file(paths[0], target_path) | ||
if verbose: | ||
print_msg("%s copied to %s" % (os.path.basename(paths[0]), target_path), prefix=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure that basename-ing is a good thing to do here. At least I usually want to know the full paths as often as possible...
test/framework/filetools.py
Outdated
@@ -1551,6 +1551,89 @@ def test_copy_files(self): | |||
error_pattern = "/toy-0.0.eb exists but is not a directory" | |||
self.assertErrorRegex(EasyBuildError, error_pattern, ft.copy_files, [bzip2_ec], copied_toy_ec) | |||
|
|||
# by default copy_files allows empty input list, but if allow_empty=False then an error is raised | |||
ft.copy_files([], self.test_prefix) | |||
error_pattern = 'One of more files to copy should be specified!' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo, s/of/or/
easybuild/tools/filetools.py
Outdated
print_msg("%d file(s) copied to %s" % (len(paths), target_path), prefix=False) | ||
|
||
elif not allow_empty: | ||
raise EasyBuildError("One of more files to copy should be specified!") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo, s/of/or/
self.assertEqual(toy_ec_txt, ft.read_file(target)) | ||
|
||
ft.remove_file(target) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add test for target_single_file into path with a missing directory in the path?
# check behaviour under -x: only printing, no actual copying | ||
init_config(build_options={'extended_dry_run': True}) | ||
self.assertFalse(os.path.exists(target)) | ||
self.assertFalse(os.path.exists(os.path.join(target, 'test.eb'))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this somewhat redundant, if target doesn't exist (as per the assertFalse above), then target/test.eb can't exist
@akesandgren Please re-review, should be OK now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Going in, thanks @boegel! |
fleshed out from #3482