Skip to content

Commit 7e90868

Browse files
author
Vasileios Karakasis
authored
Merge pull request #1163 from ekouts/bugfix/setup_hooks
[bugfix] Execute setup hooks for `CompileOnlyRegressionTest` and make the run hooks for the `RunOnlyRegressionTest` execute at the right place
2 parents 91c55c4 + d7547bf commit 7e90868

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

reframe/core/pipeline.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1506,6 +1506,7 @@ def compile_wait(self):
15061506
This is a no-op for this type of test.
15071507
'''
15081508

1509+
@_run_hooks('pre_run')
15091510
def run(self):
15101511
'''The run phase of the regression test pipeline.
15111512
@@ -1519,7 +1520,7 @@ def run(self):
15191520
self._copy_to_stagedir(os.path.join(self._prefix,
15201521
self.sourcesdir))
15211522

1522-
super().run()
1523+
super().run.__wrapped__(self)
15231524

15241525

15251526
class CompileOnlyRegressionTest(RegressionTest):
@@ -1539,6 +1540,7 @@ def _rfm_init(self, *args, **kwargs):
15391540
super()._rfm_init(*args, **kwargs)
15401541
self.local = True
15411542

1543+
@_run_hooks()
15421544
def setup(self, partition, environ, **job_opts):
15431545
'''The setup stage of the regression test pipeline.
15441546

unittests/test_pipeline.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,30 @@ def postfoo(self):
457457
assert '_RFM_PRE_SETUP' in os.environ
458458
assert '_RFM_POST_SETUP' in os.environ
459459

460+
def test_setup_hooks_in_compile_only_test(self):
461+
@fixtures.custom_prefix('unittests/resources/checks')
462+
class MyTest(rfm.CompileOnlyRegressionTest):
463+
def __init__(self):
464+
self.name = 'hellocheck_compile'
465+
self.valid_systems = ['*']
466+
self.valid_prog_environs = ['*']
467+
self.sourcepath = 'hello.c'
468+
self.executable = os.path.join('.', self.name)
469+
self.sanity_patterns = sn.assert_found('.*', self.stdout)
470+
self.count = 0
471+
472+
@rfm.run_before('setup')
473+
def presetup(self):
474+
self.count += 1
475+
476+
@rfm.run_after('setup')
477+
def postsetup(self):
478+
self.count += 1
479+
480+
test = MyTest()
481+
_run(test, self.partition, self.prgenv)
482+
assert test.count == 2
483+
460484
def test_compile_hooks(self):
461485
@fixtures.custom_prefix('unittests/resources/checks')
462486
class MyTest(HelloTest):
@@ -498,6 +522,26 @@ def check_executable(self):
498522
test = MyTest()
499523
_run(test, self.partition, self.prgenv)
500524

525+
def test_run_hooks_in_run_only_test(self):
526+
@fixtures.custom_prefix('unittests/resources/checks')
527+
class MyTest(rfm.RunOnlyRegressionTest):
528+
def __init__(self):
529+
self.executable = 'echo'
530+
self.executable_opts = ['Hello, World!']
531+
self.local = True
532+
self.valid_prog_environs = ['*']
533+
self.valid_systems = ['*']
534+
self.sanity_patterns = sn.assert_found(
535+
r'Hello, World\!', self.stdout)
536+
537+
@rfm.run_before('run')
538+
def check_empty_stage(self):
539+
# Make sure nothing has been copied to the stage directory yet
540+
assert len(os.listdir(self.stagedir)) == 0
541+
542+
test = MyTest()
543+
_run(test, self.partition, self.prgenv)
544+
501545
def test_multiple_hooks(self):
502546
@fixtures.custom_prefix('unittests/resources/checks')
503547
class MyTest(HelloTest):

0 commit comments

Comments
 (0)