Skip to content

Commit

Permalink
wip: cleaner(?) refactor of ui/summary
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Mirić committed Sep 30, 2019
1 parent 11c4be1 commit e76e2a9
Show file tree
Hide file tree
Showing 4 changed files with 204 additions and 283 deletions.
10 changes: 4 additions & 6 deletions cmd/options.go
Expand Up @@ -147,14 +147,12 @@ func getOptions(flags *pflag.FlagSet) (lib.Options, error) {
if err != nil {
return opts, err
}
for _, s := range trendStatStrings {
if err := ui.VerifyTrendColumnStat(s); err != nil {
return opts, errors.Wrapf(err, "stat '%s'", s)
}

opts.SummaryTrendStats = append(opts.SummaryTrendStats, s)
if _, summaryErr := ui.NewSummary(trendStatStrings); summaryErr != nil {
return opts, summaryErr
}

opts.SummaryTrendStats = append(opts.SummaryTrendStats, trendStatStrings...)

summaryTimeUnit, err := flags.GetString("summary-time-unit")
if err != nil {
return opts, err
Expand Down
21 changes: 10 additions & 11 deletions cmd/run.go
Expand Up @@ -62,6 +62,7 @@ const (
genericTimeoutErrorCode = 102
genericEngineErrorCode = 103
invalidConfigErrorCode = 104
summaryErrorCode = 105
)

var (
Expand Down Expand Up @@ -176,11 +177,6 @@ a commandline interface for interacting with it.`,
return ExitCode{cerr, invalidConfigErrorCode}
}

// If summary trend stats are defined, update the UI to reflect them
if len(conf.SummaryTrendStats) > 0 {
ui.UpdateTrendColumns(conf.SummaryTrendStats)
}

// Write options back to the runner too.
if err = r.SetOptions(conf.Options); err != nil {
return err
Expand Down Expand Up @@ -448,13 +444,16 @@ a commandline interface for interacting with it.`,

// Print the end-of-test summary.
if !conf.NoSummary.Bool {
s, err := ui.NewSummary(conf.SummaryTrendStats)
if err != nil {
// Shouldn't happen, config should be valid at this point
logrus.WithError(err).Error("Summary error")
return ExitCode{errors.New("summary error"), summaryErrorCode}
}

fprintf(stdout, "\n")
ui.Summarize(stdout, "", ui.SummaryData{
Opts: conf.Options,
Root: engine.Executor.GetRunner().GetDefaultGroup(),
Metrics: engine.Metrics,
Time: engine.Executor.GetTime(),
})
s.Write(stdout, "", engine.Executor.GetRunner().GetDefaultGroup(),
engine.Executor.GetTime(), conf.SummaryTimeUnit.String, engine.Metrics)
fprintf(stdout, "\n")
}

Expand Down

0 comments on commit e76e2a9

Please sign in to comment.