diff --git a/easybuild/main.py b/easybuild/main.py index 94ed2ea301..f15c648b73 100644 --- a/easybuild/main.py +++ b/easybuild/main.py @@ -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 @@ -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: @@ -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: diff --git a/test/framework/options.py b/test/framework/options.py index e4b878d4bb..731dc8c214 100644 --- a/test/framework/options.py +++ b/test/framework/options.py @@ -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')