sphinx-needs: needs_warnings not returning error code or writing to error log
Usage of -W shall handle all warnings as errors and the sphinx-build executable shall return a non-zero value as error code. Also the usage of -w <file> shall write all warnings to a file.
This works incase of Sphinx warnings, but not for warnings created with needs_warnings. Because of this pipelines cannot be configured to break incase of needs_warnings.
To reproduce the problem, do the following steps
- Create
needs_warningsinconf.py - Create a need warning within any rST
- Execute sphinx-build as follows from a console
sphinx-build -M html docs _build -W --keep-going -w error.log
- Observe
need_warningson the console - Execute the following from the console
echo $?
0is returned (a non-zero value is expected)- Check the file
error.log - Only the following line is present
WARNING: Sphinx-Needs warnings were raised. See console / log output for details.
All needs_warnings are expected in the log.
Could it be that needs_warnings is always writing to stdout instead of stderror (even with -W)?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (6 by maintainers)
Commits related to this issue
- Fixed sphinx-needs warnings return code (#396) * Fixed sphinx-needs warnings return code * Added check condition and more test scenarios Fix for #344 — committed to useblocks/sphinx-needs by haiyangToAI 3 years ago
@haiyangToAI figured out the reason: The status code calculation happens in Sphinx far too early and is based on a warning_count. See https://github.com/sphinx-doc/sphinx/blob/81a4fd973d4cfcb25d01a7b0be62cdb28f82406d/sphinx/application.py#L345 As our warning-checks happen in the cleanup-phase, which gets executed by Sphinx after the status code calculation, the value for status_code may not be valid anymore.
@haiyangToAI is currently checking if we can make a dirty-hack and change this value on our own.
@haiyangToAI @danwos How can we conclude this topic? My current understanding from the above discussion is that, sphinx-needs warnings (or in general warnings thrown by sphinx extensions?) are treated differently compared to sphinx warnings. Is this an issue coming sphinx or sphinx-needs?