Skip to content

MongooseMoo/moo-conformance-tests

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MOO Conformance Tests

A portable conformance test suite for MOO (MUD Object Oriented) language implementations. Tests are defined in YAML format and can be run against any MOO server via TCP socket.

Features

  • YAML-based tests: Declarative, easy to read and write
  • Socket transport: Tests any MOO server over TCP
  • pytest integration: Standard Python testing workflow
  • pip installable: pip install moo-conformance-tests
  • Bundled database: Includes Test.db for toaststunt compatibility

Quick Start

Install

pip install moo-conformance-tests
# or with uv
uv add moo-conformance-tests

Run Tests

  1. Start your MOO server on port 7777:

    # Example with toaststunt
    ./moo Test.db Test.out.db 7777
  2. Run the conformance tests:

    moo-conformance --moo-port=7777
    
    # or via pytest directly
    pytest --pyargs moo_conformance --moo-port=7777

Run Without Installing

# Run directly from PyPI (no install needed)
uv tool run moo-conformance-tests --moo-port=7777

# Or from a local checkout
uv run moo-conformance --moo-port=7777
  1. Lint for duplicate test definitions:

    moo-lint-duplicates
    # or from source
    uv run moo-lint-duplicates

    Auto-clean duplicate content definitions:

    # keep most descriptive test in each duplicate group (default strategy)
    moo-lint-duplicates --only content --fix-content
    
    # deterministic alternatives
    moo-lint-duplicates --only content --fix-content --keep-strategy first
    moo-lint-duplicates --only content --fix-content --keep-strategy last
    moo-lint-duplicates --only content --fix-content --keep-strategy longest-name

    Duplicate matching is exact structural matching after normalization (dictionary key order normalized; name ignored; description ignored by default). It is not fuzzy semantic equivalence.

    Semantic-lite duplicate checks (uses moo-interp parser/compiler):

    # run semantic check only
    moo-lint-duplicates --only semantic
    
    # run names/content checks plus semantic check
    moo-lint-duplicates --semantic
    
    # auto-clean semantic duplicates
    moo-lint-duplicates --only semantic --fix-semantic

    Semantic mode is bytecode-equivalence based for runnable MOO snippets (code, statement, run fields). It is stronger than text matching, but still not full program-equivalence.

From Source

git clone https://github.com/MongooseMoo/moo-conformance-tests
cd moo-conformance-tests
uv sync
uv run pytest tests/ --moo-port=7777

Managed Server Mode

Instead of starting a server yourself, pass --server-command and the tool handles the lifecycle automatically. Use {port} and {db} placeholders in the command template:

# Toaststunt (positional args: db logfile port)
moo-conformance --server-command "./moo {db} /dev/null {port}" -v

# Barn (flag args)
moo-conformance --server-command "./barn -db {db} -port {port}" -v

# With a specific port
moo-conformance --server-command "./moo {db} /dev/null {port}" --moo-port 9898 -v

# With a custom database file
moo-conformance --server-command "./moo {db} /dev/null {port}" --server-db ./MyTest.db -v

The tool copies the database to a temp directory (servers write checkpoints alongside it), starts the server, waits for it to accept connections, runs the tests, and cleans everything up on exit. When --moo-port is omitted, a free port is selected automatically.

Command Line Options

Option Default Description
--moo-host localhost MOO server hostname
--moo-port 7777 MOO server port
--server-command (none) Shell command to start a MOO server ({port} and {db} placeholders)
--server-db bundled Test.db Database file for managed server

Test Categories

Tests are organized by category:

Directory Description
basic/ Expression tests (arithmetic, strings, lists)
builtins/ Builtin function tests
language/ Language construct tests (loops, equality)
server/ Server feature tests
objects/ Object system tests
features/ Advanced feature tests

Run specific categories:

# Run only arithmetic tests
moo-conformance -k "arithmetic" --moo-port=7777

# Run all builtin tests
moo-conformance -k "builtins" --moo-port=7777

Running Against Toaststunt

The test suite was developed against toaststunt, the reference MOO implementation.

# Start toaststunt
cd /path/to/toaststunt
./moo Test.db Test.out.db 9898

# Run tests
moo-conformance --moo-port=9898 -v

See docs/TOASTSTUNT.md for detailed setup instructions.

YAML Test Format

Tests are defined in YAML files:

name: arithmetic
description: Basic arithmetic operations

tests:
  - name: addition
    code: "1 + 1"
    expect:
      value: 2

  - name: division_by_zero
    code: "1 / 0"
    expect:
      error: E_DIV

  - name: random_range
    code: "random(10)"
    expect:
      range: [1, 10]

See docs/YAML_SCHEMA.md for the full schema.

Programmatic Usage

from moo_conformance import SocketTransport, YamlTestRunner, discover_yaml_tests

# Connect to server
transport = SocketTransport("localhost", 7777)
transport.connect("wizard")

# Execute code directly
result = transport.execute("1 + 1")
print(result.value)  # 2

# Run all tests programmatically
runner = YamlTestRunner(transport)
for yaml_path, suite, test in discover_yaml_tests():
    runner.run_suite_setup(suite)
    runner.run_test(test)

Test Database

The package includes Test.db, a minimal MOO database for testing. Access it via:

from moo_conformance import get_db_path
db_path = get_db_path()

Contributing Tests

  1. Create a YAML file in the appropriate category
  2. Follow the schema in docs/YAML_SCHEMA.md
  3. Test against toaststunt to verify expected behavior
  4. Submit a pull request

See docs/CONVERTING.md for converting tests from other formats.

License

MIT License - see LICENSE for details.

Related Projects

About

Conformance test suite for MOO language implementations

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages