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

Dev/fail fast cli flag #525

Merged
merged 4 commits into from
Jan 6, 2025
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
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
Loading