Skip to content

Commit

Permalink
Don't write coverage reports if the empty string is specified for the…
Browse files Browse the repository at this point in the history
… path (#2780) (#2856)

* Don't write coverage reports if the empty string is specified

* Add env vars

Co-authored-by: Peter Ebden <peter.ebden@gmail.com>
  • Loading branch information
goddenrich and peterebden authored Jul 11, 2023
1 parent 6070643 commit f92f8e5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Version 16.28.1
---------------
* Don't write coverage reports if the empty string is specified for the
path (#2780)


Version 16.28.0
---------------
* Support for Go 1.20 (#2735)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.28.0
16.28.1
12 changes: 8 additions & 4 deletions src/please.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ var opts struct {
IncludeFile cli.Filepaths `long:"include_file" description:"Filenames to filter coverage display to. Supports shell pattern matching e.g. file/path/*."`
TestResultsFile cli.Filepath `long:"test_results_file" default:"plz-out/log/test_results.xml" description:"File to write combined test results to."`
SurefireDir cli.Filepath `long:"surefire_dir" default:"plz-out/surefire-reports" description:"Directory to copy XML test results to."`
CoverageResultsFile cli.Filepath `long:"coverage_results_file" default:"plz-out/log/coverage.json" description:"File to write combined coverage results to."`
CoverageXMLReport cli.Filepath `long:"coverage_xml_report" default:"plz-out/log/coverage.xml" description:"XML File to write combined coverage results to."`
CoverageResultsFile cli.Filepath `long:"coverage_results_file" env:"COVERAGE_RESULTS_FILE" default:"plz-out/log/coverage.json" description:"File to write combined coverage results to."`
CoverageXMLReport cli.Filepath `long:"coverage_xml_report" env:"COVERAGE_XML_REPORT" default:"plz-out/log/coverage.xml" description:"XML File to write combined coverage results to."`
Incremental bool `short:"i" long:"incremental" description:"Calculates summary statistics for incremental coverage, i.e. stats for just the lines currently modified."`
ShowOutput bool `short:"s" long:"show_output" description:"Always show output of tests, even on success."`
DebugFailingTest bool `short:"d" long:"debug" description:"Allows starting an interactive debugger on test failure. Does not work with all test types (currently only python/pytest). Implies -c dbg unless otherwise set."`
Expand Down Expand Up @@ -506,8 +506,12 @@ var buildFunctions = map[string]func() int{
}
stats = test.CalculateIncrementalStats(state, lines)
}
test.WriteCoverageToFileOrDie(state.Coverage, string(opts.Cover.CoverageResultsFile), stats)
test.WriteXMLCoverageToFileOrDie(targets, state.Coverage, string(opts.Cover.CoverageXMLReport))
if opts.Cover.CoverageResultsFile != "" {
test.WriteCoverageToFileOrDie(state.Coverage, string(opts.Cover.CoverageResultsFile), stats)
}
if opts.Cover.CoverageXMLReport != "" {
test.WriteXMLCoverageToFileOrDie(targets, state.Coverage, string(opts.Cover.CoverageXMLReport))
}

if opts.Cover.LineCoverageReport && success {
output.PrintLineCoverageReport(state, opts.Cover.IncludeFile.AsStrings())
Expand Down

0 comments on commit f92f8e5

Please sign in to comment.