MCPcopy Create free account
hub / github.com/CPChain/chain / runTestFile

Method runTestFile

tests/init_test.go:208–235  ·  view source on GitHub ↗
(t *testing.T, path, name string, runTest interface{})

Source from the content-addressed store, hash-verified

206}
207
208func (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
237func makeMapFromTestFunc(f interface{}) reflect.Value {
238 stringT := reflect.TypeOf("")

Callers 1

walkMethod · 0.95

Calls 7

findSkipMethod · 0.95
makeMapFromTestFuncFunction · 0.85
readJSONFileFunction · 0.85
sortedMapKeysFunction · 0.85
runTestFuncFunction · 0.85
FatalMethod · 0.65
RunMethod · 0.65

Tested by

no test coverage detected