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

allow copying of tweaked easyconfigs when using --try-* with --copy-ec #3332

Merged
merged 11 commits into from
May 19, 2020
14 changes: 13 additions & 1 deletion easybuild/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@

from easybuild.framework.easyblock import build_and_install_one, inject_checksums
from easybuild.framework.easyconfig import EASYCONFIGS_PKG_SUBDIR
from easybuild.framework.easyconfig.easyconfig import clean_up_easyconfigs
from easybuild.framework.easyconfig.easyconfig import fix_deprecated_easyconfigs, verify_easyconfig_filename
from easybuild.framework.easyconfig.style import cmdline_easyconfigs_style_check
from easybuild.framework.easyconfig.tools import categorize_files_by_type, dep_graph
Expand Down Expand Up @@ -320,7 +321,7 @@ def main(args=None, logfile=None, do_build=None, testing=False, modtool=None):
# determine paths to easyconfigs
determined_paths = det_easyconfig_paths(categorized_paths['easyconfigs'])

if options.copy_ec or options.fix_deprecated_easyconfigs or options.show_ec:
if (options.copy_ec and not tweaked_ecs_paths) or options.fix_deprecated_easyconfigs or options.show_ec:

if options.copy_ec:
if len(determined_paths) == 1:
Expand Down Expand Up @@ -420,6 +421,17 @@ def main(args=None, logfile=None, do_build=None, testing=False, modtool=None):
print_msg("No easyconfigs left to be built.", log=_log, silent=testing)
ordered_ecs = []

if options.copy_ec and tweaked_ecs_paths:
all_specs = [spec['spec'] for spec in
resolve_dependencies(easyconfigs, modtool, retain_all_deps=True, raise_error_missing_ecs=False)]
tweaked_ecs_in_all_ecs = [path for path in all_specs if
any(tweaked_ecs_path in path for tweaked_ecs_path in tweaked_ecs_paths)]
if tweaked_ecs_in_all_ecs:
# Clean them, then copy them
clean_up_easyconfigs(tweaked_ecs_in_all_ecs)
copy_files(tweaked_ecs_in_all_ecs, target_path)
print_msg("%d file(s) copied to %s" % (len(tweaked_ecs_in_all_ecs), target_path), prefix=False)

# creating/updating PRs
if pr_options:
if options.new_pr:
Expand Down
45 changes: 45 additions & 0 deletions test/framework/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -1946,6 +1946,51 @@ def test_try(self):
allargs = args + ['--software-version=1.2.3', '--toolchain=gompi,2018a']
self.assertErrorRegex(EasyBuildError, "version .* not available", self.eb_main, allargs, raise_error=True)

def test_try_with_copy(self):
"""Test whether --try options are taken into account."""
ecs_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'easyconfigs', 'test_ecs')
tweaked_toy_ec = os.path.join(self.test_buildpath, 'toy-0.0-tweaked.eb')
copy_file(os.path.join(ecs_path, 't', 'toy', 'toy-0.0.eb'), tweaked_toy_ec)
f = open(tweaked_toy_ec, 'a')
f.write("easyblock = 'ConfigureMake'")
f.close()

args = [
tweaked_toy_ec,
'--sourcepath=%s' % self.test_sourcepath,
'--buildpath=%s' % self.test_buildpath,
'--installpath=%s' % self.test_installpath,
'--dry-run',
'--robot=%s' % ecs_path,
'--copy-ec',
]
self.mock_stdout(True)
self.mock_stderr(True)
copied_ec = os.path.join(self.test_buildpath, 'my_eb.eb')
self.eb_main(args + [copied_ec], verbose=True, raise_error=True)
outtxt = self.get_stdout()
errtxt = self.get_stderr()
self.assertTrue(r'toy-0.0-tweaked.eb copied to ' + copied_ec in outtxt)
self.assertFalse(errtxt)
self.mock_stdout(False)
self.mock_stderr(False)
self.assertTrue(os.path.exists(copied_ec))

self.mock_stdout(True)
self.mock_stderr(True)
tweaked_ecs_dir = os.path.join(self.test_buildpath, 'my_tweaked_ecs')
self.eb_main(args + ['--try-software=foo,1.2.3', '--try-toolchain=gompi,2018a', tweaked_ecs_dir],
verbose=True, raise_error=True)
outtxt = self.get_stdout()
errtxt = self.get_stderr()
self.assertTrue(r'1 file(s) copied to ' + tweaked_ecs_dir in outtxt)
self.assertFalse(errtxt)
self.mock_stdout(False)
self.mock_stderr(False)
self.assertTrue(
os.path.exists(os.path.join(self.test_buildpath, tweaked_ecs_dir, 'foo-1.2.3-GCC-6.4.0-2.28.eb'))
)

def test_software_version_ordering(self):
"""Test whether software versions are correctly ordered when using --software."""
ecs_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'easyconfigs', 'test_ecs')
Expand Down