Skip to content

Commit ee878ca

Browse files
committed
enhance test for post_pr_test_report to cover combination of --from-pr and --include-easyblocks-from-pr
1 parent 22b9603 commit ee878ca

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

easybuild/tools/testing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ def post_pr_test_report(pr_nr, repo_type, test_report, msg, init_session_state,
295295

296296
if build_option('include_easyblocks_from_pr'):
297297
if repo_type == GITHUB_EASYCONFIGS_REPO:
298-
easyblocks_pr_nrs = [int(eb_pr_nr) for eb_pr_nr in build_option('include_easyblocks_from_pr')]
298+
easyblocks_pr_nrs = [int(x) for x in build_option('include_easyblocks_from_pr')]
299299
comment_lines.append("Using easyblocks from PR(s) %s" %
300300
", ".join(["https://github.com/%s/%s/pull/%s" %
301301
(pr_target_account, GITHUB_EASYBLOCKS_REPO, easyblocks_pr_nr)

test/framework/github.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
from easybuild.base.rest import RestClient
4242
from easybuild.framework.easyconfig.tools import categorize_files_by_type
4343
from easybuild.tools.build_log import EasyBuildError
44-
from easybuild.tools.config import build_option, module_classes
44+
from easybuild.tools.config import build_option, module_classes, update_build_option
4545
from easybuild.tools.configobj import ConfigObj
4646
from easybuild.tools.filetools import read_file, write_file
4747
from easybuild.tools.github import GITHUB_EASYCONFIGS_REPO, GITHUB_EASYBLOCKS_REPO, GITHUB_MERGEABLE_STATE_CLEAN
@@ -1051,6 +1051,27 @@ def test_pr_test_report(self):
10511051
regex = re.compile(pattern, re.M)
10521052
self.assertTrue(regex.search(stdout), "Pattern '%s' should be found in: %s" % (regex.pattern, stdout))
10531053

1054+
# also test combination of --from-pr and --include-easyblocks-from-pr
1055+
update_build_option('include_easyblocks_from_pr', ['6789'])
1056+
1057+
self.mock_stderr(True)
1058+
self.mock_stdout(True)
1059+
post_pr_test_report('1234', gh.GITHUB_EASYCONFIGS_REPO, test_report, "OK!", init_session_state, True)
1060+
stderr, stdout = self.get_stderr(), self.get_stdout()
1061+
self.mock_stderr(False)
1062+
self.mock_stdout(False)
1063+
1064+
self.assertEqual(stderr, '')
1065+
1066+
patterns = [
1067+
r"^\[DRY RUN\] Adding comment to easybuild-easyconfigs issue #1234: 'Test report by @easybuild_test",
1068+
r"^See https://gist.github.com/DRY_RUN for a full test report.'",
1069+
r"Using easyblocks from PR\(s\) https://github.com/easybuilders/easybuild-easyblocks/pull/6789",
1070+
]
1071+
for pattern in patterns:
1072+
regex = re.compile(pattern, re.M)
1073+
self.assertTrue(regex.search(stdout), "Pattern '%s' should be found in: %s" % (regex.pattern, stdout))
1074+
10541075
def test_create_test_report(self):
10551076
"""Test create_test_report function."""
10561077
logfile = os.path.join(self.test_prefix, 'log.txt')

0 commit comments

Comments
 (0)