Skip to content
Merged
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
7 changes: 5 additions & 2 deletions plain2code.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import subprocess
import sys
import tempfile
import time
import traceback

import yaml
Expand Down Expand Up @@ -32,7 +33,7 @@
MAX_REFACTORING_ITERATIONS = 5
MAX_UNIT_TEST_RENDER_RETRIES = 2

MAX_ISSUE_LENGTH = 10000 # Characters.
MAX_ISSUE_LENGTH = 15000 # Characters.

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

def execute_test_script(test_script, scripts_args, verbose, test_type):
try:
start_time = time.time()
result = subprocess.run(
[file_utils.add_current_path_if_no_path(test_script)] + scripts_args,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
text=True,
timeout=TEST_SCRIPT_EXECUTION_TIMEOUT,
)

elapsed_time = time.time() - start_time
# Log the info about the tests
if verbose:
with tempfile.NamedTemporaryFile(mode="w+", delete=False, suffix=".test_output") as temp_file:
Expand All @@ -97,6 +99,7 @@ def execute_test_script(test_script, scripts_args, verbose, test_type):
temp_file.write(f"Test script {test_script} failed with exit code {result.returncode}.\n")
else:
temp_file.write(f"Test script {test_script} successfully passed.\n")
temp_file.write(f"Test execution time: {elapsed_time:.2f} seconds.\n")

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

Expand Down
31 changes: 16 additions & 15 deletions plain_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,21 @@ def collect_specification_linked_resources(specification, specification_heading,
def collect_linked_resources_in_section(
section, linked_resources_list, specifications_list, include_acceptance_tests, frid=Optional[str]
):
# When should we collect resources in the current section (should_collect_resources_in_current_section):
# When should we collect specification headings in the current section. Either when one of the following holds true:
# - frid wasn't specified
# - section has no ID <==> it's the root section
# - section has no ID (and that's exactly when it's the root section)
# - section has ID, frid was specified and the specified frid inside the current section tree
should_collect_resources_in_current_section = frid is None or "ID" not in section or frid.startswith(section["ID"])
if not should_collect_resources_in_current_section:
return False

specifications_to_collect = list(set([DEFINITIONS, NON_FUNCTIONAL_REQUIREMENTS, TEST_REQUIREMENTS]))
if specifications_list:
specifications_to_collect = list(set(specifications_to_collect) & set(specifications_list))

for specification_heading in specifications_to_collect:
if specification_heading in section:
for requirement in section[specification_heading]:
collect_specification_linked_resources(requirement, specification_heading, linked_resources_list)
should_collect_specification_headings_in_current_section = (
frid is None or "ID" not in section or frid.startswith(section["ID"])
)
if should_collect_specification_headings_in_current_section:
specifications_to_collect = list(set([DEFINITIONS, NON_FUNCTIONAL_REQUIREMENTS, TEST_REQUIREMENTS]))
if specifications_list:
specifications_to_collect = list(set(specifications_to_collect) & set(specifications_list))
for specification_heading in specifications_to_collect:
if specification_heading in section:
for requirement in section[specification_heading]:
collect_specification_linked_resources(requirement, specification_heading, linked_resources_list)

if FUNCTIONAL_REQUIREMENTS in section and (
not specifications_list or FUNCTIONAL_REQUIREMENTS in specifications_list
Expand All @@ -97,7 +96,9 @@ def collect_linked_resources_in_section(
acceptance_test, FUNCTIONAL_REQUIREMENTS, linked_resources_list
)

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

if "sections" in section:
Expand Down