Skip to content

fix minor unreachable code caused by t.Fatal#3574

Merged
ale-linux merged 1 commit intohyperledger:mainfrom
Abirdcfly:main
Aug 8, 2022
Merged

fix minor unreachable code caused by t.Fatal#3574
ale-linux merged 1 commit intohyperledger:mainfrom
Abirdcfly:main

Conversation

@Abirdcfly
Copy link
Contributor

Type of change

  • Test update

Description

t.Fatal or os.Exit will make the subsequent code unreachable.

https://pkg.go.dev/testing#T.Fatalf

Fatalf is equivalent to Logf followed by FailNow.

Additional details

see https://go.dev/play/p/I6MX-QOTC9n for t.Fatal example:

package main

import (
	"testing"
)

func TestLastIndex(t *testing.T) {
	t.Errorf("first line")
	t.Errorf("second line")
	t.Fatalf("t.Fatalf will cause exit")
	t.Fatalf("so this line cant reach")
}

/* output:
=== RUN   TestLastIndex
    prog.go:8: first line
    prog.go:9: second line
    prog.go:10: t.Fatalf will cause exit
--- FAIL: TestLastIndex (0.00s)
FAIL

Program exited.
*/

Related issues

Release Note

Signed-off-by: Abirdcfly <fp544037857@gmail.com>
@Abirdcfly Abirdcfly requested a review from a team as a code owner August 8, 2022 11:53
@ale-linux ale-linux enabled auto-merge (rebase) August 8, 2022 12:12
@ale-linux ale-linux merged commit d1e7785 into hyperledger:main Aug 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants