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
20 changes: 9 additions & 11 deletions easybuild/tools/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -1092,22 +1092,20 @@ def _ensure_abs_path(self, opt_name):
def _postprocess_config(self):
"""Postprocessing of configuration options"""

# resolve relative paths for configuration options that specify a location;
# resolve relative paths for configuration options that specify a location,
# to avoid incorrect paths being used when EasyBuild changes the current working directory
# (see https://github.com/easybuilders/easybuild-framework/issues/3619);
# ensuring absolute paths for 'robot' is handled separately below,
# because we need to be careful with the argument pass to --robot
# because we need to be careful with the argument pass to --robot;
# note: repositorypath is purposely not listed here, because it's a special case:
# - the value could consist of a 2-tuple (<path>, <relative_subdir>);
# - the <path> could also specify the location of a *remote* (Git( repository,
# which can be done in variety of formats (git@<url>:<org>/<repo>), https://<url>, etc.)
# (see also https://github.com/easybuilders/easybuild-framework/issues/3892);
path_opt_names = ['buildpath', 'containerpath', 'git_working_dirs_path', 'installpath',
'installpath_modules', 'installpath_software', 'prefix', 'packagepath',
'robot_paths', 'sourcepath']

# repositorypath is a special case: only first part is a path;
# 2nd (optional) part is a relative subdir and should not be resolved to an absolute path!
repositorypath = self.options.repositorypath
if isinstance(repositorypath, (list, tuple)) and len(repositorypath) == 2:
abs_path = self.get_cfg_opt_abs_path('repositorypath', repositorypath[0])
self.options.repositorypath = (abs_path, repositorypath[1])
else:
path_opt_names.append('repositorypath')

for opt_name in path_opt_names:
self._ensure_abs_path(opt_name)

Expand Down
2 changes: 1 addition & 1 deletion test/framework/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def test_generaloption_config_file(self):
self.assertEqual(install_path('mod'), installpath_modules), # via config file
self.assertEqual(source_paths(), [testpath2]) # via command line
self.assertEqual(build_path(), testpath1) # via config file
self.assertEqual(get_repositorypath(), (os.path.join(topdir, 'ebfiles_repo'), 'somesubdir')) # via config file
self.assertEqual(get_repositorypath(), [os.path.join(topdir, 'ebfiles_repo'), 'somesubdir']) # via config file

# hardcoded first entry
self.assertEqual(options.robot_paths[0], '/tmp/foo')
Expand Down
4 changes: 2 additions & 2 deletions test/framework/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -6334,7 +6334,7 @@ def test_config_abs_path(self):
r"^containerpath\s+\(F\) = /.*/test_topdir/test_middle_dir$",
r"^installpath\s+\(E\) = /.*/test_topdir$",
r"^prefix\s+\(C\) = /.*/test_topdir/test_middle_dir$",
r"^repositorypath\s+\(F\) = \('/apps/easyconfigs_archive', ' somesubdir'\)$",
r"^repositorypath\s+\(F\) = /apps/easyconfigs_archive,\s+somesubdir$",
r"^sourcepath\s+\(C\) = /.*/test_topdir/test_middle_dir/test_subdir$",
r"^robot-paths\s+\(E\) = /.*/test_topdir$",
]
Expand Down Expand Up @@ -6377,7 +6377,7 @@ def test_config_repositorypath(self):
args[0] = '--repositorypath=%s,some/subdir' % repositorypath
txt, _ = self._run_mock_eb(args, do_build=True, raise_error=True, testing=False, strip=True)

regex = re.compile(r"repositorypath\s+\(C\) = \('%s', 'some/subdir'\)" % repositorypath, re.M)
regex = re.compile(r"repositorypath\s+\(C\) = %s, some/subdir" % repositorypath, re.M)
self.assertTrue(regex.search(txt), "Pattern '%s' should be found in: %s" % (regex.pattern, txt))

# end-to-end testing of unknown filename
Expand Down