TOML test format¶
Test cases and property specs are defined in TOML. Task files describe actions to execute; property files describe mathematical laws to validate by sampling.
Task files¶
Task files define a sequence of actions to execute through an adapter.
[meta]
name = "DefTensor+Contract round-trip"
description = "Define a rank-2 tensor and contract it"
[[tasks]]
action = "DefTensor"
[tasks.payload]
name = "T"
indices = ["a", "b"]
[[tasks]]
action = "Contract"
[tasks.payload]
expr = "T[a, b] * g[-a, -b]"
Structure¶
[meta]— optional metadata (name, description)[[tasks]]— one or more task entries, each with:action(required) — the operation name[tasks.payload](optional) — key-value pairs passed to the adapter
Loading¶
from pathlib import Path
from elegua.runner import load_toml_tasks
tasks = load_toml_tasks(Path("tests/fixtures/tracer.toml"))
for task in tasks:
print(f"{task.action}: {task.payload}")
Validation¶
- Missing
taskskey raisesSchemaError - Missing
actionfield on any task raisesSchemaErrorwith the task index - Empty
actionstring is treated as missing
SchemaError is a subclass of both EleguaError and ValueError, so except ValueError catches it too.
Property files¶
Property files define mathematical laws to validate via sampling. See property testing for the full format.