Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/testscript: remove redundant use of Failed #257

Merged
merged 1 commit into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions cmd/testscript/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"os/exec"
"path/filepath"
"strings"
"sync/atomic"

"github.com/rogpeppe/go-internal/goproxytest"
"github.com/rogpeppe/go-internal/gotooltest"
Expand Down Expand Up @@ -293,12 +292,6 @@ func (tr *testRunner) run(runDir, filename string) error {
}
}()
testscript.RunT(r, p)

// When continueOnError is true, FailNow does not call panic(failedRun).
// We still want err to be set, as the script resulted in a failure.
if r.Failed() {
err = failedRun
}
}()

if err != nil {
Expand Down Expand Up @@ -348,7 +341,6 @@ func renderFilename(filename string) string {
// runT implements testscript.T and is used in the call to testscript.Run
type runT struct {
verbose bool
failed int32
}

func (r *runT) Skip(is ...interface{}) {
Expand All @@ -370,14 +362,9 @@ func (r *runT) Log(is ...interface{}) {
}

func (r *runT) FailNow() {
atomic.StoreInt32(&r.failed, 1)
panic(failedRun)
}

func (r *runT) Failed() bool {
return atomic.LoadInt32(&r.failed) != 0
}

func (r *runT) Run(n string, f func(t testscript.T)) {
// For now we we don't top/tail the run of a subtest. We are currently only
// running a single script in a testscript instance, which means that we
Expand Down
3 changes: 1 addition & 2 deletions testscript/testscript.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,7 @@ type T interface {
Verbose() bool
}

// TFailed holds optional extra methods implemented on T.
// It's defined as a separate type for backward compatibility reasons.
// Deprecated: this type is unused.
type TFailed interface {
Failed() bool
}
Expand Down
4 changes: 0 additions & 4 deletions testscript/testscript_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,3 @@ func (t *fakeT) Run(name string, f func(T)) {
func (t *fakeT) Verbose() bool {
return t.verbose
}

func (t *fakeT) Failed() bool {
return t.failed
}