diff --git a/Makefile b/Makefile index f6b7a83e..03065496 100644 --- a/Makefile +++ b/Makefile @@ -21,13 +21,16 @@ test-integration: cert chmod 600 testdata/sshd/id_rsa go test ./... -tags=integration -count=1 -test-all: cert +test-all: cert test-loadt chmod 600 testdata/sshd/id_rsa go test ./... -tags=integration -coverprofile=coverage.out -covermode=count benchmark: cert go test -bench . -benchmem -run Benchmark | octocov-go-test-bench --tee > custom_metrics_benchmark.json +test-loadt: + go run ./cmd/runn/main.go loadt testdata/book/always_success.yml --duration 1s --warm-up 0s + lint: golangci-lint run ./... govulncheck ./... diff --git a/cmd/loadt.go b/cmd/loadt.go index 7758f295..716d2262 100644 --- a/cmd/loadt.go +++ b/cmd/loadt.go @@ -32,6 +32,7 @@ import ( "github.com/k1LoW/donegroup" "github.com/k1LoW/duration" "github.com/k1LoW/runn" + "github.com/mattn/go-isatty" "github.com/ryo-yamaoka/otchkiss" "github.com/ryo-yamaoka/otchkiss/setting" "github.com/spf13/cobra" @@ -90,15 +91,25 @@ var loadtCmd = &cobra.Command{ if err != nil { return err } - p := tea.NewProgram(newSpinnerModel()) - go func() { - _, _ = p.Run() - }() - if err := ot.Start(ctx); err != nil { - return err + + if isatty.IsTerminal(os.Stdout.Fd()) { + // With tty + p := tea.NewProgram(newSpinnerModel(), tea.WithContext(ctx)) + go func() { + if _, errr := p.Run(); errr != nil { + err = errr + } + }() + if err := ot.Start(ctx); err != nil { + return err + } + p.Quit() + p.Wait() + } else { + if err := ot.Start(ctx); err != nil { + return err + } } - p.Quit() - p.Wait() lr, err := runn.NewLoadtResult(len(selected), w, d, flgs.LoadTConcurrent, flgs.LoadTMaxRPS, ot.Result) if err != nil {