From 53db97b28af624a937e693aba1366ca09f9bded6 Mon Sep 17 00:00:00 2001 From: tuturu-tech Date: Mon, 23 Dec 2024 15:02:15 +0100 Subject: [PATCH 1/3] add fail fast flag --- cmd/fuzz_flags.go | 11 +++++++++++ docs/src/cli/fuzz.md | 10 ++++++++++ 2 files changed, 21 insertions(+) diff --git a/cmd/fuzz_flags.go b/cmd/fuzz_flags.go index 9e1c9d37..0e51d688 100644 --- a/cmd/fuzz_flags.go +++ b/cmd/fuzz_flags.go @@ -63,6 +63,9 @@ func addFuzzFlags() error { // Logging color fuzzCmd.Flags().Bool("no-color", false, "disabled colored terminal output") + // Enable stop on failed test + fuzzCmd.Flags().Bool("fail-fast", false, "enabled stop on failed test") + return nil } @@ -163,5 +166,13 @@ func updateProjectConfigWithFuzzFlags(cmd *cobra.Command, projectConfig *config. return err } } + + // Update StopOnFailedTest enablement + if cmd.Flags().Changed("fail-fast") { + projectConfig.Fuzzing.Testing.StopOnFailedTest, err = cmd.Flags().GetBool("fail-fast") + if err != nil { + return err + } + } return nil } diff --git a/docs/src/cli/fuzz.md b/docs/src/cli/fuzz.md index ed70d15a..ed3a197a 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 enable 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 From 7a105b6a185140e8d53feab2a9145da9fe0fc9c0 Mon Sep 17 00:00:00 2001 From: tuturu-tech Date: Mon, 23 Dec 2024 15:08:44 +0100 Subject: [PATCH 2/3] fix docs typo --- docs/src/cli/fuzz.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/cli/fuzz.md b/docs/src/cli/fuzz.md index ed3a197a..7af349c0 100644 --- a/docs/src/cli/fuzz.md +++ b/docs/src/cli/fuzz.md @@ -111,7 +111,7 @@ medusa fuzz --deployer "0x40000" ### `--fail-fast` -The `--fail-fast` flag enable fast failure (equivalent to +The `--fail-fast` flag enables fast failure (equivalent to [`testing.StopOnFailedTest`](../project_configuration/testing_config.md#stoponfailedtest)) ```shell From aefbfaf29e196d754b27749dc5ba9cb289bf703e Mon Sep 17 00:00:00 2001 From: Anish Naik Date: Mon, 6 Jan 2025 16:11:19 -0500 Subject: [PATCH 3/3] minor changes --- cmd/fuzz_flags.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cmd/fuzz_flags.go b/cmd/fuzz_flags.go index abc89190..56d17897 100644 --- a/cmd/fuzz_flags.go +++ b/cmd/fuzz_flags.go @@ -61,15 +61,14 @@ 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, "enabled 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") - return nil } @@ -171,21 +170,22 @@ func updateProjectConfigWithFuzzFlags(cmd *cobra.Command, projectConfig *config. } } - - // Update StopOnFailedTest enablement + // Update stop on failed test feature if cmd.Flags().Changed("fail-fast") { - projectConfig.Fuzzing.Testing.StopOnFailedTest, err = cmd.Flags().GetBool("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