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 May 11, 2021
1 parent 9114a6d commit 024bc9d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 20 deletions.
16 changes: 9 additions & 7 deletions courtney.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,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 @@ -51,13 +52,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
26 changes: 14 additions & 12 deletions shared/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +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
ExcludePkgs []string
TestArgs []string
Packages []PackageSpec
Env vos.Env
Paths *patsy.Cache
Enforce bool
Verbose bool
ReportTestRun bool
TestVerbose bool
Short bool
Timeout string
Load string
Output string
Options Options
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 @@ -252,11 +252,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 024bc9d

Please sign in to comment.