Skip to content

Incomplete hook override with multiple inheritance #2055

@jjotero

Description

@jjotero

Reproducer:

class Base(rfm.RunOnlyRegressionTest):
    valid_systems = ['dom:login']
    valid_prog_environs = ['PrgEnv-gnu']
    executable = 'echo bananas'
         
    @sanity_function
    def assert_bananas(self): 
        return sn.assert_found(r'bananas', self.stdout)

    @run_after('setup')
    @run_after('compile')
    def hh(self):
        print('bananas')

class Base2(rfm.RegressionMixin): 
    @run_after('setup')
    def hh(self):
        print('not bananas') 
    
@rfm.simple_test
class Derived(Base2, Base):
    pass

This gives:

[==========] Running 1 check(s)
[==========] Started on Mon Jul  5 13:30:09 2021 

[----------] started processing Derived (Derived)
[ RUN      ] Derived on dom:login using PrgEnv-gnu
not bananas
not bananas
[----------] finished processing Derived (Derived)

[----------] waiting for spawned checks to finish
[       OK ] (1/1) Derived on dom:login using PrgEnv-gnu [compile: 0.006s run: 1.306s total: 1.341s]
[----------] all spawned checks have finished

[  PASSED  ] Ran 1/1 test case(s) from 1 check(s) (0 failure(s), 0 skipped)
[==========] Finished on Mon Jul  5 13:30:10 2021 

The hook hh from class Base2 overrides the post-setup hook from class Base. However, class Base also decorates hh as a post-compile hook, and this leaks into Derived, which calls hh (inherited from Base2) both as a post-setup and post-compile hooks. hh here should only be called as a post-setup hook.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions