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
The :func:`@xfail <reframe.core.decorators.xfail>` decorator takes a message to issue when the test fails, explaining the failure, and optionally a predicate to control when the test is expected to fail (we will discuss this later in the section).
1444
+
In the example above, we have introduced a typo in the sanity checking function to cause the test to fail, but we have marked it as an expected failure.
[ PASSED ] Ran 1/1 test case(s) from 1 check(s) (0 failure(s), 1 expected failure(s), 0 skipped, 0 aborted)
1464
+
[==========] Finished on Thu May 15 09:10:09 2025+0000
1465
+
1466
+
Notice that the test is marked as ``XFAIL`` and no ``FAILURE INFO`` is generated.
1467
+
1468
+
As mentioned previously you can control when a sanity failure should be considered expected or not by passing the ``predicate`` argument to :func:`@xfail <reframe.core.decorators.xfail>`.
1469
+
In the following example, a failure is expected only if ``x<=2``:
[ FAILED ] Ran 1/1 test case(s) from 1 check(s) (1 failure(s), 0 expected failure(s), 0 skipped, 0 aborted)
1508
+
1509
+
Note that the test is counted as a failure and the overall run result is FAIL.
1510
+
The reason in the ``FAILURE INFO`` of the test mentions that the test has passed unexpectedly and also states the original reason of why it should fail.
1511
+
1512
+
.. code-block:: console
1513
+
1514
+
* Reason: unexpected success error: demo failure
1515
+
1516
+
1517
+
Expected performance failures
1518
+
-----------------------------
1519
+
1520
+
A test fails a performance check when it cannot meet its reference performance within certain user-defined bounds.
1521
+
As dicussed :ref:`earlier <writing-your-first-test>`, a test may define multiple performance variables, each one associated with a different reference.
1522
+
To mark an expected performance failure, you need to wrap the :attr:`~reframe.core.pipeline.RegressionTest.reference` tuple with the :func:`~reframe.core.builtins.xfail` builtin.
For demonstration purposes, we have increased significantly the ``copy_bw`` reference so as to cause the test to fail and mark this as an expected failure.
1535
+
Note that the :func:`~reframe.core.builtins.xfail` builtin is *different* from the :func:`@xfail <reframe.core.decorators.xfail>` decorator.
1536
+
Although the first argument is always the message to be printed, the builtin takes the reference tuple as a second argument, whereas the decorator takes optionally a conditional.
1537
+
1538
+
.. note::
1539
+
1540
+
For testing out this example, you need to set the :attr:`reference` in the ``stream_run_only.py`` test based on your system's performance.
1541
+
1542
+
Since a test might define multiple performance variables, some of which may be marked as expected failures, the overall final state of the test has to be determined in a more complex way.
1543
+
Assuming that the notation ``A>B`` means that ``A`` takes precendence over ``B``, the types of performance failures use the following hierarchy:
1544
+
1545
+
.. code-block:: console
1546
+
1547
+
FAIL > XPASS > XFAIL > PASS
1548
+
1549
+
In other words, if at least one performance variable fails, the test is a ``FAIL``.
1550
+
If none of the performance variables fails, but at least one passes unexpectedly, the test is an ``XPASS``.
1551
+
If none of the performance variables fails nor passes unexpectedly and all the expected failures fail, then the test is an ``XFAIL``.
1552
+
In all other cases the test is a ``PASS``.
1553
+
1554
+
In cases of failures or unexpected passes, the status of every performance will be printed in the ``FAILURE INFO``.
1555
+
Also, if colors are enabled (see :option:`--nocolor`), then each variable's status will be color coded in the ``P:`` lines printed just after the test finishes.
1556
+
Here is an example combined failure (``XPASS`` and ``FAIL``):
1557
+
1558
+
1559
+
.. code-block:: console
1560
+
1561
+
* Reason: performance error:
1562
+
reference(s) met unexpectedly: copy_bw=40299.1 MB/s, expected 40000 (l=36000.0, u=44000.0)
1563
+
failed to meet reference(s): triad_bw=30561.6 MB/s, expected 100000 (l=90000.0, u=110000.00000000001)
1564
+
1565
+
You can try different combinations of :func:`~reframe.core.builtins.xfail` markings and reference values to explore the behavior.
0 commit comments