Skip to content

Commit

Permalink
add flag to report progress
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensayshi committed Jun 25, 2022
1 parent f9dd7ce commit f2b3eb8
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 21 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
16 changes: 9 additions & 7 deletions courtney.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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,
},
Expand Down
27 changes: 14 additions & 13 deletions shared/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion tester/tester.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
Expand Down

0 comments on commit f2b3eb8

Please sign in to comment.