Skip to content

Commit 0981458

Browse files
committed
enhance test_checksum_step to check lack of error message in log when checksums.json is not found
1 parent f140a32 commit 0981458

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/framework/easyblock.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
from unittest import TextTestRunner
4040

4141
import easybuild.tools.systemtools as st
42+
from easybuild.base import fancylogger
4243
from easybuild.framework.easyblock import EasyBlock, get_easyblock_instance
4344
from easybuild.framework.easyconfig import CUSTOM
4445
from easybuild.framework.easyconfig.easyconfig import EasyConfig
@@ -2424,6 +2425,30 @@ def test_checksum_step(self):
24242425
eb.fetch_sources()
24252426
eb.checksum_step()
24262427

2428+
with self.mocked_stdout_stderr() as (stdout, stderr):
2429+
2430+
# using checksum-less test easyconfig in location that does not provide checksums.json
2431+
test_ec = os.path.join(self.test_prefix, 'test-no-checksums.eb')
2432+
copy_file(toy_ec, test_ec)
2433+
write_file(test_ec, 'checksums = []', append=True)
2434+
ec = process_easyconfig(test_ec)[0]
2435+
2436+
# enable logging to screen, so we can check whether error is logged when checksums.json is not found
2437+
fancylogger.logToScreen(enable=True, stdout=True)
2438+
2439+
eb = get_easyblock_instance(ec)
2440+
eb.fetch_sources()
2441+
eb.checksum_step()
2442+
2443+
fancylogger.logToScreen(enable=False, stdout=True)
2444+
stdout = self.get_stdout()
2445+
2446+
# make sure there's no error logged for not finding checksums.json,
2447+
# see also https://github.com/easybuilders/easybuild-framework/issues/4301
2448+
regex = re.compile("ERROR .*Couldn't find file checksums.json anywhere", re.M)
2449+
regex.search(stdout)
2450+
self.assertFalse(regex.search(stdout), "Pattern '%s' should not be found in log" % regex.pattern)
2451+
24272452
# fiddle with checksum to check whether faulty checksum is catched
24282453
copy_file(toy_ec, self.test_prefix)
24292454
toy_ec = os.path.join(self.test_prefix, os.path.basename(toy_ec))

0 commit comments

Comments
 (0)