You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/regression_test_api.rst
+36-2Lines changed: 36 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -111,10 +111,10 @@ So although a "post-init" and a "pre-setup" hook will both run *after* a test ha
111
111
the post-init hook will execute *right after* the test is initialized.
112
112
The framework will then continue with other activities and it will execute the pre-setup hook *just before* it schedules the test for executing its setup stage.
113
113
114
-
Pipeline hooks are executed in reverse MRO order, i.e., the hooks of the least specialized class will be executed first.
114
+
Pipeline hooks are normally executed in reverse MRO order, i.e., the hooks of the least specialized class will be executed first.
115
115
In the following example, :func:`BaseTest.x` will execute before :func:`DerivedTest.y`:
116
116
117
-
.. code:: python
117
+
.. code-block:: python
118
118
119
119
classBaseTest(rfm.RegressionTest):
120
120
@run_after('setup')
@@ -127,6 +127,34 @@ In the following example, :func:`BaseTest.x` will execute before :func:`DerivedT
127
127
'''Hook y'''
128
128
129
129
130
+
This order can be altered using the ``always_last`` argument of the :func:`@run_before <reframe.core.builtins.run_before>` and :func:`@run_after <reframe.core.builtins.run_after>` decorators.
131
+
In this case, all hooks of the same stage defined with ``always_last=True`` will be executed in MRO order at the end of the stage's hook chain.
132
+
For example, given the following hierarchy:
133
+
134
+
.. code-block:: python
135
+
136
+
classX(rfm.RunOnlyRegressionTest):
137
+
@run_before('run', always_last=True)
138
+
defhook_a(self): pass
139
+
140
+
@run_before('run')
141
+
defhook_b(self): pass
142
+
143
+
classY(X):
144
+
@run_before('run', always_last=True)
145
+
defhook_c(self): pass
146
+
147
+
@run_before('run')
148
+
defhook_d(self): pass
149
+
150
+
151
+
the run hooks of :class:`Y` will be executed as follows:
@@ -146,6 +174,12 @@ In the following example, :func:`BaseTest.x` will execute before :func:`DerivedT
146
174
with osext.change_dir(self.stagedir):
147
175
...
148
176
177
+
.. note::
178
+
In versions prior to 4.3.4, overriding a pipeline hook in a subclass would re-attach it from scratch in the stage, therefore changing its execution order relative to other hooks of the superclass.
179
+
This is fixed in versions >= 4.3.4 where the execution order of the hook is not changed.
180
+
However, the fix may break existing workaround code that used to call explicitly the base class' hook from the derived one.
181
+
Check issue `#3012 <https://github.com/reframe-hpc/reframe/issues/3012>`__ for details on how to properly address this.
182
+
149
183
.. warning::
150
184
.. versionchanged:: 3.7.0
151
185
Declaring pipeline hooks using the same name functions from the :py:mod:`reframe` or :py:mod:`reframe.core.decorators` modules is now deprecated.
0 commit comments