useblocks / sphinx-test-reports

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

Does not working test-reports "links" option in sphinx-needs versions >= v1.0.2 #51

Closed magyarosiR closed 1 year ago

magyarosiR commented 1 year ago

After I increase Sphinx, Test-Reports and Sphinx-Needs versions I got an error message after I built my project:

Sphinx parallel build error:
NotImplementedError: <class 'sphinx.writers.html5.HTML5Translator'> departing unknown node type: NeedIncoming

or

Sphinx parallel build error:
NotImplementedError: <class 'sphinx.writers.html5.HTML5Translator'> departing unknown node type: NeedOutgoing

Versions:

I played with the versions and with my implementation and I realized that problem is coming up, when increasing Sphinx-Needs version above 1.0.2. When I used <=1.0.2 everything works fine.

I have connection between Test Results (Test Cases, Test Suites from Test-Reports extension), and other own created need types using extra options. Between Test Cases (or Test Suites) and Test Specifications I am using the :links: extra option from Test-Results extension.

When I want to link from a Test Case or Test Suite to a Test Specification I got this error message, without linking the project works.

Example implementations of Test Suite and Test Case in reStructuredText:

.. test-suite:: No title
   :id: TESTSUITE_1
   :file: ./source/tests/test_res_addproduct.xml
   :suite: test_res_addproduct-123
   :collapse: true
   :links: TESTSPEC_123
.. test-case:: No title
   :id: TESTCASE_1
   :file: ./source/tests/test_res_addproduct.xml
   :suite: test_res_addproduct-123
   :case: test_button
   :collapse: true
   :links: TESTSPEC_123

I got a feedback from Useblocks side to remove Sphinx parallel build while this bug has been fixed, after I removed I got the error message below:

Exception occurred:
  File "/home/dockeruser/.local/lib/python3.10/site-packages/docutils/nodes.py", line 2056, in unknown_departure
    raise NotImplementedError(
NotImplementedError: <class 'sphinx.writers.html5.HTML5Translator'> departing unknown node type: NeedOutgoing

Important finding: If I put the "target" need in the file where the Test Case or Test Suite is, the build process is successful.

danwos commented 1 year ago

Thanks for reporting and adding a detailed error description :+1:

I was able to reproduce it and could create a test case. However, no solution yet.

But it looks like the handlers for need_incoming and need_outgoing are not called if :links are set by a Sphinx-Test-Report directive (like test-suite or test-case) in the file only.

When I add a dummy-need, which is also setting a link, then my test case works:

.. spec:: A dummy need
   :id: SPEC_001
   :links: TESTSPEC_123

This means the need_outgoing and need_incoming roles are correctly handled. Only the handlers itself get not executed for the file.

Argh, I think I have it. Sphinx-Needs is storing, which directive/role is used in which file so that it calls the needed handlers only for these files. This allows us to skip any performance-costing doctree-lookups.

This mechanism is not yet part of Sphinx-Test-Report, so the handlers get not called if no other Sphinx-Needs "links" are used somewhere in the same file.

Give me some minutes :)

danwos commented 1 year ago

Fix is out with PR #52.

@magyarosiR can you please test, if the version on master solves all the problems now? Simply install via pip install --upgrade git+https://github.com/useblocks/sphinx-test-reports.git

magyarosiR commented 1 year ago

Thank you for your quick solution @danwos, it is works fine locally.

I used the pip install git+https://github.com/useblocks/sphinx-test-reports@0f1ee42c8fecdca334e81009a5e89eefaf4b093f command to upgrade version.