A simple and powerful testing toolkit for MoonBit CLI applications and Script
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 user/foo
$ export NAME='Moon Bit'
$ ./hello.mbtx "${NAME}"
Hello, Moon Bit!
$ cmd/main --version
my-cli * (glob)
$ ./producer.mbtx|cmd/filter|./consumer.mbtx
filtered output
``````mooncram-import
moongrep : moonbit-community/moongrep@0.3.5
```
```mooncram
$ moongrep --version
* (glob)
```| Suffix | Meaning |
|---|---|
| none | 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]
```