useblocks / sphinx-test-reports

Documents test-results inside Sphinx
https://sphinx-test-reports.readthedocs.io/en/latest/
MIT License
28 stars 18 forks source link

Usage of check_linked_values #56

Closed kreuzberger closed 1 year ago

kreuzberger commented 1 year ago

Hi!

I try to use check_linked_values dynamic function to resolve the results from importet junit file to my previously defined test cases.

Attached files contains the junit xml (one tests with status fail) and the index.rst with the report definition. Expected: in the needstable one row gets red, other rows have no color due to check_linked_values returning only failed for ONE case. But the result is that EVERY row is marked failed. Does check_linked_values perform a deep search of all linked values (and therefore for the complete file test file itself?). Or what is wrong in my usage of dynamic function?

Content of report index.rst

Checked linked values
=====================

.. test:: usage_test
   :id: TEST_0001

.. test:: success_test
   :id: TEST_0002

.. test:: fail_test
   :id: TEST_0003

.. test:: fail_test_output
   :id: TEST_0004

.. needtable::
   :style: table
   :filter:  id.startswith('TEST_') and any('CTESTFILE_1' in s for s in links_back)
   :columns: id, title, links_back as "Tests"
   :style_row: [[check_linked_values('tr_failure', 'result', 'failure', filter_string='title==case')]]

.. test-file:: My CTest Data
   :file: ../utils/ctest_result_filter.xml
   :id: CTESTFILE_1
   :auto_suites:
   :auto_cases:
   :links: [[tr_link('classname', 'title')]]

The content of the xml file is:

<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="Linux-c++"
    tests="4"
    failures="1"
    disabled="0"
    skipped="0"
    hostname=""
    time="0"
    timestamp="2022-12-08T15:15:07"
    >
    <testcase name="usage_test" classname="usage_test" time="0.000609293" status="run">
        <system-out>usage: test &lt;argument&gt;
    If &lt;argument&gt; is 0, print SUCCESS. Otherwise print FAIL.
</system-out>
    </testcase>
    <testcase name="success_test" classname="success_test" time="0.000605907" status="run">
        <system-out>SUCCESS
</system-out>
    </testcase>
    <testcase name="fail_test" classname="fail_test" time="0.000599379" status="run">
        <system-out>FAIL
</system-out>
    </testcase>
    <testcase name="fail_test_output" classname="fail_test_output" time="0.000576548" status="fail">
        <failure message=""/>
        <system-out>FAIL
</system-out>
    </testcase>
</testsuite>

Attached files: doc_test_ctest_file_result_filter.zip Screenshot_20230223_092144

kreuzberger commented 1 year ago

Using sphinx >= 6.0

kreuzberger commented 1 year ago

Ok, i see 2 potential errors: First: if NO LINK is found, the functions returns ALWAYS the desired value. This should return none. Second: the function checks only "links", i assumed it searches "links_back" also.

:edit: Ok, and from the docu ( i missed the restrictions hint) incoming links are not available with dynamic functions. So second is just not valid