From 350ee4badd95135970c8d1b23bfa47be4fd8c63a Mon Sep 17 00:00:00 2001 From: tuturu-tech <9058533+tuturu-tech@users.noreply.github.com> Date: Mon, 6 Jan 2025 22:24:48 +0100 Subject: [PATCH] Dev/fail fast cli flag (#525) * add fail fast flag * fix docs typo * minor changes --------- Co-authored-by: anishnaik --- cmd/fuzz_flags.go | 18 +++++++++++++++--- docs/src/cli/fuzz.md | 10 ++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/cmd/fuzz_flags.go b/cmd/fuzz_flags.go index d782496f..56d17897 100644 --- a/cmd/fuzz_flags.go +++ b/cmd/fuzz_flags.go @@ -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") @@ -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 diff --git a/docs/src/cli/fuzz.md b/docs/src/cli/fuzz.md index 671723b5..6430b3ed 100644 --- a/docs/src/cli/fuzz.md +++ b/docs/src/cli/fuzz.md @@ -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