Skip to content

Commit

Permalink
raft,rafttest: print panic arguments correctly
Browse files Browse the repository at this point in the history
This commit makes the testing loggers print Panic and Fatal agruments before
redirecting them to the panic() call. Previously they would be displayed in a
non-human-readable way, as something like:

  panic: ([]interface {}) 0x1400000eb88

Signed-off-by: Pavel Kalinnikov <[email protected]>
  • Loading branch information
pav-kv committed Mar 9, 2023
1 parent d0fb0cd commit 574d2f1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions node_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (l *nodeTestHarness) Warningf(format string, v ...interface{}) {

func (l *nodeTestHarness) Fatal(v ...interface{}) {
l.t.Error(v...)
panic(v)
panic(fmt.Sprint(v...))
}

func (l *nodeTestHarness) Fatalf(format string, v ...interface{}) {
Expand All @@ -70,7 +70,7 @@ func (l *nodeTestHarness) Fatalf(format string, v ...interface{}) {

func (l *nodeTestHarness) Panic(v ...interface{}) {
l.t.Log(v...)
panic(v)
panic(fmt.Sprint(v...))
}

func (l *nodeTestHarness) Panicf(format string, v ...interface{}) {
Expand Down
4 changes: 2 additions & 2 deletions rafttest/interaction_env_logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (l *RedirectLogger) Errorf(format string, v ...interface{}) {

func (l *RedirectLogger) Fatal(v ...interface{}) {
l.print(4, v...)
panic(v)
panic(fmt.Sprint(v...))
}

func (l *RedirectLogger) Fatalf(format string, v ...interface{}) {
Expand All @@ -92,7 +92,7 @@ func (l *RedirectLogger) Fatalf(format string, v ...interface{}) {

func (l *RedirectLogger) Panic(v ...interface{}) {
l.print(4, v...)
panic(v)
panic(fmt.Sprint(v...))
}

func (l *RedirectLogger) Panicf(format string, v ...interface{}) {
Expand Down

0 comments on commit 574d2f1

Please sign in to comment.