diff --git a/.github/workflows/go.yaml b/.github/workflows/go.yaml index 1d13532..82727e4 100644 --- a/.github/workflows/go.yaml +++ b/.github/workflows/go.yaml @@ -70,9 +70,10 @@ jobs: with: name: go-test-results path: | - ./go/ocr2/ocr2_decryptionplugin_coverage.txt + ./go/ocr2/decryptionplugin/ocr2_decryptionplugin_coverage.txt ./go/tdh2/tdh_coverage.txt + sonar-scan: name: SonarQube needs: [golangci-lint, build-and-test] diff --git a/go/ocr2/decryptionplugin/fail_test.go b/go/ocr2/decryptionplugin/fail_test.go new file mode 100644 index 0000000..149fd0b --- /dev/null +++ b/go/ocr2/decryptionplugin/fail_test.go @@ -0,0 +1,39 @@ +package main + +import ( + "errors" + "os" + "sync" + "testing" +) + +func TestFail(t *testing.T) { + if testing.Short() { + t.Skip() + } + t.Fatal("fake failure") +} + +func TestRace(t *testing.T) { + var v int + var wg sync.WaitGroup + wg.Add(100) + for i := 0; i < 100; i++ { + go func() { + defer wg.Done() + v++ + v-- + }() + } + wg.Wait() + t.Log(v) +} + +func TestLint(t *testing.T) { + const ALL_CAPS = 10 // should be AllCaps + err := os.ErrNotExist + if err == os.ErrNotExist { // should use errors.Is + err := errors.New("fake error") // shadowed variable + t.Log(err) + } +} diff --git a/go/tdh2/fail_test.go b/go/tdh2/fail_test.go new file mode 100644 index 0000000..149fd0b --- /dev/null +++ b/go/tdh2/fail_test.go @@ -0,0 +1,39 @@ +package main + +import ( + "errors" + "os" + "sync" + "testing" +) + +func TestFail(t *testing.T) { + if testing.Short() { + t.Skip() + } + t.Fatal("fake failure") +} + +func TestRace(t *testing.T) { + var v int + var wg sync.WaitGroup + wg.Add(100) + for i := 0; i < 100; i++ { + go func() { + defer wg.Done() + v++ + v-- + }() + } + wg.Wait() + t.Log(v) +} + +func TestLint(t *testing.T) { + const ALL_CAPS = 10 // should be AllCaps + err := os.ErrNotExist + if err == os.ErrNotExist { // should use errors.Is + err := errors.New("fake error") // shadowed variable + t.Log(err) + } +}