Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion render_machine/actions/exit_with_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def execute(self, render_context: RenderContext, previous_action_payload: Any |

if render_context.frid_context is not None:
console.info(
f"To continue rendering from the last successfully rendered functional requirement, provide the [red]--render-from {render_context.frid_context.frid}[/b][/red] flag."
f"To continue rendering from the last successfully rendered functional requirement, provide the [red]--render-from {render_context.frid_context.frid}[/red] flag."
)

if render_context.run_state.render_id is not None:
Expand Down
8 changes: 8 additions & 0 deletions render_machine/actions/prepare_testing_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import render_machine.render_utils as render_utils
from plain2code_console import console
from plain2code_events import RenderStateUpdated
from render_machine.actions.base_action import BaseAction
from render_machine.render_context import RenderContext
from render_machine.render_types import RenderError
Expand All @@ -26,6 +27,13 @@ def execute(self, render_context: RenderContext, _previous_action_payload: Any |
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
render_context.event_bus.publish(
RenderStateUpdated(
state=render_context.state,
previous_state=render_context.previous_state,
snapshot=render_context.create_snapshot(),
)
)
if exit_code == 0:
return self.SUCCESSFUL_OUTCOME, None
else:
Expand Down
13 changes: 11 additions & 2 deletions render_machine/actions/run_conformance_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import render_machine.render_utils as render_utils
from plain2code_console import console
from plain2code_events import RenderStateUpdated
from render_machine.actions.base_action import BaseAction
from render_machine.render_context import RenderContext
from render_machine.render_types import RenderError
Expand Down Expand Up @@ -52,18 +53,26 @@ def execute(self, render_context: RenderContext, _previous_action_payload: Any |
render_context, exit_code, conformance_tests_issue
)

render_context.event_bus.publish(
RenderStateUpdated(
state=render_context.state,
previous_state=render_context.previous_state,
snapshot=render_context.create_snapshot(),
)
)

if exit_code == 0:
conformance_tests_issue = "All conformance tests passed successfully!"

if exit_code == 0:
return self.SUCCESSFUL_OUTCOME, None

if exit_code in UNRECOVERABLE_ERROR_EXIT_CODES:
console.error(conformance_tests_issue)
console.error(f"[red]{conformance_tests_issue}[/red]")
return (
self.UNRECOVERABLE_ERROR_OUTCOME,
RenderError.encode(
message=conformance_tests_issue,
message="Conformance tests script failed with an unrecoverable error.\nPlease check your conformance test script output for more details.",
error_type="ENVIRONMENT_ERROR",
exit_code=exit_code,
script=render_context.conformance_tests_script,
Expand Down
12 changes: 10 additions & 2 deletions render_machine/actions/run_unit_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import render_machine.render_utils as render_utils
from plain2code_console import console
from plain2code_events import RenderStateUpdated
from render_machine.actions.base_action import BaseAction
from render_machine.render_context import RenderContext
from render_machine.render_types import RenderError
Expand All @@ -28,15 +29,22 @@ def execute(self, render_context: RenderContext, _previous_action_payload: Any |

render_context.script_execution_history.latest_unit_test_output_path = unittests_temp_file_path
render_context.script_execution_history.should_update_script_outputs = True
render_context.event_bus.publish(
RenderStateUpdated(
state=render_context.state,
previous_state=render_context.previous_state,
snapshot=render_context.create_snapshot(),
)
)
if exit_code == 0:
return self.SUCCESSFUL_OUTCOME, None

elif exit_code in UNRECOVERABLE_ERROR_EXIT_CODES:
console.error(unittests_issue)
console.error(f"[red]{unittests_issue}[/red]")
return (
self.UNRECOVERABLE_ERROR_OUTCOME,
RenderError.encode(
message="Unit tests script failed due to problems in the environment setup. Please check your environment or update the script for running unittests.",
message="Unit tests script failed with an unrecoverable error.\nPlease check your unit test script output for more details.",
error_type="ENVIRONMENT_ERROR",
exit_code=exit_code,
script=render_context.unittests_script,
Expand Down
1 change: 1 addition & 0 deletions render_machine/code_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def run(self):
)
)
previous_state = deepcopy(self.render_context.state)
self.render_context.previous_state = previous_state
self.render_context.script_execution_history.should_update_script_outputs = False
# Reset error message at start of each iteration to prevent stale data
self.render_context.last_error_message = None
Expand Down
2 changes: 2 additions & 0 deletions render_machine/render_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ def __init__(
self.script_execution_history = ScriptExecutionHistory()
self.starting_frid = None

self.previous_state = None

resources_list = []
plain_spec.collect_linked_resources(plain_source_tree, resources_list, None, True)
self.all_linked_resources = file_utils.load_linked_resources(template_dirs, resources_list)
Expand Down