Coveralls sends the test coverage to Coveralls.
()
| 237 | |
| 238 | // Coveralls sends the test coverage to Coveralls. |
| 239 | func (g Go) Coveralls() error { |
| 240 | mg.Deps(g.Cover) |
| 241 | if mg.Verbose() { |
| 242 | fmt.Println("Filtering Go coverage output") |
| 243 | } |
| 244 | inFile, err := os.Open(goCoverageFile) |
| 245 | if err != nil { |
| 246 | return err |
| 247 | } |
| 248 | outFile, err := os.OpenFile("coveralls_"+goCoverageFile, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o644) |
| 249 | if err != nil { |
| 250 | return err |
| 251 | } |
| 252 | defer func() { |
| 253 | outFile.Close() |
| 254 | os.Remove("coveralls_" + goCoverageFile) |
| 255 | }() |
| 256 | s := bufio.NewScanner(inFile) |
| 257 | nextLine: |
| 258 | for s.Scan() { |
| 259 | line := s.Text() |
| 260 | for _, suffix := range coverallsIgnored { |
| 261 | if strings.Contains(line, suffix) { |
| 262 | continue nextLine |
| 263 | } |
| 264 | } |
| 265 | if _, err = fmt.Fprintln(outFile, line); err != nil { |
| 266 | return err |
| 267 | } |
| 268 | } |
| 269 | if err = outFile.Close(); err != nil { |
| 270 | return err |
| 271 | } |
| 272 | service := os.Getenv("COVERALLS_SERVICE") |
| 273 | if service == "" { |
| 274 | service = "github" |
| 275 | } |
| 276 | if mg.Verbose() { |
| 277 | fmt.Println("Sending Go coverage to Coveralls") |
| 278 | } |
| 279 | return runGoTool(goveralls, "-coverprofile=coveralls_"+goCoverageFile, "-service="+service) |
| 280 | } |
| 281 | |
| 282 | // Generate runs go generate. |
| 283 | func (Go) Generate() error { |