Skip to content

Commit

Permalink
complete failfast implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Mar 8, 2025
1 parent 32147aa commit 2be439e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
1 change: 1 addition & 0 deletions gnovm/cmd/gno/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ func execTest(cfg *testCfg, args []string, io commands.IO) error {
opts.Metrics = cfg.printRuntimeMetrics
opts.Events = cfg.printEvents
opts.Debug = cfg.debug
opts.FailfastFlag = cfg.failfast

buildErrCount := 0
testErrCount := 0
Expand Down
19 changes: 4 additions & 15 deletions gnovm/cmd/gno/testdata/test/flag_fail-fast.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ stderr 'someError'
! stderr 'secondError'


-- one/failfast.gno --
package one
-- failfast.gno --
package failfast

-- one/failfast_test.gno --
package one
-- failfast_test.gno --
package failfast

import (
"testing"
Expand All @@ -22,17 +22,6 @@ func TestFail(t *testing.T) {
t.Error("someError")
}

-- two/failfast.gno --
package two

-- two/failfast_test.gno --
package two

import (
"testing"
)

func TestFail2(t *testing.T) {
t.Error("secondError")
}

5 changes: 5 additions & 0 deletions gnovm/pkg/test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ type TestOptions struct {

// Flag to filter tests to run.
RunFlag string
// Flag to stop executing as soon a test fails.
FailfastFlag bool
// Whether to update filetest directives.
Sync bool
// Uses Error to print when starting a test, and prints test output directly,
Expand Down Expand Up @@ -382,6 +384,9 @@ func (opts *TestOptions) runTestFiles(
if rep.Failed {
err := fmt.Errorf("failed: %q", tf.Name)
errs = multierr.Append(errs, err)
if opts.FailfastFlag {
return errs
}
}

if opts.Metrics {
Expand Down

0 comments on commit 2be439e

Please sign in to comment.