-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathprepare_testing_environment.py
More file actions
40 lines (35 loc) · 1.8 KB
/
Copy pathprepare_testing_environment.py
File metadata and controls
40 lines (35 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from typing import Any
import render_machine.render_utils as render_utils
from plain2code_console import console
from render_machine.actions.base_action import BaseAction
from render_machine.render_context import RenderContext
from render_machine.render_types import RenderError
class PrepareTestingEnvironment(BaseAction):
SUCCESSFUL_OUTCOME = "testing_environment_prepared"
FAILED_OUTCOME = "testing_environment_preparation_failed"
def execute(self, render_context: RenderContext, _previous_action_payload: Any | None):
if render_context.verbose:
console.info(
f"Running testing environment preparation script {render_context.prepare_environment_script} for build folder {render_context.build_folder}."
)
exit_code, _, preparation_temp_file_path = render_utils.execute_script(
render_context.prepare_environment_script,
[render_context.build_folder],
render_context.verbose,
"Testing Environment Preparation",
)
render_context.conformance_tests_running_context.should_prepare_testing_environment = False
render_context.script_execution_history.latest_testing_environment_output_path = preparation_temp_file_path
render_context.script_execution_history.should_update_script_outputs = True
if exit_code == 0:
return self.SUCCESSFUL_OUTCOME, None
else:
return (
self.FAILED_OUTCOME,
RenderError.encode(
message="Testing environment preparation failed. Please check the preparation script.",
error_type="ENVIRONMENT_ERROR",
exit_code=exit_code,
script=render_context.prepare_environment_script,
).to_payload(),
)