Skip to content

Commit cf73295

Browse files
authored
Merge pull request #24 from Codeplain-ai/08-11-deploy
Minor bugfixes and improvements
2 parents e340bef + e2fb7c0 commit cf73295

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

plain2code.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import subprocess
66
import sys
77
import tempfile
8+
import time
89
import traceback
910

1011
import yaml
@@ -32,7 +33,7 @@
3233
MAX_REFACTORING_ITERATIONS = 5
3334
MAX_UNIT_TEST_RENDER_RETRIES = 2
3435

35-
MAX_ISSUE_LENGTH = 10000 # Characters.
36+
MAX_ISSUE_LENGTH = 15000 # Characters.
3637

3738
UNRECOVERABLE_ERROR_EXIT_CODES = [69]
3839
TIMEOUT_ERROR_EXIT_CODE = 124
@@ -78,14 +79,15 @@ def _get_frids_range(plain_source_tree, start, end=None):
7879

7980
def execute_test_script(test_script, scripts_args, verbose, test_type):
8081
try:
82+
start_time = time.time()
8183
result = subprocess.run(
8284
[file_utils.add_current_path_if_no_path(test_script)] + scripts_args,
8385
stdout=subprocess.PIPE,
8486
stderr=subprocess.STDOUT,
8587
text=True,
8688
timeout=TEST_SCRIPT_EXECUTION_TIMEOUT,
8789
)
88-
90+
elapsed_time = time.time() - start_time
8991
# Log the info about the tests
9092
if verbose:
9193
with tempfile.NamedTemporaryFile(mode="w+", delete=False, suffix=".test_output") as temp_file:
@@ -97,6 +99,7 @@ def execute_test_script(test_script, scripts_args, verbose, test_type):
9799
temp_file.write(f"Test script {test_script} failed with exit code {result.returncode}.\n")
98100
else:
99101
temp_file.write(f"Test script {test_script} successfully passed.\n")
102+
temp_file.write(f"Test execution time: {elapsed_time:.2f} seconds.\n")
100103

101104
console.info(f"[b]Test output stored in: {temp_file_path}[/b]")
102105

plain_spec.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,22 +63,21 @@ def collect_specification_linked_resources(specification, specification_heading,
6363
def collect_linked_resources_in_section(
6464
section, linked_resources_list, specifications_list, include_acceptance_tests, frid=Optional[str]
6565
):
66-
# When should we collect resources in the current section (should_collect_resources_in_current_section):
66+
# When should we collect specification headings in the current section. Either when one of the following holds true:
6767
# - frid wasn't specified
68-
# - section has no ID <==> it's the root section
68+
# - section has no ID (and that's exactly when it's the root section)
6969
# - section has ID, frid was specified and the specified frid inside the current section tree
70-
should_collect_resources_in_current_section = frid is None or "ID" not in section or frid.startswith(section["ID"])
71-
if not should_collect_resources_in_current_section:
72-
return False
73-
74-
specifications_to_collect = list(set([DEFINITIONS, NON_FUNCTIONAL_REQUIREMENTS, TEST_REQUIREMENTS]))
75-
if specifications_list:
76-
specifications_to_collect = list(set(specifications_to_collect) & set(specifications_list))
77-
78-
for specification_heading in specifications_to_collect:
79-
if specification_heading in section:
80-
for requirement in section[specification_heading]:
81-
collect_specification_linked_resources(requirement, specification_heading, linked_resources_list)
70+
should_collect_specification_headings_in_current_section = (
71+
frid is None or "ID" not in section or frid.startswith(section["ID"])
72+
)
73+
if should_collect_specification_headings_in_current_section:
74+
specifications_to_collect = list(set([DEFINITIONS, NON_FUNCTIONAL_REQUIREMENTS, TEST_REQUIREMENTS]))
75+
if specifications_list:
76+
specifications_to_collect = list(set(specifications_to_collect) & set(specifications_list))
77+
for specification_heading in specifications_to_collect:
78+
if specification_heading in section:
79+
for requirement in section[specification_heading]:
80+
collect_specification_linked_resources(requirement, specification_heading, linked_resources_list)
8281

8382
if FUNCTIONAL_REQUIREMENTS in section and (
8483
not specifications_list or FUNCTIONAL_REQUIREMENTS in specifications_list
@@ -97,7 +96,9 @@ def collect_linked_resources_in_section(
9796
acceptance_test, FUNCTIONAL_REQUIREMENTS, linked_resources_list
9897
)
9998

100-
if current_frid == frid:
99+
if frid is not None and current_frid == frid:
100+
# here, we rely on the fact that FRIDs are incrementing. And if we have reached the current FRID, we should
101+
# not collect any FRIDs after the current one.
101102
return True
102103

103104
if "sections" in section:

0 commit comments

Comments
 (0)