From 8601d251a59c45d6662b0a572bd67c3e1db0d865 Mon Sep 17 00:00:00 2001 From: honzaprevratil Date: Mon, 16 Dec 2024 17:14:45 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20PoC:=20flow=20calling=20function?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/testing-framework/fuzzing.md | 1 + wake/testing/fuzzing/fuzz_test.py | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/testing-framework/fuzzing.md b/docs/testing-framework/fuzzing.md index 55d35fd42..72afbb016 100644 --- a/docs/testing-framework/fuzzing.md +++ b/docs/testing-framework/fuzzing.md @@ -75,6 +75,7 @@ Execution hooks are functions that are executed during the `FuzzTest` lifecycle. - `pre_sequence(self)` - executed before each test sequence, - `pre_flow(self, flow: Callable)` - executed before each flow, accepts the flow function to be executed as an argument, +- `call_flow(self, flow: Callable, flow_params: List[Any])` - executes each flow, accepts the flow function to be executed as an argument and the flow parameters which will be passed to the flow function, - `post_flow(self, flow: Callable)` - executed after each flow, accepts the flow function that was executed as an argument, - `pre_invariants(self)` - executed before each set of invariants, - `pre_invariant(self, invariant: Callable)` - executed before each invariant, accepts the invariant function to be executed as an argument, diff --git a/wake/testing/fuzzing/fuzz_test.py b/wake/testing/fuzzing/fuzz_test.py index 3b06923ab..d2f363ba9 100644 --- a/wake/testing/fuzzing/fuzz_test.py +++ b/wake/testing/fuzzing/fuzz_test.py @@ -1,7 +1,7 @@ from __future__ import annotations from collections import defaultdict -from typing import Callable, DefaultDict, List, Optional +from typing import Callable, DefaultDict, List, Optional, Any from typing_extensions import get_type_hints @@ -121,7 +121,7 @@ def run( self._flow_num = j self.pre_flow(flow) - flow(self, *flow_params) + self.call_flow(flow, flow_params) flows_counter[flow] += 1 self.post_flow(flow) @@ -152,6 +152,9 @@ def post_sequence(self) -> None: def pre_flow(self, flow: Callable) -> None: pass + def call_flow(self, flow: Callable, flow_params: List[Any]) -> None: + flow(self, *flow_params) + def post_flow(self, flow: Callable) -> None: pass