Skip to content

Commit 05b5772

Browse files
author
Zhou Hao
authored
Merge pull request #645 from kinvolk/dongsu/correct-fail-func
validation: use t.Fail when checking for main test errors
2 parents fef2a70 + fab1de6 commit 05b5772

File tree

9 files changed

+20
-15
lines changed

9 files changed

+20
-15
lines changed

Diff for: validation/config_updates_without_affect/config_updates_without_affect.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func main() {
8282
err = r.Delete()
8383
}
8484
if err != nil {
85-
util.Fatal(err)
85+
t.Fail(err.Error())
8686
}
8787

8888
t.AutoPlan()

Diff for: validation/delete/delete.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func main() {
8585
util.WaitingForStatus(testRuntime, util.LifecycleStatusStopped, time.Second*10, time.Second*1)
8686
err = testRuntime.Delete()
8787
if err != nil {
88-
util.Fatal(err)
88+
t.Fail(err.Error())
8989
}
9090
}
9191
}

Diff for: validation/hooks_stdin/hooks_stdin.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ func main() {
140140

141141
err = util.RuntimeLifecycleValidate(config)
142142
if err != nil {
143-
util.Fatal(err)
143+
t.Fail(err.Error())
144144
}
145145

146146
expectedState := rspecs.State{

Diff for: validation/hostname/hostname.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func main() {
4040

4141
for _, h := range hostnames {
4242
if err := testHostname(t, h); err != nil {
43-
util.Fatal(err)
43+
t.Fail(err.Error())
4444
}
4545
}
4646
}

Diff for: validation/kill_no_effect/kill_no_effect.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func main() {
5757
}
5858
err = util.RuntimeLifecycleValidate(config)
5959
if err != nil && err != targetErr {
60-
util.Fatal(err)
60+
t.Fail(err.Error())
6161
} else {
6262
util.SpecErrorOK(t, err == nil, targetErr, nil)
6363
}

Diff for: validation/killsig/killsig.go

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ func main() {
3131
containerID := uuid.NewV4().String()
3232
sigConfig, err := util.GetDefaultGenerator()
3333
if err != nil {
34+
os.RemoveAll(bundleDir)
3435
util.Fatal(err)
3536
}
3637
rootDir := filepath.Join(bundleDir, sigConfig.Spec().Root.Path)

Diff for: validation/linux_ns_itype/linux_ns_itype.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func main() {
124124

125125
err := testNamespaceInheritType(t)
126126
if err != nil {
127-
util.Fatal(err)
127+
t.Fail(err.Error())
128128
}
129129

130130
t.AutoPlan()

Diff for: validation/linux_ns_nopath/linux_ns_nopath.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ func main() {
125125

126126
err := testNamespaceNoPath(t)
127127
if err != nil {
128-
util.Fatal(err)
128+
t.Fail(err.Error())
129129
}
130130

131131
t.AutoPlan()

Diff for: validation/start/start.go

+12-8
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
func main() {
1818
t := tap.New()
1919
t.Header(0)
20+
defer t.AutoPlan()
2021

2122
bundleDir, err := util.PrepareBundle()
2223
if err != nil {
@@ -54,7 +55,8 @@ func main() {
5455

5556
err = r.Create()
5657
if err != nil {
57-
util.Fatal(err)
58+
t.Fail(err.Error())
59+
return
5860
}
5961
_, err = os.Stat(output)
6062
// check the existence of the output file
@@ -67,7 +69,8 @@ func main() {
6769
} else {
6870
err = util.WaitingForStatus(r, util.LifecycleStatusStopped, time.Second*10, time.Second*1)
6971
if err != nil {
70-
util.Fatal(err)
72+
t.Fail(err.Error())
73+
return
7174
}
7275
outputData, outputErr := ioutil.ReadFile(output)
7376
// check the output
@@ -81,7 +84,8 @@ func main() {
8184

8285
err = util.WaitingForStatus(r, util.LifecycleStatusStopped, time.Second*10, time.Second*1)
8386
if err != nil {
84-
util.Fatal(err)
87+
t.Fail(err.Error())
88+
return
8589
}
8690

8791
outputData, outputErr := ioutil.ReadFile(output)
@@ -90,7 +94,8 @@ func main() {
9094

9195
err = r.Delete()
9296
if err != nil {
93-
util.Fatal(err)
97+
t.Fail(err.Error())
98+
return
9499
}
95100

96101
g.Spec().Process = nil
@@ -100,7 +105,8 @@ func main() {
100105
}
101106
err = r.Create()
102107
if err != nil {
103-
util.Fatal(err)
108+
t.Fail(err.Error())
109+
return
104110
}
105111

106112
err = r.Start()
@@ -110,8 +116,6 @@ func main() {
110116
err = r.Delete()
111117
}
112118
if err != nil {
113-
util.Fatal(err)
119+
t.Fail(err.Error())
114120
}
115-
116-
t.AutoPlan()
117121
}

0 commit comments

Comments
 (0)