craftos_test
Run *.test.lua files in fresh ComputerCraft emulators to test Lua programs with ccunit, returning pass counts, failures, and error lines.
Instructions
Run *.test.lua files. Inside a test file use the global ccunit: test(name, fn [, {timeout}]), eq, neq, near, contains, truthy, raises(fn, pattern), skip, and run(program, {seconds|script, args}) / screen(monitor?) / touch(monitor, x, y) to drive a program and read its screens (craftos_help {topic:"ccunit"}). Each file runs in its own fresh computer; peripherals can be attached with "monitors". timeoutMs is per file and covers copying the workspace; a file that hangs keeps the tests it finished and names the one it was in. The reply gives each file its status, a count of passing tests (named too in runs of up to 50 tests), and every failing test with its error and line. The computer gets a copy of the workspace (without .git, node_modules, .runtime and what .gitignore ignores); for a big workspace give world.deploy to copy only some folders.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "craftos_test"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| paths | No | Files or directories; empty runs every *.test.lua. | |
| world | No | The world around the computer (an object). Fields: addons, version, simProgram, craftosPcApis, motd, players, host, interacting, autoApprove, economyAvailable, holdInteraction, vhcctweaks, economyDelayTicks, gearPowerAvailable, identifyAvailable, internalErrors, vhccStore, linkLatency, computerId, kind, advanced, terminal, config, position, cobaltSpeed, label, deploy, peripherals, environment, entities, ap, mekanism, turtle, disks, blocks, fills, ground, items, gameRules, turtleConfig, spawnProtection, worldBorder, loadedChunks, unloadedChunks, nextDiskId, gameData, seed; e.g. {"peripherals":[{"name":"chest_0","type":"minecraft:chest","size":27}],"deploy":[{"from":"src"}]}. world.deploy picks which workspace folders or files go on the computer, and where ([{"from":"src","to":"lib"}]), instead of a copy of the whole workspace. Every field with its options: craftos_help {topic:"world"} (or the craftos://schema/world resource). Checked before boot: a wrong key or peripheral type comes back as an error with a suggestion. | |
| budgetMs | No | Real time for the whole call (default 10 min). When it runs out, running files stop keeping their finished tests, and notRun lists the rest. | |
| monitors | No | ||
| timeScale | No | Virtual clock speed. 10 makes sleep(), os.clock() and os.epoch() run 10x faster than real time, so slow scripts finish quickly. timeoutMs stays in real time. | |
| timeoutMs | No | ||
| worldFile | No | A saved world: a name in the worlds folder (e.g. "advanced-peripherals-demo") or a workspace path to a .json file (e.g. "door.world.json"). Fields in `world` override it. |