-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix #297: Ablog is NOT safe for parallel read
- Loading branch information
1 parent
c17d644
commit d194653
Showing
9 changed files
with
60 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
extensions = ["ablog"] |
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,7 @@ | ||
test-postlist | ||
=============== | ||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
|
||
postlist |
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,4 @@ | ||
.. post:: 2020-12-01 | ||
|
||
post 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.. post:: 2020-12-01 | ||
|
||
post 2 | ||
======= |
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,4 @@ | ||
.. post:: 2020-12-01 | ||
|
||
post 3 | ||
======= |
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,4 @@ | ||
.. post:: 2020-12-01 | ||
|
||
post 4 | ||
======= |
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,4 @@ | ||
postlist | ||
========== | ||
|
||
.. postlist:: |
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from pathlib import Path | ||
from subprocess import run | ||
|
||
|
||
def test_not_safe_for_parallel_read(rootdir: Path): | ||
"""Ablog is NOT safe for parallel read. In such case, it doesn't collect any posts.""" | ||
# https://github.com/sunpy/ablog/issues/297 | ||
# Very ugly hack to change the parallel_read_safe value to True | ||
good_read_safe = '"parallel_read_safe": False' | ||
bad_read_safe = '"parallel_read_safe": True' | ||
init_py_path = Path(__file__).parent.parent / "__init__.py" | ||
assert good_read_safe in init_py_path.read_text() | ||
bad_init_py = init_py_path.read_text().replace(good_read_safe, bad_read_safe) | ||
init_py_path.write_text(bad_init_py) | ||
|
||
# liborjelinek: I wasn't able to demonstrate the issue with the `parallel` argument to the `sphinx` fixture | ||
# @pytest.mark.sphinx("html", testroot="parallel", parallel=2) | ||
# therefore running sphinx-build externally | ||
indir = rootdir / "test-parallel" | ||
run(["sphinx-build", "-M", "html", indir.as_posix(), "_build", "-j", "auto"], check=True) | ||
|
||
path = indir / "_build" / "html" / "postlists.html" | ||
|
||
run(f"sudo ls -l {path.as_posix()}", shell=True) | ||
|
||
# And posts are not collected by Ablog... | ||
html = path.read_text() | ||
assert "post 1" not in html | ||
assert "post 2" not in html | ||
assert "post 3" not in html | ||
assert "post 4" not in html |