Skip to content

Commit 37d4d28

Browse files
committed
Enhance comparators debugging info
Signed-off-by: apostasie <[email protected]>
1 parent 0896078 commit 37d4d28

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

mod/tigron/expect/comparators.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package expect
1818

1919
import (
20+
"encoding/hex"
2021
"fmt"
2122
"regexp"
2223
"strings"
@@ -45,7 +46,8 @@ func Contains(compare string) test.Comparator {
4546
return func(stdout, info string, t *testing.T) {
4647
t.Helper()
4748
assertive.Check(t, strings.Contains(stdout, compare),
48-
fmt.Sprintf("Output does not contain: %q", compare)+info)
49+
fmt.Sprintf("Output does not contain: %q", compare),
50+
info)
4951
}
5052
}
5153

@@ -56,7 +58,7 @@ func DoesNotContain(compare string) test.Comparator {
5658
return func(stdout, info string, t *testing.T) {
5759
t.Helper()
5860
assertive.Check(t, !strings.Contains(stdout, compare),
59-
fmt.Sprintf("Output should not contain: %q", compare)+info)
61+
fmt.Sprintf("Output should not contain: %q", compare), info)
6062
}
6163
}
6264

@@ -65,10 +67,14 @@ func Equals(compare string) test.Comparator {
6567
//nolint:thelper
6668
return func(stdout, info string, t *testing.T) {
6769
t.Helper()
70+
71+
hexdump := hex.Dump([]byte(stdout))
6872
assertive.Check(
6973
t,
7074
compare == stdout,
71-
fmt.Sprintf("Output is not equal to: %q", compare)+info,
75+
fmt.Sprintf("Output is not equal to: %q", compare),
76+
"\n"+hexdump,
77+
info,
7278
)
7379
}
7480
}

mod/tigron/expect/consts.go renamed to mod/tigron/expect/exit.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@ const (
2121
ExitCodeSuccess = 0
2222
// ExitCodeGenericFail will verify that the command ran and exited with a non-zero error code.
2323
// This does NOT include timeouts, cancellation, or signals.
24-
ExitCodeGenericFail = -1
24+
ExitCodeGenericFail = -10
2525
// ExitCodeNoCheck does not enforce any check at all on the function.
26-
ExitCodeNoCheck = -2
26+
ExitCodeNoCheck = -11
2727
// ExitCodeTimeout verifies that the command was cancelled on timeout.
28-
ExitCodeTimeout = -3
28+
ExitCodeTimeout = -12
29+
// ExitCodeSignaled verifies that the command has been terminated by a signal.
30+
ExitCodeSignaled = -13
31+
// ExitCodeCancelled = -14.
2932
)

0 commit comments

Comments
 (0)