Skip to content

Commit 30713da

Browse files
committed
also check for correct stripping of extension by extract_cmd + better error message for extension stripping in test for back_up_file
1 parent d18100b commit 30713da

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

test/framework/filetools.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ def test_extract_cmd(self):
9797
('test.iso', "7z x test.iso"),
9898
('test.tar.Z', "tar xzf test.tar.Z"),
9999
('test.foo.bar.sh', "cp -a test.foo.bar.sh ."),
100+
# check whether extension is stripped correct to determine name of target file
101+
# cfr. https://github.com/easybuilders/easybuild-framework/pull/3705
102+
('testbz2.bz2', "bunzip2 -c testbz2.bz2 > testbz2"),
103+
('testgz.gz', "gunzip -c testgz.gz > testgz"),
100104
]
101105
for (fn, expected_cmd) in tests:
102106
cmd = ft.extract_cmd(fn)
@@ -935,7 +939,9 @@ def test_back_up_file(self):
935939
res = ft.back_up_file(fp2, strip_fn='.lua')
936940
self.assertFalse('.lua' in os.path.basename(res))
937941
# strip_fn should not remove the first a in 'a.lua'
938-
self.assertTrue(res.startswith(fp + 'a.bak_'))
942+
expected = os.path.basename(fp) + 'a.bak_'
943+
res_fn = os.path.basename(res)
944+
self.assertTrue(res_fn.startswith(expected), "'%s' should start with with '%s'" % (res_fn, expected))
939945

940946
def test_move_logs(self):
941947
"""Test move_logs function."""

0 commit comments

Comments
 (0)