Skip to content

Commit 7a39ece

Browse files
author
Tjaz Erzen
committed
In case of unrecoverable exit codes, display also latest script paths
1 parent d548252 commit 7a39ece

4 files changed

Lines changed: 24 additions & 4 deletions

File tree

render_machine/actions/run_conformance_tests.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import render_machine.render_utils as render_utils
44
from plain2code_console import console
5+
from plain2code_events import RenderStateUpdated
56
from render_machine.actions.base_action import BaseAction
67
from render_machine.render_context import RenderContext
78
from render_machine.render_types import RenderError
@@ -52,18 +53,26 @@ def execute(self, render_context: RenderContext, _previous_action_payload: Any |
5253
render_context, exit_code, conformance_tests_issue
5354
)
5455

56+
render_context.event_bus.publish(
57+
RenderStateUpdated(
58+
state=render_context.state,
59+
previous_state=render_context.previous_state,
60+
snapshot=render_context.create_snapshot(),
61+
)
62+
)
63+
5564
if exit_code == 0:
5665
conformance_tests_issue = "All conformance tests passed successfully!"
5766

5867
if exit_code == 0:
5968
return self.SUCCESSFUL_OUTCOME, None
6069

6170
if exit_code in UNRECOVERABLE_ERROR_EXIT_CODES:
62-
console.error(conformance_tests_issue)
71+
console.error(f"[red]{conformance_tests_issue}[/red]")
6372
return (
6473
self.UNRECOVERABLE_ERROR_OUTCOME,
6574
RenderError.encode(
66-
message=conformance_tests_issue,
75+
message="Conformance tests script failed with an unrecoverable error.\nPlease check your conformance test script output for more details.",
6776
error_type="ENVIRONMENT_ERROR",
6877
exit_code=exit_code,
6978
script=render_context.conformance_tests_script,

render_machine/actions/run_unit_tests.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import render_machine.render_utils as render_utils
44
from plain2code_console import console
5+
from plain2code_events import RenderStateUpdated
56
from render_machine.actions.base_action import BaseAction
67
from render_machine.render_context import RenderContext
78
from render_machine.render_types import RenderError
@@ -28,15 +29,22 @@ def execute(self, render_context: RenderContext, _previous_action_payload: Any |
2829

2930
render_context.script_execution_history.latest_unit_test_output_path = unittests_temp_file_path
3031
render_context.script_execution_history.should_update_script_outputs = True
32+
render_context.event_bus.publish(
33+
RenderStateUpdated(
34+
state=render_context.state,
35+
previous_state=render_context.previous_state,
36+
snapshot=render_context.create_snapshot(),
37+
)
38+
)
3139
if exit_code == 0:
3240
return self.SUCCESSFUL_OUTCOME, None
3341

3442
elif exit_code in UNRECOVERABLE_ERROR_EXIT_CODES:
35-
console.error(unittests_issue)
43+
console.error(f"[red]{unittests_issue}[/red]")
3644
return (
3745
self.UNRECOVERABLE_ERROR_OUTCOME,
3846
RenderError.encode(
39-
message="Unit tests script failed due to problems in the environment setup. Please check your environment or update the script for running unittests.",
47+
message="Unit tests script failed with an unrecoverable error.\nPlease check your unit test script output for more details.",
4048
error_type="ENVIRONMENT_ERROR",
4149
exit_code=exit_code,
4250
script=render_context.unittests_script,

render_machine/code_renderer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def run(self):
4444
)
4545
)
4646
previous_state = deepcopy(self.render_context.state)
47+
self.render_context.previous_state = previous_state
4748
self.render_context.script_execution_history.should_update_script_outputs = False
4849
# Reset error message at start of each iteration to prevent stale data
4950
self.render_context.last_error_message = None

render_machine/render_context.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ def __init__(
7676
self.script_execution_history = ScriptExecutionHistory()
7777
self.starting_frid = None
7878

79+
self.previous_state = None
80+
7981
resources_list = []
8082
plain_spec.collect_linked_resources(plain_source_tree, resources_list, None, True)
8183
self.all_linked_resources = file_utils.load_linked_resources(template_dirs, resources_list)

0 commit comments

Comments
 (0)