@@ -13,13 +13,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
13
See the License for the specific language governing permissions and
14
14
limitations under the License.
15
15
*/
16
- package sanity
16
+ package main
17
17
18
18
import (
19
19
"flag"
20
20
"fmt"
21
21
"os"
22
- "testing"
23
22
"time"
24
23
25
24
"github.com/kubernetes-csi/csi-test/v3/pkg/sanity"
@@ -31,7 +30,6 @@ const (
31
30
32
31
var (
33
32
VERSION = "(dev)"
34
- config = sanity .NewTestConfig ()
35
33
)
36
34
37
35
func stringVar (p * string , name string , usage string ) {
@@ -54,9 +52,20 @@ func durationVar(p *time.Duration, name string, usage string) {
54
52
flag .DurationVar (p , prefix + name , * p , usage )
55
53
}
56
54
57
- func TestMain (m * testing.M ) {
55
+ type testing struct {
56
+ result int
57
+ }
58
+
59
+ func (t * testing ) Fail () {
60
+ t .result = 1
61
+ }
62
+
63
+ func main () {
58
64
version := flag .Bool ("version" , false , "print version of this program" )
59
65
66
+ // Get configuration with defaults.
67
+ config := sanity .NewTestConfig ()
68
+
60
69
// Support overriding the default configuration via flags.
61
70
stringVar (& config .Address , "endpoint" , "CSI endpoint" )
62
71
stringVar (& config .ControllerAddress , "controllerendpoint" , "CSI controller endpoint" )
@@ -85,9 +94,8 @@ func TestMain(m *testing.M) {
85
94
fmt .Printf ("--%sendpoint must be provided with an CSI endpoint\n " , prefix )
86
95
os .Exit (1 )
87
96
}
88
- os .Exit (m .Run ())
89
- }
90
97
91
- func TestSanity (t * testing.T ) {
92
- sanity .Test (t , config )
98
+ t := testing {}
99
+ sanity .Test (& t , config )
100
+ os .Exit (t .result )
93
101
}
0 commit comments