MCPcopy Index your code
hub / github.com/dgraph-io/dgraph / isTestCoverageEmpty

Function isTestCoverageEmpty

t/t.go:1351–1372  ·  view source on GitHub ↗

Checks whether the test coverage file generated by go test is empty. Empty coverage file are those that only has one line ("mode: ") and nothing else.

(path string)

Source from the content-addressed store, hash-verified

1349// Checks whether the test coverage file generated by go test is empty.
1350// Empty coverage file are those that only has one line ("mode: <coverage_mode>") and nothing else.
1351func isTestCoverageEmpty(path string) (bool, error) {
1352 file, err := os.Open(path)
1353 if err != nil {
1354 return true, err
1355 }
1356 defer func() {
1357 if err := file.Close(); err != nil {
1358 glog.Warningf("error closing file: %v", err)
1359 }
1360 }()
1361
1362 var l int
1363 scanner := bufio.NewScanner(file)
1364 for l = 0; scanner.Scan() && l <= 1; l++ {
1365 }
1366
1367 if err = scanner.Err(); err != nil {
1368 return true, err
1369 }
1370
1371 return l <= 1, nil
1372}
1373
1374func appendTestCoverageFile(src, des string) error {
1375 if !fileExists(src) {

Callers 1

appendTestCoverageFileFunction · 0.85

Calls 3

WarningfMethod · 0.80
OpenMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected