Task Definitions: None
Template Definitions: 'assert'
Batcher Defintions: None
Allows wrapping an existing task with an assertion of its target or dependency file contents.
expect-equals
(String): The source text of the target (or dep in the case of no target) to assert.expect-match
(String): Regular expression match to apply to the target source.expect-pattern
(String): Instead of exact string or regex, this only supports*
as matching any set of characters and\*
as a literal.task-template
(String): The template string to use for the task. Used to wrap templated tasks.task-template-options
(Dictionary): The template options to use for the task, whentask-template
is used above.
chompfile.toml
version = 0.1
extensions = ['[email protected]:assert']
[[task]]
name = 'test'
target = 'out.txt'
run = 'echo "Chomp Chomp" > out.txt'
template = 'assert'
[task.template-options]
expect-equals = 'Chomp Chomp'
expect-match = '\w+ \w+'
Where the task will fail with an assertion diff on failure (which isn't possible in the above example unless changing the echo "Chomp Chomp"
contents).
Support for asserting templated tasks is provided with the task-template
and task-template-options
template options.
When ejecting the assert template, ejection will entirely remove the assertion itself, leaving only the unasserted task.
Future additions to this extension might include:
- Supporting multiple output checks, for example with interpolation tasks.
- Supporting taking the expectation values from files instead of as a template option.
- If supporting using expectations in files, having the ability to generate these file expectations as well.
- It may make sense to treat ejection as a nicer form of the assertion task instead of removing the assertion entirely.