Skip to content
Open
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
3 changes: 3 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[env]
# insta writes multi-line snapshot metadata as unquoted literal blocks
INSTA_YAML_BLOCK_STYLE = "1"
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ pkg/aur/.SRCINFO

# dummy dir to test org behaviour
toss/

# don't commit pending snapshots
*.snap.new
29 changes: 29 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,32 @@ cargo install org-rust
*** Development

Refer to the [[./docs][documentation]] for developer-specific information & syntax-progress.


** Testing

The parser and exporter rely on snapshot tests built on [[https://insta.rs/][insta]].
A snapshot test processes a small input and compares the output against a stored snapshot (~.snap~) in ~crates/<crate>/snapshots/~.
Parser tests compare against the output ~Parser::render_tree()~ to ensure stability.
Exporter snapshot tests are handled [[https://insta.rs/docs/quickstart/#inline-snapshots][inline]].

*** Snapshot workflow

After making a change, run the tests as usual with ~cargo test --workspace~.
If a snapshot doesn't match (or doesn't exist yet), the test fails and ~insta~ generates a pending snapshot as a ~.snap.new~ file.

Read the diff to verify correctness. Optionally, [[https://insta.rs/docs/cli/][cargo-insta]] offers a convenience tool for this:

#+begin_src bash
cargo insta review
#+end_src

If every change is intended, ~INSTA_UPDATE=always cargo test --workspace~ accepts them all at once, overwriting the stored snapshots directly.

*** Adding a test

The snapshot is named after the module path and test name.

1. Run ~cargo test~. The new test fails and writes a ~.snap.new~.
2. Check, then accept it with ~cargo insta review~ / ~cargo insta accept~ or just do it manually.
3. Re-run ~cargo test~, then commit the new ~.snap~ file.
1 change: 1 addition & 0 deletions crates/org-exporter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ phf = {version = "0.11.1", features = ["macros"]}
thiserror = "1.0.63"

[dev-dependencies]
insta = "1.48.0"
pretty_assertions = "1.3.0"
Loading
Loading