Skip to content
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

Merged
merged 2 commits into from
Nov 20, 2020

Conversation

boegel
Copy link
Member

@boegel boegel commented Oct 25, 2020

fleshed out from #3482

@boegel boegel added this to the 4.x milestone Oct 25, 2020
@boegel boegel modified the milestones: 4.x, 4.3.2 Oct 25, 2020
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)
Copy link
Contributor

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

@@ -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!'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo, s/of/or/

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!")
Copy link
Contributor

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)

Copy link
Contributor

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')))
Copy link
Contributor

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

@boegel
Copy link
Member Author

boegel commented Nov 17, 2020

@akesandgren Please re-review, should be OK now.

Copy link
Contributor

@akesandgren akesandgren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@akesandgren
Copy link
Contributor

Going in, thanks @boegel!

@akesandgren akesandgren merged commit be5d589 into easybuilders:develop Nov 20, 2020
@boegel boegel deleted the enhance_copy_files branch November 20, 2020 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants