(t *testing.T, path, name string, runTest interface{})
| 206 | } |
| 207 | |
| 208 | func (tm *testMatcher) runTestFile(t *testing.T, path, name string, runTest interface{}) { |
| 209 | if r, _ := tm.findSkip(name); r != "" { |
| 210 | t.Skip(r) |
| 211 | } |
| 212 | t.Parallel() |
| 213 | |
| 214 | // Load the file as map[string]<testType>. |
| 215 | m := makeMapFromTestFunc(runTest) |
| 216 | if err := readJSONFile(path, m.Addr().Interface()); err != nil { |
| 217 | t.Fatal(err) |
| 218 | } |
| 219 | |
| 220 | // Run all tests from the map. Don't wrap in a subtest if there is only one test in the file. |
| 221 | keys := sortedMapKeys(m) |
| 222 | if len(keys) == 1 { |
| 223 | runTestFunc(runTest, t, name, m, keys[0]) |
| 224 | } else { |
| 225 | for _, key := range keys { |
| 226 | name := name + "/" + key |
| 227 | t.Run(key, func(t *testing.T) { |
| 228 | if r, _ := tm.findSkip(name); r != "" { |
| 229 | t.Skip(r) |
| 230 | } |
| 231 | runTestFunc(runTest, t, name, m, key) |
| 232 | }) |
| 233 | } |
| 234 | } |
| 235 | } |
| 236 | |
| 237 | func makeMapFromTestFunc(f interface{}) reflect.Value { |
| 238 | stringT := reflect.TypeOf("") |
no test coverage detected