-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 fix warnings for duplicate needs in parallel builds (#1223)
Change duplicate need feedback from raising exceptions to emitting Sphinx warnings, e.g. ``` path/to/page.rst:4: WARNING: A need with ID STORY_PAGE_1 already exists, title: 'duplicate'. [needs.duplicate_id] ``` and ensure warning is also emitted during parallel builds Note, although there was already a parallel build test in the test suite, actually it was not running parallel because there were not enough documents in the test project (see sphinx-doc/sphinx#12796), so one more document is added.
- Loading branch information
1 parent
2045121
commit ff4ae90
Showing
8 changed files
with
96 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ PARALLEL TEST DOCUMENT | |
page_2 | ||
page_3 | ||
page_4 | ||
page_5 | ||
|
||
.. spec:: Command line interface | ||
:id: SP_TOO_001 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Page 5 | ||
====== | ||
|
||
.. story:: duplicate | ||
:id: STORY_PAGE_1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,26 @@ | ||
import pytest | ||
import os | ||
|
||
from sphinx_needs.api.need import NeedsDuplicatedId | ||
import pytest | ||
from sphinx.testing.util import SphinxTestApp | ||
from sphinx.util.console import strip_colors | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"test_app", | ||
[{"buildername": "html", "srcdir": "doc_test/broken_doc"}], | ||
[{"buildername": "html", "srcdir": "doc_test/broken_doc", "no_plantuml": True}], | ||
indirect=True, | ||
) | ||
def test_doc_build_html(test_app): | ||
with pytest.raises(NeedsDuplicatedId): | ||
app = test_app | ||
|
||
app.build() | ||
html = (app.outdir / "index.html").read_text() | ||
assert "<h1>BROKEN DOCUMENT" in html | ||
assert "SP_TOO_001" in html | ||
def test_doc_build_html(test_app: SphinxTestApp): | ||
test_app.build() | ||
warnings = ( | ||
strip_colors(test_app._warning.getvalue()) | ||
.replace(str(test_app.srcdir) + os.path.sep, "<srcdir>/") | ||
.strip() | ||
) | ||
assert ( | ||
warnings | ||
== "<srcdir>/index.rst:11: WARNING: A need with ID SP_TOO_001 already exists, title: 'Command line interface'. [needs.duplicate_id]" | ||
) | ||
html = (test_app.outdir / "index.html").read_text() | ||
assert "<h1>BROKEN DOCUMENT" in html | ||
assert "SP_TOO_001" in html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters