8000 docs: rewrite habit snooze spec for humans by ASHWATHRAM007 · Pull Request #197 · habit-hooks/habit-hooks · GitHub
[go: up one dir, main page]

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
10 changes: 8 additions & 2 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@

from __future__ import annotations

import shutil
import tempfile
import weakref
from pathlib import Path

import pytest

from harness import (
POSIX_SHELL_ONLY,
STEPS_RUN_ON_THIS_PLATFORM,
Session,
SpecCase,
SpecError,
SpecFailure,
Expand All @@ -32,6 +35,9 @@ def pytest_collect_file(parent, file_path):

class SpecFile(pytest.File):
def collect(self):
root = Path(tempfile.mkdtemp(dir=_case_root()))
weakref.finalize(self, shutil.rmtree, root, True)
self.spec_session = Session(root)
for case in parse_spec(self.path.read_text(encoding="utf-8")):
yield SpecItem.from_parent(self, name=case.name, case=case)

Expand All @@ -46,8 +52,8 @@ def runtest(self):
pytest.skip(POSIX_SHELL_ONLY)
if self.case.skip:
pytest.skip("🟡 not built yet")
with tempfile.TemporaryDirectory(dir=_case_root()) as tmp:
execute(self.case, Path(tmp), _REPO_ROOT)
workdir = self.parent.spec_session.workdir(self.case.continued)
execute(self.case, workdir, _REPO_ROOT)

def repr_failure(self, excinfo):
if isinstance(excinfo.value, (SpecError, SpecFailure)):
Expand Down
4 changes: 4 additions & 0 deletions docs/executable_spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ So given:

`Example A` and `Example B` each start from a clean temp dir with `FOO` set and `config.toml` written.

A heading that ends in `(continued)` continues the previous section instead of starting fresh: it runs in the directory the previous section left behind, and its inherited preambles are skipped — their effect is already on disk. Sections chain in document order, so a `(continued)` section may continue another `(continued)` section.

A `(continued)` section with no previous section is an error, so running one on its own (for example picked out by `pytest -k`) fails instead of silently missing its context.

## Steps

A step is a **marker** optionally followed by a fenced code block. The block's info string (` ```json `, ` ```markdown `, …) is cosmetic — only the marker decides the block's role. ` ```bash ` blocks are **reserved** for commands and are never consumed as another marker's payload.
Expand Down
Loading
0