Skip to content

Commit

Permalink
[task] handle edge case of template missing the test description head…
Browse files Browse the repository at this point in the history
…er and with description header as last item
  • Loading branch information
pducolin committed Oct 31, 2024
1 parent 14087d6 commit 0d4dac5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tasks/github_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,9 +487,11 @@ def extract_test_qa_description(pr_body: str) -> str:
if line.startswith('### Describe how to test'):
index_of_test_qa_section = i
break
index_of_next_section = -1
if index_of_test_qa_section == -1:
return ''
index_of_next_section = len(pr_body_lines)
for i in range(index_of_test_qa_section + 1, len(pr_body_lines)):
if pr_body_lines[i].startswith('### Possible Drawbacks'):
if pr_body_lines[i].startswith('### '):
index_of_next_section = i
break
if index_of_next_section == -1:
Expand Down
23 changes: 23 additions & 0 deletions tasks/unit_tests/github_tasks_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,29 @@ class TestExtractBodyCase:
""",
expected="Here is a test description with special characters: `~!@#$,%^&*()_-+={[]}|\\:;\"'<>.?/",
),
TestExtractBodyCase(
name="Missing test description header",
body="""### What does this PR do?
### Motivation
### Possible Drawbacks / Trade-offs
### Additional Notes
""",
expected="",
),
TestExtractBodyCase(
name="Missing next section header",
body="""### What does this PR do?
### Motivation
### Describe how to test/QA your changes
Here is how to test this PR
""",
expected="Here is how to test this PR",
),
]

for tc in testcases:
Expand Down

0 comments on commit 0d4dac5

Please sign in to comment.