Skip to content

Commit

Permalink
Dev/fail fast cli flag (#525)
Browse files Browse the repository at this point in the history
* add fail fast flag

* fix docs typo

* minor changes

---------

Co-authored-by: anishnaik <[email protected]>
  • Loading branch information
tuturu-tech and anishnaik authored Jan 6, 2025
1 parent 225d2ee commit 350ee4b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
18 changes: 15 additions & 3 deletions cmd/fuzz_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ func addFuzzFlags() error {
fmt.Sprintf("print the execution trace for every element in a shrunken call sequence instead of only the last element (unless a config file is provided, default is %t)", defaultConfig.Fuzzing.Testing.TraceAll))

// Logging color
fuzzCmd.Flags().Bool("no-color", false, "disabled colored terminal output")
fuzzCmd.Flags().Bool("no-color", false, "disables colored terminal output")

// Enable stop on failed test
fuzzCmd.Flags().Bool("fail-fast", false, "enables stop on failed test")

// Exploration mode
fuzzCmd.Flags().Bool("explore", false, "enables exploration mode")
Expand Down Expand Up @@ -167,13 +170,22 @@ func updateProjectConfigWithFuzzFlags(cmd *cobra.Command, projectConfig *config.
}
}

// Update stop on failed test feature
if cmd.Flags().Changed("fail-fast") {
failFast, err := cmd.Flags().GetBool("fail-fast")
if err != nil {
return err
}
projectConfig.Fuzzing.Testing.StopOnFailedTest = failFast
}

// Update configuration to exploration mode
if cmd.Flags().Changed("explore") {
exploreBool, err := cmd.Flags().GetBool("explore")
explore, err := cmd.Flags().GetBool("explore")
if err != nil {
return err
}
if exploreBool {
if explore {
projectConfig.Fuzzing.Testing.StopOnFailedTest = false
projectConfig.Fuzzing.Testing.StopOnNoTests = false
projectConfig.Fuzzing.Testing.AssertionTesting.Enabled = false
Expand Down
10 changes: 10 additions & 0 deletions docs/src/cli/fuzz.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,16 @@ The `--deployer` flag allows you to update `medusa`'s contract deployer (equival
medusa fuzz --deployer "0x40000"
```

### `--fail-fast`

The `--fail-fast` flag enables fast failure (equivalent to
[`testing.StopOnFailedTest`](../project_configuration/testing_config.md#stoponfailedtest))

```shell
# Enable fast failure
medusa fuzz --fail-fast
```

### `--trace-all`

The `--trace-all` flag allows you to retrieve an execution trace for each element of a call sequence that triggered a test
Expand Down

0 comments on commit 350ee4b

Please sign in to comment.