Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion README.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
21 changes: 15 additions & 6 deletions src/orgparse/tests/test_corpus.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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.
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions testdata/external/exobrain
Submodule exobrain added at 339faa
1 change: 1 addition & 0 deletions testdata/external/nvim-orgmode
Submodule nvim-orgmode added at d9cd82
1 change: 1 addition & 0 deletions testdata/external/sachac
Submodule sachac added at 57c7f7
Loading