diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 90bb365..2d7b019 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -46,17 +46,16 @@ jobs: # html格式查看cover信息: https://blog.golang.org/cover # go test -covermode=count -coverprofile=count.out ./... && go tool cover -html=count.out # - # 从go1.20开始test子命令才支持-skip参数 + # 从go1.20开始test子命令才支持-skip参数,但是test的-skip和-race不能同时使用 run: | - nproc --all || sysctl -n hw.ncpu || grep -c ^processor /proc/cpuinfo || date + go vet ./... + nproc --all || sysctl -n hw.ncpu || grep -c ^processor /proc/cpuinfo || date if [[ "${{ matrix.go }}" < "1.20" ]]; then - time go test -cover -v ./... && echo done - time go test -race -cover -v ./... && echo done + time SKIP_TEST_SEND_MAIL=1 go test -cover -v ./... && echo done else time go test -skip "^TestSendMail$" -cover -v ./... && echo done - time go test -race -skip "^TestSendMail$" -skip "^TestDataRaceError$" -cover -v ./... && echo done fi - go vet ./... + time SKIP_TEST_SEND_MAIL=1 go test -race -cover -v ./... && echo done # golangci-lint run #golangci-lint run --enable-all 如果手动执行,需要提前下载golangci-lint # CI是通过golangci-lint.yml配置文件启用的 diff --git a/lockedmap/lockedmap_race_bad_practice_test.go b/lockedmap/lockedmap_race_bad_practice_test.go index 60d548d..1818f70 100644 --- a/lockedmap/lockedmap_race_bad_practice_test.go +++ b/lockedmap/lockedmap_race_bad_practice_test.go @@ -1,4 +1,4 @@ -//go:build go1.20 +//go:build !race package lockedmap diff --git a/mailx/mail_test.go b/mailx/mail_test.go index e83ea5b..acb1dd7 100644 --- a/mailx/mail_test.go +++ b/mailx/mail_test.go @@ -1,10 +1,14 @@ package mailx import ( + "os" "testing" ) func TestSendMail(t *testing.T) { + if os.Getenv("SKIP_TEST_SEND_MAIL") != "" { + t.Skip("skip test send mail") + } mail := NewSMTPMail("user@qq.com", "password", "smtp.qq.com", 587) receivers := []string{"user@163.com"} body := `