-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathgoreal_executor_test.go
81 lines (73 loc) · 1.78 KB
/
goreal_executor_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package gobench
import (
"strings"
"testing"
"time"
)
func shuffledBugs() []Bug {
var result []Bug
var bugnum int
idxes := make(map[string]int)
bugs := GoBenchBugSet.ListByTypes(GoRealNonBlocking | GoRealBlocking)
bugset := NewBugSet(bugs)
bugnum = len(bugs)
for bugnum > 0 {
for project, bugs := range bugset.Groups() {
if idxes[project] < len(bugs) {
result = append(result, bugs[idxes[project]].Fork())
idxes[project] += 1
bugnum -= 1
}
}
}
return result
}
func testBuildAndRunForBug(bug Bug, t *testing.T) {
e := NewDefaultExecutor(ExecBugConfig{
ExecEnvConfig: ExecEnvConfig{
ClearDirs: true,
Count: 1,
Timeout: 5 * time.Second,
Repeat: 2,
},
Bug: bug,
}).(*GoRealExecuter)
e.Build()
if _, exist := FindImage(e.ImageName); !exist {
t.Errorf("Expect %v to be exist but not found.", e.ImageName)
}
for i := 0; i < 2; i++ {
e.Run()
}
e.Done()
result := e.GetResult()
if _, exist := FindContainer(e.ContainerName); exist {
t.Errorf("Expect %v to be exited and auto-removed but still found.", e.ContainerName)
}
output := result.log()
if len(output) == 0 || !strings.Contains(output, "GoBench") {
t.Errorf("Expect a valid output. But found '%s'", output)
}
}
func TestGoRealBasic(t *testing.T) {
t.Skip()
bug := GoReal("hugo_5379")
NewGoRealBugConfig(bug, bug.gobenchCfg).UpdateDockerfile()
testBuildAndRunForBug(bug, t)
}
func TestGoRealImageBuildAndRun(t *testing.T) {
for _, bug := range shuffledBugs() {
func(bug Bug) {
t.Run(bug.ID, func(t *testing.T) {
t.Parallel()
defer func() {
if err := recover(); err != nil {
t.Errorf("%s is failed: %v", bug.ID, err)
}
}()
NewGoRealBugConfig(bug, bug.gobenchCfg).UpdateDockerfile()
// testBuildAndRunForBug(bug, t)
})
}(bug)
}
}