2 releases
| 0.1.2 | Jun 20, 2025 |
|---|---|
| 0.1.1 | Jun 20, 2025 |
#1750 in Data structures
Used in regex-mumu
53KB
1K
SLoC
mumu-test
Test suite plugin for the Lava language
Overview
mumu-test is a native plugin for the Lava/MuMu scripting language providing a full-featured test suite runner, test description framework (describe/it), file assertions, error checks, and test helpers for robust automated testing of Lava plugins, scripts, and applications.
- Write tests in Lava/MuMu using familiar constructs
- Get pretty console reports (with color and clipboard debugging)
- Assert deep equality, error conditions, and file state
- Create test files and temp data easily from Lava/MuMu code
Features
describe/it: Organize tests in suites- Expectations:
expect_equal,expect_not_equal,prop_equals,has_key,test:expect_error - File assertions:
file_contents_equal,file_contents_not_equal,file_contents_length_equal - Helpers:
test:lorem_file(create lorem test files),test:unique_filename - Batch runner: Run all
tests/*.mufiles and see summaries - Clipboard debugging: Output of failing test files copied for quick pasting
- JSON output: Suite/test results as JSON lines (for CI/automation)
Installation
Build the plugin as a shared library (.so):
make
make install
This copies libmumutest.so to /usr/local/lib/, as expected by the Lava/MuMu runtime.
Usage
-
Enable the plugin in Lava/MuMu:
> extend("test") -
Write a test file (e.g.,
tests/hello_test.mu):describe("Sample suite", fn() { it("should add numbers", fn() { expect_equal(1 + 1, 2) }) it("should fail gracefully", fn() { expect_not_equal("a", "b") }) it("should throw error", fn() { test:expect_error(fn() { error("bad wolf") }, "wolf") }) }) -
Run all tests from CLI:
lava -e 'test:all(fn(pass) { log(pass) })'- Or run a single file:
lava tests/hello_test.mu
- Or run a single file:
API
- describe(suite_name: string, fn)
- it(test_name: string, fn)
- expect_equal(actual, expected)
- expect_not_equal(actual, expected)
- has_key(keyed_array, key)
- prop_equals(keyed_array, key, expected_value)
- test:expect_error(fn, [optional substring])
- file_contents_equal(filename, expected_string)
- file_contents_not_equal(filename, unexpected_string)
- file_contents_length_equal(filename, expected_len)
- test:lorem_file(n_chars)
- test:unique_filename()
- test:all([opts], callback)
- test:run(filename, callback)
See the source for full parameter details and advanced options.
License
Dual-licensed under MIT or Apache-2.0 (see LICENSE).
© 2025 Tom Fotheringham and contributors
Links
Dependencies
~6–25MB
~326K SLoC