Skip to content

Commit ae34c83

Browse files
authored
Merge pull request #3540 from vkarak/doc/pipeline-hooks-private-fn
[doc] Add some notes and tips in the documentation of pipeline hooks
2 parents 020b39c + a1bbba6 commit ae34c83

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

docs/regression_test_api.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,10 @@ the run hooks of :class:`Y` will be executed as follows:
161161
.. seealso::
162162
- :func:`@run_before <reframe.core.builtins.run_before>`, :func:`@run_after <reframe.core.builtins.run_after>` decorators
163163

164+
.. note::
165+
166+
Pipeline hook functions cannot be private, i.e., starting with double underscore: ``__``.
167+
164168
.. note::
165169
Pipeline hooks do not execute in the test's stage directory, but in the directory that ReFrame executes in.
166170
However, the test's :attr:`~reframe.core.pipeline.RegressionTest.stagedir` can be accessed by explicitly changing the working directory from within the hook function itself (see the :class:`~reframe.utility.osext.change_dir` utility for further details):
@@ -200,6 +204,11 @@ the run hooks of :class:`Y` will be executed as follows:
200204
This version defines the execution order of hooks, which now follows a strict reverse MRO order, so that parent hooks will execute before those of derived classes.
201205
Tests that relied on the execution order of hooks might break with this change.
202206

207+
.. tip::
208+
209+
When writing library tests or :class:`~reframe.core.pipeline.RegressionMixin`'s that are meant to be re-used by multiple final tests, it is a good practice to define their hooks using a unique name scheme, e.g., ``_<ClassName>_<hook_name>``.
210+
This will avoid possible clashes with hooks in derived test classes that may use the same hook name hiding inadvertently the base class hook.
211+
Note that in future ReFrame may create unique names for pipeline hooks automatically.
203212

204213

205214
.. _test-variants:

0 commit comments

Comments
 (0)