Skip to content

Commit a5f5247

Browse files
committed
Enhance the skip-extension test to cover modulename: False
There shouldn't be a command executed for that.
1 parent 24e657c commit a5f5247

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

test/framework/easyblock.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,7 @@ def test_skip_extensions_step(self):
11901190
"ext1",
11911191
("EXT-2", "42", {"source_tmpl": "dummy.tgz"}),
11921192
("ext3", "1.1", {"source_tmpl": "dummy.tgz", "modulename": "real_ext"}),
1193-
"ext4",
1193+
("ext4", "0.2", {"source_tmpl": "dummy.tgz", "modulename": False}),
11941194
]
11951195
exts_filter = ("\
11961196
if [ %(ext_name)s == 'ext_2' ] && [ %(ext_version)s == '42' ] && [[ %(src)s == *dummy.tgz ]];\
@@ -1206,20 +1206,24 @@ def test_skip_extensions_step(self):
12061206
eb.installdir = config.install_path()
12071207
eb.skip = True
12081208

1209-
self.mock_stdout(True)
1210-
eb.extensions_step(fetch=True)
1211-
stdout = self.get_stdout()
1212-
self.mock_stdout(False)
1209+
with self.mocked_stdout_stderr():
1210+
eb.extensions_step(fetch=True)
1211+
stdout = self.get_stdout()
1212+
logtxt = read_file(eb.logfile)
1213+
self.assertRegex(logtxt, r"Running shell command\W+if \[ ext1")
1214+
self.assertRegex(logtxt, r"Running shell command\W+if \[ ext_2")
1215+
self.assertRegex(logtxt, r"Running shell command\W+if \[ real_ext")
1216+
# modulename: False skips the check
1217+
self.assertNotRegex(logtxt, r"Running shell command\W+if \[ (False|ext4)")
12131218

12141219
patterns = [
12151220
r"^== skipping extension EXT-2",
12161221
r"^== skipping extension ext3",
12171222
r"^== installing extension ext1 \(1/2\)\.\.\.",
1218-
r"^== installing extension ext4 \(2/2\)\.\.\.",
1223+
r"^== installing extension ext4 0.2 \(2/2\)\.\.\.",
12191224
]
12201225
for pattern in patterns:
1221-
regex = re.compile(pattern, re.M)
1222-
self.assertTrue(regex.search(stdout), "Pattern '%s' found in: %s" % (regex.pattern, stdout))
1226+
self.assertRegex(stdout, re.compile(pattern, re.M))
12231227

12241228
# 'ext1' should be in eb.ext_instances
12251229
eb_exts = [x.name for x in eb.ext_instances]

0 commit comments

Comments
 (0)