From a130c67b61527368c29e770fa5edd57a5f031953 Mon Sep 17 00:00:00 2001 From: Dima Gerasimov Date: Sat, 26 Sep 2026 15:02:38 +0100 Subject: [PATCH] test: expand corpus with real-world Org documents --- .gitmodules | 12 ++++++++++++ README.md | 3 ++- README.qmd | 3 ++- src/orgparse/tests/test_corpus.py | 21 +++++++++++++++------ testdata/external/exobrain | 1 + testdata/external/nvim-orgmode | 1 + testdata/external/sachac | 1 + 7 files changed, 34 insertions(+), 8 deletions(-) create mode 160000 testdata/external/exobrain create mode 160000 testdata/external/nvim-orgmode create mode 160000 testdata/external/sachac diff --git a/.gitmodules b/.gitmodules index a5e5a1e..92a2ced 100644 --- a/.gitmodules +++ b/.gitmodules @@ -2,3 +2,15 @@ path = testdata/external/org-mode url = https://github.com/bzg/org-mode.git shallow = true +[submodule "external/sachac"] + path = testdata/external/sachac + url = https://github.com/sachac/.emacs.d.git + shallow = true +[submodule "external/exobrain"] + path = testdata/external/exobrain + url = https://github.com/karlicoss/exobrain.git + shallow = true +[submodule "external/nvim-orgmode"] + path = testdata/external/nvim-orgmode + url = https://github.com/nvim-orgmode/orgmode.git + shallow = true diff --git a/README.md b/README.md index db8f9c1..fa86999 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,8 @@ For an existing checkout, run `git submodule update --init --recursive`. Run the tests with `uv tool run --with tox-uv tox -e tests`. This also checks the examples in this README. -The normal test suite parses the `.org` files in `testdata/external/org-mode/testing/examples` and checks tree structure and attribute access. +Corpus tests parse upstream Org examples, Sacha Chua’s Emacs configuration, exobrain notes, and nvim-orgmode documents from `testdata/external`. +They check tree structure, source line ranges, and attribute access. Edit `README.qmd`, then regenerate `README.md` with `uv tool run --with tox-uv tox -e quarto`. Quarto computes links to source code and tests from their definitions, so line numbers are refreshed when rendering. diff --git a/README.qmd b/README.qmd index 6902ba7..7fff685 100644 --- a/README.qmd +++ b/README.qmd @@ -151,7 +151,8 @@ For an existing checkout, run `git submodule update --init --recursive`. Run the tests with `uv tool run --with tox-uv tox -e tests`. This also checks the examples in this README. -The normal test suite parses the `.org` files in `testdata/external/org-mode/testing/examples` and checks tree structure and attribute access. +Corpus tests parse upstream Org examples, Sacha Chua's Emacs configuration, exobrain notes, and nvim-orgmode documents from `testdata/external`. +They check tree structure, source line ranges, and attribute access. Edit `README.qmd`, then regenerate `README.md` with `uv tool run --with tox-uv tox -e quarto`. Quarto computes links to source code and tests from their definitions, so line numbers are refreshed when rendering. diff --git a/src/orgparse/tests/test_corpus.py b/src/orgparse/tests/test_corpus.py index 351151d..f30cf50 100644 --- a/src/orgparse/tests/test_corpus.py +++ b/src/orgparse/tests/test_corpus.py @@ -1,4 +1,4 @@ -"""Exercise the public parser API on Org mode's upstream example files.""" +"""Exercise the public parser API on upstream examples and real-world Org documents.""" from pathlib import Path @@ -8,18 +8,27 @@ from ..extra import Table from ..node import OrgNode -CORPUS = Path(__file__).resolve().parents[3] / 'testdata' / 'external' / 'org-mode' / 'testing' / 'examples' +CORPUS = Path(__file__).resolve().parents[3] / 'testdata' / 'external' +CORPUS_DIRS = ( + 'org-mode/testing/examples', + 'sachac', + 'exobrain', + 'nvim-orgmode', +) def corpus_files() -> list[Path]: - paths = sorted(CORPUS.rglob('*.org')) - assert len(paths) > 0, 'Missing Org corpus: run git submodule update --init --recursive' + paths = [] + for directory in CORPUS_DIRS: + files = sorted((CORPUS / directory).rglob('*.org')) + assert len(files) > 0, f'Missing Org corpus {directory}: run git submodule update --init --recursive' + paths.extend(files) return paths @pytest.mark.parametrize('path', corpus_files(), ids=lambda path: path.relative_to(CORPUS).as_posix()) def test_corpus(path: Path) -> None: - """Check parser robustness and tree consistency across upstream Org examples. + """Check parser robustness and tree consistency across examples, configurations, notes, and documentation. Exercise heading/body formatting, property lookups, table row/block iteration, and formatting of populated timestamps. @@ -49,7 +58,7 @@ def test_corpus(path: Path) -> None: list(part.rows) list(part.blocks) - dates = node.get_timestamps(active=True, inactive=True) + dates = node.get_timestamps(active=True, inactive=True, point=True, range=True) if isinstance(node, OrgNode): dates = [*dates, node.scheduled, node.deadline, node.closed, *node.clock, *node.repeated_tasks] for date in dates: diff --git a/testdata/external/exobrain b/testdata/external/exobrain new file mode 160000 index 0000000..339faa2 --- /dev/null +++ b/testdata/external/exobrain @@ -0,0 +1 @@ +Subproject commit 339faa2ef6d708d3b216858b002bc48e6ac7e6b1 diff --git a/testdata/external/nvim-orgmode b/testdata/external/nvim-orgmode new file mode 160000 index 0000000..d9cd82d --- /dev/null +++ b/testdata/external/nvim-orgmode @@ -0,0 +1 @@ +Subproject commit d9cd82d732cf4322100cf2c4c57b285c870bd893 diff --git a/testdata/external/sachac b/testdata/external/sachac new file mode 160000 index 0000000..57c7f7b --- /dev/null +++ b/testdata/external/sachac @@ -0,0 +1 @@ +Subproject commit 57c7f7b30dcf5930daea4edbe6dfc7e2eafea4a5