Closed wolframkriesing closed 4 years ago
That sounds like a pretty good proposal to me. I think we can do that.
What do you think the output should look like on a test failure? Currently we use git diff --no-index
to produce something like:
name
input: 12345
stdout: @@ -1 +1 @@
-12345
+67890
Obviously a diff won't be useful when we're looking for a substring. Perhaps it would be appropriate to go back to the older style of Smoke output, with something like:
name
input: 12345
stdout:
actual:
this string contains the numbers 23456 and none other
expected:
contains:
12345
What do you think?
EDIT: Turns out Smoke doesn't strip newlines. I was thinking of Smoke v1.0. I guess I fixed that.
FYI, |
is part of standard YAML, and tells the YAML parser to parse all indented content as multiline text. So you could also use contains: "12345\n"
if you wanted.
I find it useful when dealing with trailing newlines, large amounts of text, or if you want to avoid quoting text that might appear as some other datatype (e.g. null
, true
, 12345
, etc.). For consistency, I tend to use it in all situations when writing Smoke tests.
These are all equivalent (tested with yq
):
stuff:
contents: |
this paragraph is
made up of multiple lines
also a haiku
and:
stuff:
contents: "this paragraph is\nmade up of multiple lines\nalso a haiku\n"
and also:
{
"stuff": {
"contents": "this paragraph is\nmade up of multiple lines\nalso a haiku\n"
}
}
I would love to do something like this
Currently, I had not found a way to assert for part of the string. In the docs I only saw how to match all of stdout.
PS: what is the
|
at the end ofcontains: |
, is this yaml standard? You use it in many places but I didnt find an explanation. Thanks