From f92f8e512afce3c0fc53bd4add33b55c33192f93 Mon Sep 17 00:00:00 2001 From: Richard Godden <7768980+goddenrich@users.noreply.github.com> Date: Tue, 11 Jul 2023 17:14:30 +0100 Subject: [PATCH] Don't write coverage reports if the empty string is specified for the path (#2780) (#2856) * Don't write coverage reports if the empty string is specified * Add env vars Co-authored-by: Peter Ebden --- ChangeLog | 6 ++++++ VERSION | 2 +- src/please.go | 12 ++++++++---- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 741bf55303..41de3b0f62 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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) diff --git a/VERSION b/VERSION index 885090dccc..2d4487b5d8 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -16.28.0 +16.28.1 diff --git a/src/please.go b/src/please.go index 2a9af7aeb4..76362ff8cb 100644 --- a/src/please.go +++ b/src/please.go @@ -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."` @@ -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())