Skip to content

Commit 042d57a

Browse files
authored
Merge pull request #20 from boegel/fix-obtain_files-for-patch-with-alt_location
always log a message in obtain_file to indicate whether or directory in which easyconfig file is located is being consider to locate file + enhance test_obtain_file
2 parents 522393a + dc7a61f commit 042d57a

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

easybuild/framework/easyblock.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -756,10 +756,12 @@ def obtain_file(self, filename, extension=False, urls=None, download_filename=No
756756
# always look first in the dir of the current eb file unless alt_location is set
757757
if alt_location is None:
758758
ebpath = [os.path.dirname(self.cfg.path)]
759+
self.log.info("Considering directory in which easyconfig file is located when searching for %s: %s",
760+
filename, ebpath[0])
759761
else:
760-
self.log.info("Directory of the easyconfig file ignored when searching for %s "
761-
"because alt_location is set to %s", filename, alt_location)
762762
ebpath = []
763+
self.log.info("Not considering directory in which easyconfig file is located when searching for %s "
764+
"because alt_location is set to %s", filename, alt_location)
763765

764766
# always consider robot + easyconfigs install paths as a fall back (e.g. for patch files, test cases, ...)
765767
common_filepaths = []

test/framework/easyblock.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1684,7 +1684,11 @@ def test_obtain_file(self):
16841684
mkdir(tmpdir_subdir, parents=True)
16851685
del os.environ['EASYBUILD_SOURCEPATH'] # defined by setUp
16861686

1687-
ec = process_easyconfig(os.path.join(testdir, 'easyconfigs', 'test_ecs', 't', 'toy', 'toy-0.0.eb'))[0]
1687+
toy_ec = os.path.join(testdir, 'easyconfigs', 'test_ecs', 't', 'toy', 'toy-0.0.eb')
1688+
test_ec = os.path.join(tmpdir, 'ecs', 'test.eb')
1689+
copy_file(toy_ec, test_ec)
1690+
1691+
ec = process_easyconfig(test_ec)[0]
16881692
eb = EasyBlock(ec['ec'])
16891693

16901694
# 'downloading' a file to (first) sourcepath works
@@ -1697,6 +1701,15 @@ def test_obtain_file(self):
16971701
res = eb.obtain_file(toy_tarball, urls=['file://%s' % tmpdir_subdir], alt_location='alt_toy')
16981702
self.assertEqual(res, os.path.join(tmpdir, 'a', 'alt_toy', toy_tarball))
16991703

1704+
# make sure that directory in which easyconfig file is located is *ignored* when alt_location is used
1705+
dummy_toy_tar_gz = os.path.join(os.path.dirname(test_ec), 'toy-0.0.tar.gz')
1706+
write_file(dummy_toy_tar_gz, '')
1707+
res = eb.obtain_file(toy_tarball, urls=['file://%s' % tmpdir_subdir])
1708+
self.assertEqual(res, dummy_toy_tar_gz)
1709+
res = eb.obtain_file(toy_tarball, urls=['file://%s' % tmpdir_subdir], alt_location='alt_toy')
1710+
self.assertEqual(res, os.path.join(tmpdir, 'a', 'alt_toy', toy_tarball))
1711+
remove_file(dummy_toy_tar_gz)
1712+
17001713
# finding a file in sourcepath works
17011714
init_config(args=["--sourcepath=%s:/no/such/dir:%s" % (sandbox_sources, tmpdir)])
17021715
res = eb.obtain_file(toy_tarball)

0 commit comments

Comments
 (0)