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
30 changes: 21 additions & 9 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,33 @@ Blocks support options in the infostring (e.g., ` ```nushell try, no-output `):

## Testing

The `toolkit.nu testing` command:
```nushell
# Run all tests (unit + integration)
nu toolkit.nu testing

# Run only unit tests (nutest-based, tests internal functions)
nu toolkit.nu testing-unit

# Run only integration tests (executes example markdown files)
nu toolkit.nu testing-integration

# All commands support --json for CI
nu toolkit.nu testing --json
```

### Unit Tests (`tests/`)

Unit tests use [nutest](https://github.com/vyadh/nutest) framework. Tests import internal functions via `use ../numd/commands.nu *` to test parsing and transformation logic directly.

### Integration Tests (`z_examples/`)

The `testing-integration` command:
1. Runs all example files in `z_examples/` through numd
2. Generates stripped `.nu` versions in `z_examples/99_strip_markdown/`
3. Reports Levenshtein distance and diff stats to detect changes

Example files serve as integration tests - use both the Levenshtein stats and `git diff` to verify changes.

```bash
# Run tests with JSON output (for external tools/CI)
nu toolkit.nu testing --json

# Check actual file changes after testing
git diff
```

### Expected Non-Zero Diffs

Some files legitimately differ on each run due to:
Expand Down
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ Output:
# => ╰──────────────────name───────────────────┴─type─╯

> sys host | get boot_time
# => Fri Dec 5 00:43:02 2025
# => Fri Dec 5 01:08:37 2025

> 2 + 2
# => 4
Expand Down Expand Up @@ -242,10 +242,29 @@ Output:

Nushell Markdown documents used together with Git could often serve as a convenient way to test custom and built-in Nushell commands.

Testing of the `numd` module itself is done via the `testing` command in `tools.nu` in the root repository folder: whatever changes are made in the module - it could be easily seen if they break anything (both by the Levenshtein distance metric or by `git diff` of the updated example files versus their initial versions) . Please, feel free to try it on your own.
Testing of the `numd` module is done via `toolkit.nu`:

```nushell no-run
# Run all tests (unit + integration)
> nu toolkit.nu testing

# Run only unit tests (uses nutest framework)
> nu toolkit.nu testing-unit

# Run only integration tests (executes example markdown files)
> nu toolkit.nu testing-integration
```

### Unit tests

Unit tests in `tests/` use the [nutest](https://github.com/vyadh/nutest) framework to test internal functions like `find-code-blocks`, `match-action`, `extract-fence-options`, etc.

### Integration tests

Integration tests run all example files in `z_examples/` through numd and report changes via Levenshtein distance. Whatever changes are made in the module - it can be easily seen if they break anything (both by the Levenshtein distance metric or by `git diff` of the updated example files versus their initial versions).

```nushell no-run
> nu toolkit.nu testing-integration
# => ╭───────────────────────────────────────────────┬─────────────────┬───────────────────┬────────────┬──────────────┬─────╮
# => │ filename │ nushell_blocks │ levenshtein_dist │ diff_lines │ diff_words │ ... │
# => ├───────────────────────────────────────────────┼─────────────────┼───────────────────┼────────────┼──────────────┼─────┤
Expand Down
Loading
Loading