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

--new-pr can't be empty #1846

Merged
merged 4 commits into from
Aug 4, 2016
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: 2 additions & 0 deletions easybuild/tools/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,8 @@ def _easyconfigs_pr_common(paths, start_branch=None, pr_branch=None, target_acco
print_msg(git_repo.git.diff(cached=True) + '\n', log=_log, prefix=False)

diff_stat = git_repo.git.diff(cached=True, stat=True)
if not diff_stat:
raise EasyBuildError("No changed files found. Refused to make empty pull request.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clarify error message, somehow mention that you were comparing with current develop branch (but keep it short, people don't actually read long errors ;-))


# commit
if commit_msg:
Expand Down
32 changes: 30 additions & 2 deletions test/framework/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
from easybuild.tools.config import DEFAULT_MODULECLASSES
from easybuild.tools.config import find_last_log, get_build_log_path, get_module_syntax, module_classes
from easybuild.tools.environment import modify_env
from easybuild.tools.filetools import mkdir, read_file, write_file
from easybuild.tools.github import fetch_github_token
from easybuild.tools.filetools import download_file, mkdir, read_file, write_file
from easybuild.tools.github import GITHUB_RAW, GITHUB_EB_MAIN, GITHUB_EASYCONFIGS_REPO, URL_SEPARATOR, fetch_github_token
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long, stay under 120 chars

from easybuild.tools.options import EasyBuildOptions, parse_external_modules_metadata, set_tmpdir
from easybuild.tools.toolchain.utilities import TC_CONST_PREFIX
from easybuild.tools.run import run_cmd
Expand Down Expand Up @@ -2350,6 +2350,34 @@ def test_new_update_pr(self):
regex = re.compile(regex, re.M)
self.assertTrue(regex.search(txt), "Pattern '%s' found in: %s" % (regex.pattern, txt))

def test_empty_pr(self):
"""Test use of --new-pr (dry run only) with no changes"""
if self.github_token is None:
print "Skipping test_new_pr, no GitHub token available?"
return

# get file from develop branch
test_ecs_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'easyconfigs')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

download to self.test_prefix, that gets cleaned up automagically

otherwise if this test fails, the downloaded easyconfigs will stick around in test/framework/easyconfigs subdir

full_url = URL_SEPARATOR.join([GITHUB_RAW, GITHUB_EB_MAIN, GITHUB_EASYCONFIGS_REPO, 'develop/easybuild/easyconfigs/z/zlib/zlib-1.2.8.eb'])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tooooooo long

ec = download_file('zlib-1.2.8.eb', full_url, path=os.path.join(test_ecs_dir, 'zlib-1.2.8.eb'), forced=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try to use zlib-1.2.8.eb exactly once, i.e. add a variable for it (or derive from 'develop/easybuild/easyconfigs/z/zlib/zlib-1.2.8.eb' via os.path.basename


# try to open new pr with unchanged file
os.environ['EASYBUILD_GITHUB_USER'] = GITHUB_TEST_ACCOUNT
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use '--github-user=%s' % GITHUB_TEST_ACCOUNT in args below?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use --github-user=... below?

args = [
'--new-pr',
'--experimental',
ec,
'-D',
]

self.mock_stdout(True)
error_msg = 'No changed files found. Refused to make empty pull request.'
self.assertErrorRegex(EasyBuildError, error_msg, self.eb_main, args, do_build=True, raise_error=True)
self.mock_stdout(False)

os.remove(os.path.join(test_ecs_dir, 'zlib-1.2.8.eb'))


def test_show_config(self):
""""Test --show-config and --show-full-config."""

Expand Down