@@ -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