diff options
author | Ed Santiago <santiago@redhat.com> | 2021-11-22 10:54:22 -0700 |
---|---|---|
committer | Ed Santiago <santiago@redhat.com> | 2021-11-22 14:37:43 -0700 |
commit | 97ab9176f77c4fc9c4413afad4d2dcf5fad824b6 (patch) | |
tree | fc67f0c7dd3304489f89fd58742d3c46431eb44a /test/e2e/remove-betrue | |
parent | 1bfbb28b0365790552483b961b4bd48a69dd8070 (diff) | |
download | podman-97ab9176f77c4fc9c4413afad4d2dcf5fad824b6.tar.gz podman-97ab9176f77c4fc9c4413afad4d2dcf5fad824b6.tar.bz2 podman-97ab9176f77c4fc9c4413afad4d2dcf5fad824b6.zip |
e2e tests: clean up antihelpful BeTrue()s
Many ginkgo tests have been written to use this evil form:
GrepString("foo")
Expect(that to BeTrue())
...which yields horrible useless messages on failure:
false is not true
Identify those (automatically, via script) and convert to:
Expect(output to ContainSubstring("foo"))
...which yields:
"this output" does not contain substring "foo"
There are still many BeTrue()s left. This is just a start.
This is commit 1 of 2. It includes the script I used, and
all changes to *.go are those computed by the script.
Commit 2 will apply some manual fixes.
Signed-off-by: Ed Santiago <santiago@redhat.com>
Diffstat (limited to 'test/e2e/remove-betrue')
-rwxr-xr-x | test/e2e/remove-betrue | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/test/e2e/remove-betrue b/test/e2e/remove-betrue new file mode 100755 index 000000000..dd56ca818 --- /dev/null +++ b/test/e2e/remove-betrue @@ -0,0 +1,48 @@ +#!/usr/bin/perl +# +# one-shot script for #12387 +# +use warnings; +use strict; +use File::Basename qw(dirname); + +chdir(dirname($0)); + +for my $f (glob('*_test.go')) { + my ($indent, $okvar, $sessionvar, $s); + my $prev = ''; + + open my $fh_in, '<', $f or die; + open my $fh_out, '>', "$f.tmp.$$" or die; + while (<$fh_in>) { + if (/^(\s+)(\S+),\s+_\s+:?=\s+(\S+)\.GrepString\((.*)\)/) { + print { $fh_out } $prev; + $prev = $_; + ($indent, $okvar, $sessionvar, $s) = ($1, $2, $3, $4); + next; + } + elsif ($okvar && /^\s+Expect\($okvar\)\.(Should|To)\(BeTrue\(\)\)\s*$/) { + print { $fh_out} $indent, "Expect($sessionvar.OutputToString()).To(ContainSubstring($s))\n"; + $okvar = $sessionvar = $s = $prev = ''; + next; + } + else { + print { $fh_out } $prev; + $prev = $_; + $okvar = $sessionvar = $s = ''; + + # Handle other common cases + $prev =~ s{ +^ (\s+) Expect\((\S+)\.LineInOutputContains\((.*?)\)\)\.To\(BeTrue\(\)\) + }{${1}Expect($2.OutputToString()).To(ContainSubstring($3))}xx; + + $prev =~ s{ +^ (\s+) Expect\((\S+)\.LineInOutputStartsWith\((.*)\)\)\.To\(BeTrue\(\)\) + }{${1}Expect($2.OutputToStringArray()).To(ContainElement(HavePrefix($3)))}xx; + + } + } + print { $fh_out } $prev; + close $fh_out or die; + rename "$f.tmp.$$" => "$f" or die; +} |