Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix minor unreachable code caused by t.Fatal #3574

Merged
merged 1 commit into from
Aug 8, 2022

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