Skip to content

Commit a92f6d9

Browse files
authored
Merge pull request #139 from azaurus1/update-coverage-for-map
added coveragemap to track uncovered paths
2 parents 5fd19eb + f3140c3 commit a92f6d9

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tools/coverage/coverage.go

+24
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import (
1111
"github.com/go-openapi/spec"
1212
)
1313

14+
var coveredPaths map[string]bool = make(map[string]bool)
15+
1416
func iteratePathsAndCalculate(swagger *spec.Swagger, f []byte) float64 {
1517
// Convert the file content to a string
1618
fileContent := string(f)
@@ -27,8 +29,10 @@ func iteratePathsAndCalculate(swagger *spec.Swagger, f []byte) float64 {
2729
// Check if the file content contains the path
2830
if strings.Contains(fileContent, path) {
2931
foundPathCount++
32+
coveredPaths[path] = true
3033
} else {
3134
// fmt.Printf("Path not found in go-pinot-api.go: %s\n", path)
35+
coveredPaths[path] = false
3236
}
3337
}
3438

@@ -68,6 +72,24 @@ func writeToCoverageFile(coverage float64) {
6872

6973
}
7074

75+
func writeCoverageMapToFile() {
76+
filePath := filepath.Join(".", "coverageMap.txt")
77+
78+
f, err := os.Create(filePath)
79+
if err != nil {
80+
panic(err)
81+
}
82+
defer f.Close()
83+
84+
for k, v := range coveredPaths {
85+
_, err = f.WriteString(fmt.Sprintf("%s: %t\n", k, v))
86+
if err != nil {
87+
panic(err)
88+
}
89+
}
90+
91+
}
92+
7193
func main() {
7294
filePath := filepath.Join(".", "swagger.json")
7395

@@ -83,4 +105,6 @@ func main() {
83105

84106
writeToCoverageFile(coverage)
85107

108+
writeCoverageMapToFile()
109+
86110
}

0 commit comments

Comments
 (0)