Skip to content

Commit 05be3d7

Browse files
committed
Don't append empty component to start_dir
In most cases `start_dir` is unset/empty. When passing it to `os.path.join` it leads to `/topdir/` which could case issues when using the template as `%(startdir)s/subdir` as a double-slash might be treated specially.
1 parent 825f842 commit 05be3d7

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

easybuild/framework/easyblock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2368,7 +2368,7 @@ def guess_start_dir(self):
23682368
# make sure start_dir subdir exists (cfr. check below)
23692369
mkdir(os.path.join(topdir, start_dir), parents=True)
23702370

2371-
abs_start_dir = os.path.join(topdir, start_dir)
2371+
abs_start_dir = os.path.join(topdir, start_dir) if start_dir else topdir
23722372
if topdir.endswith(start_dir) and not os.path.exists(abs_start_dir):
23732373
self.cfg['start_dir'] = topdir
23742374
else:

test/framework/easyblock.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2845,6 +2845,8 @@ def check_start_dir(expected_start_dir):
28452845
abs_expected_start_dir = os.path.join(eb.builddir, expected_start_dir)
28462846
self.assertTrue(os.path.samefile(eb.cfg['start_dir'], abs_expected_start_dir))
28472847
self.assertTrue(os.path.samefile(os.getcwd(), abs_expected_start_dir))
2848+
self.assertTrue(eb.cfg['start_dir'].endswith(abs_expected_start_dir))
2849+
self.assertFalse(eb.cfg['start_dir'].endswith(os.path.sep))
28482850

28492851
# default (no start_dir specified): use unpacked dir as start dir
28502852
self.assertEqual(ec['ec']['start_dir'], None)

0 commit comments

Comments
 (0)