cmd — run arbitrary commands

The cmd check runs arbitrary commands, waits for them to finish, and asserts that they produced certain output or exited with the correct status code.

This lets you test for things without having to write the tests in Specsheet. For example, if you want to test if a package is installed in a package manager that Specsheet doesn’t support, you could run the command to list its installed packages, and assert that the output contains the name of the package you want to see.

It also lets you test command-line programs during development. For more on this use case, see the Testing a Command-Line Program guide.


Check that running a command produces certain output:

shell = 'git config --global core.excludesfile'
stdout = { regex = '^~/\.gitignore_global' }

Check that a command exits with a certain status:

shell = 'nomad status'
status = 0

Shell commands and variables

Be very careful when using cmd with variables — the contents of a variable get placed into the shell command to run without being escaped.

You can check whether the process exited successfully, with status 0, or whether it exited with some other error code.

You can match on a regex or on a plain string.

List of parameters

environmenttableMapping of environment variable names to values, to be set for the process.
shellstringThe shell command to run.
statusnumberThe command’s expected exit status.
stdoutcontentThe content of the process’s standard output stream.
stderrcontentThe content of the process’s standard error stream.