test-mumu

Crates.iotest-mumu
lib.rstest-mumu
version0.1.4
created_at2025-08-15 18:04:09.738778+00
updated_at2025-08-16 16:34:54.300945+00
descriptionTest suite plugin for the Lava language
homepagehttps://lava.nu11.uk
repositoryhttps://gitlab.com/tofo/mumu-test
max_upload_size
id1797257
size207,350
(justifiedmumu)

documentation

README

mumu-test

Test suite plugin for the Lava language
MIT OR Apache-2.0 licensed


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/*.mu files 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

  1. Enable the plugin in Lava/MuMu:

    > extend("test")
    
  2. 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")
      })
    })
    
  3. Run all tests from CLI:

    lava -e 'test:all(fn(pass) { log(pass) })'
    
    • Or run a single file:
      lava tests/hello_test.mu
      

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

Commit count: 0

cargo fmt