Skip to content

Commit c25dd96

Browse files
committed
Adding a test script timeout argument
1 parent a2ccfa8 commit c25dd96

8 files changed

Lines changed: 16 additions & 5 deletions

module_renderer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ def _build_render_context_for_module(
176176
verbose=self.args.verbose,
177177
run_state=self.run_state,
178178
event_bus=self.event_bus,
179+
test_script_timeout=self.args.test_script_timeout,
179180
)
180181

181182
def _render_module(

plain2code.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@
4747
from system_config import system_config
4848
from tui.plain2code_tui import Plain2CodeTUI
4949

50-
TEST_SCRIPT_EXECUTION_TIMEOUT = 120 # 120 seconds
51-
5250
DEFAULT_TEMPLATE_DIRS = importlib.resources.files("standard_template_library")
5351

5452
MAX_UNITTEST_FIX_ATTEMPTS = 20

plain2code_arguments.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,13 @@ def create_parser():
202202
help="Path to a shell script that prepares the testing environment. The script should accept the source code folder path as its first argument.",
203203
)
204204

205+
parser.add_argument(
206+
"--test-script-timeout",
207+
type=int,
208+
default=None,
209+
help="Timeout for test scripts in seconds. If not provided, the default timeout of 120 seconds is used.",
210+
)
211+
205212
parser.add_argument(
206213
"--api",
207214
type=str,

render_machine/actions/prepare_testing_environment.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def execute(self, render_context: RenderContext, _previous_action_payload: Any |
2121
[render_context.build_folder],
2222
render_context.verbose,
2323
"Testing Environment Preparation",
24+
timeout=render_context.test_script_timeout
2425
)
2526

2627
render_context.conformance_tests_running_context.should_prepare_testing_environment = False

render_machine/actions/run_conformance_tests.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ def execute(self, render_context: RenderContext, _previous_action_payload: Any |
4343
[render_context.build_folder, conformance_tests_folder_name],
4444
render_context.verbose,
4545
"Conformance Tests",
46-
render_context.conformance_tests_running_context.current_testing_frid,
46+
frid=render_context.conformance_tests_running_context.current_testing_frid,
47+
timeout=render_context.test_script_timeout
4748
)
4849
render_context.script_execution_history.latest_conformance_test_output_path = conformance_tests_temp_file_path
4950
render_context.script_execution_history.should_update_script_outputs = True

render_machine/actions/run_unit_tests.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def execute(self, render_context: RenderContext, _previous_action_payload: Any |
2424
[render_context.build_folder],
2525
render_context.verbose,
2626
"Unit Tests",
27+
timeout=render_context.test_script_timeout
2728
)
2829

2930
render_context.script_execution_history.latest_unit_test_output_path = unittests_temp_file_path

render_machine/render_context.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def __init__(
5151
verbose: bool,
5252
run_state: RunState,
5353
event_bus: EventBus,
54+
test_script_timeout: Optional[int] = None,
5455
):
5556
self.codeplain_api: CodeplainAPI = codeplain_api
5657
self.memory_manager = memory_manager
@@ -75,6 +76,7 @@ def __init__(
7576
self.event_bus = event_bus
7677
self.script_execution_history = ScriptExecutionHistory()
7778
self.starting_frid = None
79+
self.test_script_timeout = test_script_timeout
7880

7981
resources_list = []
8082
plain_spec.collect_linked_resources(plain_source_tree, resources_list, None, True)

render_machine/render_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def print_inputs(render_context, existing_files_content, message):
4242

4343

4444
def execute_script(
45-
script: str, scripts_args: list[str], verbose: bool, script_type: str, frid: Optional[str] = None
45+
script: str, scripts_args: list[str], verbose: bool, script_type: str, frid: Optional[str] = None, timeout: Optional[int] = None
4646
) -> tuple[int, str, Optional[str]]:
4747
temp_file_path = None
4848
try:
@@ -52,7 +52,7 @@ def execute_script(
5252
stdout=subprocess.PIPE,
5353
stderr=subprocess.STDOUT,
5454
text=True,
55-
timeout=SCRIPT_EXECUTION_TIMEOUT,
55+
timeout=timeout if timeout is not None else SCRIPT_EXECUTION_TIMEOUT,
5656
)
5757
elapsed_time = time.time() - start_time
5858
# Log the info about the script execution

0 commit comments

Comments
 (0)