diff --git a/codeplain_REST_api.py b/codeplain_REST_api.py index 5b8f7d2..bdd05e0 100644 --- a/codeplain_REST_api.py +++ b/codeplain_REST_api.py @@ -350,6 +350,7 @@ def fix_conformance_tests_issue( implementation_fix_count, conformance_tests_folder_name, current_testing_frid_high_level_implementation_plan: Optional[str], + conflicting_requirements_count: int, run_state: RunState, ): endpoint_url = f"{self.api_url}/fix_conformance_tests_issue" @@ -371,6 +372,7 @@ def fix_conformance_tests_issue( "implementation_fix_count": implementation_fix_count, "conformance_tests_folder_name": conformance_tests_folder_name, "current_testing_frid_high_level_implementation_plan": current_testing_frid_high_level_implementation_plan, + "conflicting_requirements_count": conflicting_requirements_count, } if acceptance_tests is not None: diff --git a/render_machine/actions/fix_conformance_test.py b/render_machine/actions/fix_conformance_test.py index 076c195..2ad4429 100644 --- a/render_machine/actions/fix_conformance_test.py +++ b/render_machine/actions/fix_conformance_test.py @@ -15,6 +15,10 @@ class FixConformanceTest(BaseAction): IMPLEMENTATION_CODE_NOT_UPDATED = "implementation_code_not_updated" IMPLEMENTATION_CODE_UPDATED = "implementation_code_updated" + ISSUE_REASON_CODE_CONFORMANCE_TESTS = 0 + ISSUE_REASON_CODE_IMPLEMENTATION_CODE = 1 + ISSUE_REASON_CODE_CONFLICTING_REQUIREMENTS = 2 + def execute(self, render_context: RenderContext, previous_action_payload: Any | None): console.info( f"Fixing conformance test for functionality {render_context.conformance_tests_running_context.current_testing_frid} in module {render_context.conformance_tests_running_context.current_testing_module_name}." @@ -53,6 +57,15 @@ def execute(self, render_context: RenderContext, previous_action_payload: Any | render_context.build_folder, render_context.plain_source_tree, render_context.frid_context.frid ) + conflicting_module_name = render_context.conformance_tests_running_context.conflicting_module_name + conflicting_frid = render_context.conformance_tests_running_context.conflicting_frid + current_testing_module_name = render_context.conformance_tests_running_context.current_testing_module_name + current_testing_frid = render_context.conformance_tests_running_context.current_testing_frid + + # Reset the conflicting requirement count if the current testing functionality is not the same as the previously conflicting functionality + if conflicting_module_name != current_testing_module_name or conflicting_frid != current_testing_frid: + render_context.conformance_tests_running_context.conflicting_requirement_count = 0 + if render_context.verbose: tmp_resources_list = [] plain_spec.collect_linked_resources( @@ -79,7 +92,7 @@ def execute(self, render_context: RenderContext, previous_action_payload: Any | ) with console.status(console_message): - [conformance_tests_fixed, response_files] = render_context.codeplain_api.fix_conformance_tests_issue( + [issue_reason_code, response_files] = render_context.codeplain_api.fix_conformance_tests_issue( render_context.frid_context.frid, render_context.conformance_tests_running_context.current_testing_frid, render_context.plain_source_tree, @@ -96,11 +109,23 @@ def execute(self, render_context: RenderContext, previous_action_payload: Any | render_context.conformance_tests_running_context.fix_attempts, render_context.conformance_tests_running_context.get_current_conformance_test_folder_name(), render_context.conformance_tests_running_context.current_testing_frid_high_level_implementation_plan, + render_context.conformance_tests_running_context.conflicting_requirement_count, run_state=render_context.run_state, ) code_diff_files_content = {} - if conformance_tests_fixed: + if issue_reason_code == self.ISSUE_REASON_CODE_CONFLICTING_REQUIREMENTS: + render_context.conformance_tests_running_context.conflicting_requirement_count += 1 + render_context.conformance_tests_running_context.conflicting_module_name = current_testing_module_name + render_context.conformance_tests_running_context.conflicting_frid = current_testing_frid + console.info( + f"Potential conflicting functionalities detected while fixing conformance tests for functionality {current_testing_frid} in module {current_testing_module_name}." + ) + + if ( + issue_reason_code == self.ISSUE_REASON_CODE_CONFORMANCE_TESTS + or issue_reason_code == self.ISSUE_REASON_CODE_CONFLICTING_REQUIREMENTS + ): render_context.conformance_tests.store_conformance_tests_files( render_context.module_name, render_context.required_modules, diff --git a/render_machine/render_types.py b/render_machine/render_types.py index 91c17d5..234c6e5 100644 --- a/render_machine/render_types.py +++ b/render_machine/render_types.py @@ -32,6 +32,9 @@ def __init__( current_testing_frid_specifications: Optional[dict[str, list]], conformance_test_phase_index: int, should_prepare_testing_environment: bool, + conflicting_requirement_count: int = 0, + conflicting_module_name: Optional[str] = None, + conflicting_frid: Optional[str] = None, ): self.current_testing_module_name = current_testing_module_name self.current_testing_frid = current_testing_frid @@ -41,7 +44,9 @@ def __init__( self.current_testing_frid_specifications = current_testing_frid_specifications self.conformance_test_phase_index = conformance_test_phase_index self.should_prepare_testing_environment = should_prepare_testing_environment - + self.conflicting_requirement_count = conflicting_requirement_count + self.conflicting_module_name = conflicting_module_name + self.conflicting_frid = conflicting_frid # will be propagated only when: # - current_testing_frid == frid noqa: E800 # - conformance_test_phase_index == 0 (conformance tests phase)