A simple and powerful testing toolkit for MoonBit CLI applications and Script
Dependencies
moon run . -- test README.md
moon run . -- test examples
moon run . -- update examples --dry-run$ ./examples/hello.mbtx "Moon Bit"
Hello, Moon Bit!mooncram test [paths...] [--target wasm|native] [--timeout-ms N]
mooncram update [paths...] [--target wasm|native] [--timeout-ms N] [--dry-run]
mooncram --help
mooncram --version| Status | Meaning |
|---|---|
| 0 | All assertions pass, or update/dry-run completes successfully |
| 1 | One or more assertions fail in test |
| 2 | Invalid arguments, parsing/build/execution errors, or no cases found |
```mooncram
$ ./hello.mbtx 'Moon Bit'
Hello, Moon Bit!
$ ./cmd/main --version
my-cli * (glob)
```| Suffix | Meaning |
|---|---|
| none or (equal) | Exact line match |
| (glob) | Whole-line glob: *, ?, [abc], [a-z], [!a-z], [^a-z]; backslash quotes a character |
| (regex) | Whole-line standard-library Regex match |
| (escaped) | Exact match of a JSON string, including control characters |
| (no-eol) | The final output line has no terminating newline; follows any other suffix |
```mooncram
$ ./special.mbtx
"$ this is output" (escaped)
"[2]" (escaped)
"```" (escaped)
"\u001b[31mred\u001b[0m" (escaped)
"" (escaped)
final text (no-eol)
[3]
``````mooncram {"stream":"stderr","stdin":"./input.txt","env":{"MODE":"test"}}
$ ./cmd/main --invalid
unknown option: --invalid
[2]
```| Field | Values/default |
|---|---|
| stream | stdout (default), stderr, or merged |
| stdin | File path; default is immediate EOF; reopened for each case |
| env | String-to-string mapping, overriding inherited environment variables |
| target | wasm or native for local packages; overrides CLI target (default wasm) |
| timeout_ms | Positive 32-bit integer; overrides CLI timeout (default 60000 ms) |
Install
Download zipA simple and powerful testing toolkit for MoonBit CLI applications and Script
Dependencies