Skip to content

Commit caae57e

Browse files
Go to straight to FINISHED_RENDER state after last functional requirement is implemented
1 parent 2d23644 commit caae57e

5 files changed

Lines changed: 12 additions & 18 deletions

File tree

‎_version.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.2.14"
1+
__version__ = "0.2.18"

‎plain_file.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ def plain_file_parser( # noqa: C901
649649
)
650650

651651
if not check_if_functional_requirements_are_specified(plain_file_parse_result.plain_source, []):
652-
raise PlainSyntaxError("Syntax error: No functionality specified.")
652+
raise PlainSyntaxError(f"Module '{module_name}' was required but does not contain functional requirements.")
653653

654654
exported_definitions = process_required_modules(
655655
plain_file_parse_result.required_modules,

‎render_machine/render_context.py‎

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,6 @@ def start_implementing_frid(self):
146146
else:
147147
frid = plain_spec.get_next_frid(self.plain_source_tree, self.frid_context.frid)
148148

149-
if frid is None:
150-
# If frid context is empty, it means that all frids have been implemented
151-
self.frid_context = None
152-
self.machine.dispatch(triggers.PREPARE_FINAL_OUTPUT)
153-
return
154-
155149
specifications, _ = plain_spec.get_specifications_for_frid(self.plain_source_tree, frid)
156150
functional_requirement_text = specifications[plain_spec.FUNCTIONAL_REQUIREMENTS][-1]
157151

@@ -172,10 +166,6 @@ def start_implementing_frid(self):
172166
return
173167

174168
def check_frid_iteration_limit(self):
175-
# If frid context is not set, it means that all frids have been implemented
176-
if self.frid_context is None:
177-
return
178-
179169
if self.frid_context.functional_requirement_render_attempts >= MAX_CODE_GENERATION_RETRIES:
180170
error_msg = f"Unittests could not be fixed after rendering the functionality {self.frid_context.frid} for the {MAX_CODE_GENERATION_RETRIES} times."
181171
self.dispatch_error(error_msg)
@@ -189,6 +179,9 @@ def check_frid_iteration_limit(self):
189179
f"Restarting rendering the functionality {self.frid_context.frid} from scratch."
190180
)
191181

182+
def has_next_frid(self) -> bool:
183+
return plain_spec.get_next_frid(self.plain_source_tree, self.frid_context.frid) is not None
184+
192185
def finish_implementing_frid(self):
193186
self.functional_requirements_render_attempts_failed_unit_during_conformance_tests = 0
194187
self.run_state.increment_rendered_functionalities()

‎render_machine/state_machine_config.py‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,11 +261,6 @@ def get_transitions(self) -> List[Dict[str, Any]]:
261261
"dest": f"{States.IMPLEMENTING_FRID.value}_{States.STEP_COMPLETED.value}",
262262
"unless": "should_run_unit_tests",
263263
},
264-
{
265-
"source": f"{States.IMPLEMENTING_FRID.value}",
266-
"trigger": triggers.PREPARE_FINAL_OUTPUT,
267-
"dest": States.RENDER_COMPLETED.value,
268-
},
269264
{
270265
"source": "*",
271266
"trigger": triggers.HANDLE_ERROR,
@@ -349,6 +344,13 @@ def get_transitions(self) -> List[Dict[str, Any]]:
349344
"source": f"{States.IMPLEMENTING_FRID.value}_{States.FRID_FULLY_IMPLEMENTED.value}",
350345
"trigger": triggers.PROCEED_FRID_PROCESSING,
351346
"dest": f"{States.IMPLEMENTING_FRID.value}",
347+
"conditions": "has_next_frid",
348+
},
349+
{
350+
"source": f"{States.IMPLEMENTING_FRID.value}_{States.FRID_FULLY_IMPLEMENTED.value}",
351+
"trigger": triggers.PROCEED_FRID_PROCESSING,
352+
"dest": States.RENDER_COMPLETED.value,
353+
"unless": "has_next_frid",
352354
},
353355
{
354356
"source": f"{States.IMPLEMENTING_FRID.value}_{States.REFACTORING_CODE.value}_{States.PROCESSING_UNIT_TESTS.value}_{States.UNIT_TESTS_READY.value}",

‎render_machine/triggers.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
MARK_UNIT_TESTS_FAILED = "mark_unit_tests_failed"
1313
MARK_UNIT_TESTS_PASSED = "mark_unit_tests_passed"
1414
MARK_UNIT_TESTS_READY = "mark_unit_tests_ready"
15-
PREPARE_FINAL_OUTPUT = "prepare_final_output"
1615
FINISH_RENDER = "finish_render"
1716
HANDLE_ERROR = "handle_error"
1817
REFACTOR_CODE = "refactor_code"

0 commit comments

Comments
 (0)