SamirTalwar / smoke

Runs tests against anything, using command-line arguments, STDIN, STDOUT and STDERR.
MIT License
88 stars 10 forks source link

Support `contains:` for checking that output matches a substring. #46

Closed SamirTalwar closed 4 years ago

SamirTalwar commented 4 years ago

This applies to STDOUT, STDERR, and files.

From the update to the README:

We don't always want to check the full output; sometimes checking that it contains a given substring is more useful. We can use the contains: operator to specify this:

tests:
  # ...
  - name: big multiplication
    stdin: |
      961748927 * 982451653
    stdout:
      contains: "1021"

Note that we don't use | here, as we don't want to capture the trailing newline, which would make this test fail. Instead we use quotes around the value to ensure that the YAML parser treats it as a string, not a number.

You can also use equals: to explicitly specify that we're checking equality, though this is the default.

Closes #36.