Skip to content

Commit ffba6e0

Browse files
committed
CI tester
This draft adds a test file designed to flag the unit tests, the race detector, and the linter, in order to ensure that they are all operating correctly.
1 parent 579f5cf commit ffba6e0

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package main
2+
3+
import (
4+
"errors"
5+
"os"
6+
"sync"
7+
"testing"
8+
)
9+
10+
func TestFail(t *testing.T) {
11+
if testing.Short() {
12+
t.Skip()
13+
}
14+
t.Fatal("fake failure")
15+
}
16+
17+
func TestRace(t *testing.T) {
18+
var v int
19+
var wg sync.WaitGroup
20+
wg.Add(100)
21+
for i := 0; i < 100; i++ {
22+
go func() {
23+
defer wg.Done()
24+
v++
25+
v--
26+
}()
27+
}
28+
wg.Wait()
29+
t.Log(v)
30+
}
31+
32+
func TestLint(t *testing.T) {
33+
const ALL_CAPS = 10 // should be AllCaps
34+
err := os.ErrNotExist
35+
if err == os.ErrNotExist { // should use errors.Is
36+
err := errors.New("fake error") // shadowed variable
37+
t.Log(err)
38+
}
39+
}

0 commit comments

Comments
 (0)