Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance test for post_pr_test_report to cover combination of --from-pr and --include-easyblocks-from-pr #3726

Merged
merged 4 commits into from
Jun 8, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion easybuild/tools/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def post_pr_test_report(pr_nr, repo_type, test_report, msg, init_session_state,

if build_option('include_easyblocks_from_pr'):
if repo_type == GITHUB_EASYCONFIGS_REPO:
easyblocks_pr_nrs = [int(eb_pr_nr) for eb_pr_nr in build_option('include_easyblocks_from_pr')]
easyblocks_pr_nrs = [int(x) for x in build_option('include_easyblocks_from_pr')]
boegel marked this conversation as resolved.
Show resolved Hide resolved
comment_lines.append("Using easyblocks from PR(s) %s" %
", ".join(["https://github.com/%s/%s/pull/%s" %
(pr_target_account, GITHUB_EASYBLOCKS_REPO, easyblocks_pr_nr)
Expand Down
23 changes: 22 additions & 1 deletion test/framework/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
from easybuild.base.rest import RestClient
from easybuild.framework.easyconfig.tools import categorize_files_by_type
from easybuild.tools.build_log import EasyBuildError
from easybuild.tools.config import build_option, module_classes
from easybuild.tools.config import build_option, module_classes, update_build_option
from easybuild.tools.configobj import ConfigObj
from easybuild.tools.filetools import read_file, write_file
from easybuild.tools.github import GITHUB_EASYCONFIGS_REPO, GITHUB_EASYBLOCKS_REPO, GITHUB_MERGEABLE_STATE_CLEAN
Expand Down Expand Up @@ -1051,6 +1051,27 @@ def test_pr_test_report(self):
regex = re.compile(pattern, re.M)
self.assertTrue(regex.search(stdout), "Pattern '%s' should be found in: %s" % (regex.pattern, stdout))

# also test combination of --from-pr and --include-easyblocks-from-pr
update_build_option('include_easyblocks_from_pr', ['6789'])

self.mock_stderr(True)
self.mock_stdout(True)
post_pr_test_report('1234', gh.GITHUB_EASYCONFIGS_REPO, test_report, "OK!", init_session_state, True)
stderr, stdout = self.get_stderr(), self.get_stdout()
self.mock_stderr(False)
self.mock_stdout(False)

self.assertEqual(stderr, '')

patterns = [
r"^\[DRY RUN\] Adding comment to easybuild-easyconfigs issue #1234: 'Test report by @easybuild_test",
r"^See https://gist.github.com/DRY_RUN for a full test report.'",
r"Using easyblocks from PR\(s\) https://github.com/easybuilders/easybuild-easyblocks/pull/6789",
]
for pattern in patterns:
regex = re.compile(pattern, re.M)
self.assertTrue(regex.search(stdout), "Pattern '%s' should be found in: %s" % (regex.pattern, stdout))

def test_create_test_report(self):
"""Test create_test_report function."""
logfile = os.path.join(self.test_prefix, 'log.txt')
Expand Down