hs-test: added filenames to test names
- It is now possible to only run tests that are in a certain file
Type: test
Change-Id: I41665dd2bc0942c283be36a5af3e560fd65e9d03
Signed-off-by: Adrian Villin <avillin@cisco.com>
diff --git a/extras/hs-test/suite_ns_test.go b/extras/hs-test/suite_ns_test.go
index 7bdb90b..b4fa771 100644
--- a/extras/hs-test/suite_ns_test.go
+++ b/extras/hs-test/suite_ns_test.go
@@ -15,18 +15,18 @@
serverInterface = "hsrvvpp"
)
-var nsTests = []func(s *NsSuite){}
-var nsSoloTests = []func(s *NsSuite){}
+var nsTests = map[string][]func(s *NsSuite){}
+var nsSoloTests = map[string][]func(s *NsSuite){}
type NsSuite struct {
HstSuite
}
func registerNsTests(tests ...func(s *NsSuite)) {
- nsTests = append(nsTests, tests...)
+ nsTests[getTestFilename()] = tests
}
func registerNsSoloTests(tests ...func(s *NsSuite)) {
- nsSoloTests = append(nsSoloTests, tests...)
+ nsSoloTests[getTestFilename()] = tests
}
func (s *NsSuite) SetupSuite() {
@@ -77,15 +77,17 @@
s.TearDownTest()
})
- for _, test := range nsTests {
- test := test
- pc := reflect.ValueOf(test).Pointer()
- funcValue := runtime.FuncForPC(pc)
- testName := strings.Split(funcValue.Name(), ".")[2]
- It(testName, func(ctx SpecContext) {
- s.log(testName + ": BEGIN")
- test(&s)
- }, SpecTimeout(suiteTimeout))
+ for filename, tests := range nsTests {
+ for _, test := range tests {
+ test := test
+ pc := reflect.ValueOf(test).Pointer()
+ funcValue := runtime.FuncForPC(pc)
+ testName := filename + "/" + strings.Split(funcValue.Name(), ".")[2]
+ It(testName, func(ctx SpecContext) {
+ s.log(testName + ": BEGIN")
+ test(&s)
+ }, SpecTimeout(suiteTimeout))
+ }
}
})
@@ -104,14 +106,16 @@
s.TearDownTest()
})
- for _, test := range nsSoloTests {
- test := test
- pc := reflect.ValueOf(test).Pointer()
- funcValue := runtime.FuncForPC(pc)
- testName := strings.Split(funcValue.Name(), ".")[2]
- It(testName, Label("SOLO"), func(ctx SpecContext) {
- s.log(testName + ": BEGIN")
- test(&s)
- }, SpecTimeout(suiteTimeout))
+ for filename, tests := range nsSoloTests {
+ for _, test := range tests {
+ test := test
+ pc := reflect.ValueOf(test).Pointer()
+ funcValue := runtime.FuncForPC(pc)
+ testName := filename + "/" + strings.Split(funcValue.Name(), ".")[2]
+ It(testName, Label("SOLO"), func(ctx SpecContext) {
+ s.log(testName + ": BEGIN")
+ test(&s)
+ }, SpecTimeout(suiteTimeout))
+ }
}
})