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 some unreachable code #1068

Merged
merged 1 commit into from
Aug 22, 2022
Merged

fix some unreachable code #1068

merged 1 commit into from
Aug 22, 2022

Conversation

Abirdcfly
Copy link
Contributor

Signed-off-by: Abirdcfly fp544037857@gmail.com

see https://go.dev/play/p/8fS-lKgH7Ze for example:

package main

import (
	"fmt"
	"testing"
	"time"
)

func TestA(t *testing.T) {
	errc := make(chan error, 1)
	donec := make(chan bool)

	go func() {
		defer close(donec)
		time.Sleep(time.Second)
		// time.Sleep(10 * time.Second) // or you want test with timeout.
	}()

	select {
	case <-donec:
		fmt.Println("just return")
		return
	case <-time.After(5 * time.Second):
		t.Fatal("timeout")
	}
	fmt.Println("cant reach!!!")
	e := fmt.Errorf("err one")
	errc <- e
	select {
	case err := <-errc:
		if err != nil {
			t.Fatalf("Error in handler: %v", err)
		}
	case <-time.After(2 * time.Second):
		t.Error("timeout waiting for handler to finish")
	}
}

/* 
// Output:
=== RUN   TestA
just return
--- PASS: TestA (1.00s)
PASS

Program exited.

// Output when uncommenting line 16 and letting the program time out:
=== RUN   TestA
    prog.go:24: timeout
--- FAIL: TestA (5.00s)
FAIL

Program exited.
*/

@kwanhur
Copy link
Contributor

kwanhur commented Aug 11, 2022

Maybe a little change per pull request will be better.

bfe_http2/server_test.go Outdated Show resolved Hide resolved
bfe_spdy/server_test.go Outdated Show resolved Hide resolved
@@ -234,7 +234,6 @@ func TestContextValueFetcher(t *testing.T) {
contextVal, err := hf.Fetch(req)
if err != nil {
t.Fatalf("Fetch(): %v", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议分为两次提交

  1. 第一次提交包含第1/4处修改
  2. 第二次提交包含第2/3处修改(可能涉及失败用例修复)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的。

  • 当前PR 包含 1、4处删除提交。
  • #1069 包含2、3处改动和可能的测试用例修复。

Signed-off-by: Abirdcfly <fp544037857@gmail.com>
@codecov-commenter
Copy link

Codecov Report

Merging #1068 (65235f2) into develop (4f81511) will decrease coverage by 0.03%.
The diff coverage is n/a.

@@             Coverage Diff             @@
##           develop    #1068      +/-   ##
===========================================
- Coverage    54.25%   54.22%   -0.04%     
===========================================
  Files          301      301              
  Lines        26602    26602              
===========================================
- Hits         14432    14424       -8     
- Misses       10509    10514       +5     
- Partials      1661     1664       +3     
Impacted Files Coverage Δ
bfe_websocket/server_conn.go 72.72% <0.00%> (-1.52%) ⬇️
bfe_spdy/frame_write.go 49.49% <0.00%> (-1.02%) ⬇️
bfe_spdy/server_conn.go 78.09% <0.00%> (-0.45%) ⬇️
bfe_http2/server.go 72.36% <0.00%> (-0.17%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@iyangsj iyangsj merged commit 21a14e7 into bfenetworks:develop Aug 22, 2022
@iyangsj
Copy link
Member

iyangsj commented Aug 22, 2022

@Abirdcfly 请回复微信号或添加微信好友 iyangsj, 将邀请加入开源BFE开发者群方便交流

supermario1990 pushed a commit to supermario1990/bfe that referenced this pull request Feb 20, 2024
Signed-off-by: Abirdcfly <fp544037857@gmail.com>
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.

4 participants