diff --git a/README.md b/README.md index be449a3..c9549b7 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,11 @@ courtney . -- -count=2 -parallel=4 All the output from the `go test -v` command is shown. +### Report: -r +`Report tests being ran` + +Reports each test (package) being ran. + # Output Courtney will fail if the tests fail. If the tests succeed, it will create or overwrite a `coverage.out` file in the current directory. diff --git a/courtney.go b/courtney.go index 1b3c6a9..6d79e3a 100644 --- a/courtney.go +++ b/courtney.go @@ -20,6 +20,7 @@ func main() { enforceFlag := flag.Bool("e", false, "Enforce 100% code coverage") verboseFlag := flag.Bool("v", false, "Verbose output") + reportFlag := flag.Bool("r", false, "Print each package being tested") shortFlag := flag.Bool("short", false, "Pass the short flag to the go test command") timeoutFlag := flag.String("timeout", "", "Pass the timeout flag to the go test command") outputFlag := flag.String("o", "", "Override coverage file location") @@ -64,13 +65,14 @@ func main() { } setup := &shared.Setup{ - Env: env, - Paths: patsy.NewCache(env), - Enforce: *enforceFlag, - Verbose: *verboseFlag, - Short: *shortFlag, - Timeout: *timeoutFlag, - Output: *outputFlag, + Env: env, + Paths: patsy.NewCache(env), + Enforce: *enforceFlag, + Verbose: *verboseFlag, + ReportTestRun: *reportFlag, + Short: *shortFlag, + Timeout: *timeoutFlag, + Output: *outputFlag, Options: shared.Options{ ExcludeErrNoReturnParam: *excludeErrNoReturnParamFlag, }, diff --git a/shared/shared.go b/shared/shared.go index fda891a..cb7f3e3 100644 --- a/shared/shared.go +++ b/shared/shared.go @@ -10,19 +10,20 @@ import ( // Setup holds globals, environment and command line flags for the courtney // command type Setup struct { - Env vos.Env - Paths *patsy.Cache - Enforce bool - Verbose bool - Short bool - Timeout string - Load string - Output string - Options Options - CoverPkgs []string - ExcludePkgs []string - TestArgs []string - Packages []PackageSpec + Env vos.Env + Paths *patsy.Cache + Enforce bool + Verbose bool + ReportTestRun bool + Short bool + Timeout string + Load string + Output string + Options Options + CoverPkgs []string + ExcludePkgs []string + TestArgs []string + Packages []PackageSpec } type Options struct { diff --git a/tester/tester.go b/tester/tester.go index e02a423..079ac34 100644 --- a/tester/tester.go +++ b/tester/tester.go @@ -260,11 +260,13 @@ func (t *Tester) processDir(dir string) error { args = append(args, t.setup.TestArgs...) } if t.setup.Verbose { - fmt.Fprintf( + _, _ = fmt.Fprintf( t.setup.Env.Stdout(), "Running test: %s\n", strings.Join(append([]string{"go"}, args...), " "), ) + } else if t.setup.ReportTestRun { + _, _ = fmt.Fprintf(t.setup.Env.Stdout(), "Running test: %s\n", dir) } exe := exec.Command("go", args...)