Skip to content

Commit d38174b

Browse files
committed
Enhance test for test_cases_step
1 parent aae1d7f commit d38174b

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

test/framework/easyblock.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,7 +1286,8 @@ def test_test_cases_step(self):
12861286
eb.cfg['tests'] = ['/abs/path/does-not-exist']
12871287
self.assertRaisesRegex(EasyBuildError, 'non-existing path: /abs/path/does-not-exist', eb.test_cases_step)
12881288

1289-
mock_test_bin = os.path.join(self.test_prefix, 'pi', 'test_me')
1289+
new_source_path = os.path.join(tempfile.mkdtemp(), 'sources')
1290+
mock_test_bin = os.path.join(new_source_path, 'pi', 'test_me')
12901291
os.environ['PATH'] += f':{os.path.dirname(mock_test_bin)}'
12911292
write_file(mock_test_bin, "#!/bin/bash\necho 'Test case success'")
12921293

@@ -1295,10 +1296,12 @@ def test_test_cases_step(self):
12951296
fn = os.path.basename(mock_test_bin)
12961297
self.assertRaisesRegex(EasyBuildError, f'non-existing path: {fn}', eb.test_cases_step)
12971298

1298-
init_config(args=[f"--sourcepath={self.test_prefix}"])
1299+
init_config(args=[f"--sourcepath={new_source_path}", "--debug"])
12991300
write_file(eb.logfile, '')
13001301
eb.test_cases_step()
1301-
self.assertIn('Test case success', read_file(eb.logfile))
1302+
logtxt = read_file(eb.logfile)
1303+
self.assertIn(f'Running test {mock_test_bin}', logtxt)
1304+
self.assertIn('Test case success', logtxt)
13021305

13031306
# Also works with non-executable file
13041307
perms = stat.S_IREAD
@@ -1321,13 +1324,17 @@ def test_test_cases_step(self):
13211324
eb.cfg['tests'] = [mock_test_bin_fail]
13221325
write_file(eb.logfile, '')
13231326
self.assertRaisesRegex(RunShellCmdError, f"'{os.path.basename(mock_test_bin_fail)}' failed", eb.test_cases_step)
1324-
self.assertIn('Test case failure', read_file(eb.logfile))
1327+
logtxt = read_file(eb.logfile)
1328+
self.assertIn(f'Running test {mock_test_bin_fail}', logtxt)
1329+
self.assertIn('Test case failure', logtxt)
13251330

13261331
# Multiple tests
13271332
eb.cfg['tests'] = [mock_test_bin, mock_test_bin_fail]
13281333
write_file(eb.logfile, '')
13291334
self.assertRaisesRegex(RunShellCmdError, f"'{os.path.basename(mock_test_bin_fail)}' failed", eb.test_cases_step)
13301335
log_txt = read_file(eb.logfile)
1336+
self.assertIn(f'Running test {mock_test_bin}', logtxt)
1337+
self.assertIn(f'Running test {mock_test_bin_fail}', logtxt)
13311338
self.assertIn('Test case success', log_txt)
13321339
self.assertIn('Test case failure', log_txt)
13331340

0 commit comments

Comments
 (0)