Skip to content

Commit c0de937

Browse files
authored
Add more tests and start measuring coverage (#2486)
1 parent 319bdd7 commit c0de937

File tree

142 files changed

+51230
-143
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+51230
-143
lines changed

.github/workflows/test-process-pr.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ jobs:
2626
sparse-checkout: tests/Framework.py
2727
sparse-checkout-cone-mode: false
2828
- run: mv tmp/tests/Framework.py tests/
29-
- run: sed -i -e 's/pool_size=self.pool_size/per_page=100/g' tests/Framework.py
29+
- run: |
30+
cd tests
31+
patch -p0 < Framework.patch
3032
- name: Set up Python ${{ matrix.python-version }}
3133
uses: actions/setup-python@v4
3234
with:

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,10 @@
22
.idea
33
*.properties
44
tests/Framework.py
5-
venv
5+
venv*
66
GithubCredentials.py
7+
.coverage
8+
htmlcov
9+
/tests/ReplayData/TestProcessPr.test_mark_rejected.txt
10+
/tests/ReplayData/TestProcessPr.test_mark_passed.txt
11+
/tests/*.log

modify_comment.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,39 @@
77
from optparse import OptionParser
88
import sys
99
from socket import setdefaulttimeout
10+
import re
1011

1112
setdefaulttimeout(120)
1213
SCRIPT_DIR = dirname(abspath(sys.argv[0]))
1314

15+
16+
def find_last_comment(issue, user, match):
17+
last_comment = None
18+
for comment in issue.get_comments():
19+
if (user != comment.user.login) or (not comment.body):
20+
continue
21+
if not re.match(
22+
match, comment.body.encode("ascii", "ignore").decode().strip("\n\t\r "), re.MULTILINE
23+
):
24+
continue
25+
last_comment = comment
26+
print("Matched comment from %s with comment id %s" % (comment.user.login, comment.id))
27+
return last_comment
28+
29+
30+
def modify_comment(comment, match, replace, dryRun):
31+
comment_msg = comment.body.encode("ascii", "ignore").decode() if comment.body else ""
32+
if match:
33+
new_comment_msg = re.sub(match, replace, comment_msg)
34+
else:
35+
new_comment_msg = comment_msg + "\n" + replace
36+
if new_comment_msg != comment_msg:
37+
if not dryRun:
38+
comment.edit(new_comment_msg)
39+
print("Message updated")
40+
return 0
41+
42+
1443
valid_types = {}
1544
valid_types["JENKINS_TEST_URL"] = ["", None]
1645
valid_types["JENKINS_STYLE_URL"] = ["", None]
@@ -68,7 +97,6 @@
6897
if exists(join(repo_dir, "repo_config.py")):
6998
sys.path.insert(0, repo_dir)
7099
import repo_config
71-
from process_pr import modify_comment, find_last_comment
72100
from process_pr import TRIGERING_TESTS_MSG, TRIGERING_STYLE_TEST_MSG
73101

74102
valid_types["JENKINS_TEST_URL"] = ["^\\s*" + TRIGERING_TESTS_MSG + ".*$", None]

0 commit comments

Comments
 (0)