-
-
Notifications
You must be signed in to change notification settings - Fork 60
cherry-picker: Run Travis CI test on Windows #311
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5eb4d83
cherry-picker: Run Travis CI test on Windows
encukou c9a3c8b
Use explicit block literal in before_install in Travis
webknjaz 3cefad1
Use declarative way of setting up env vars
webknjaz bcb89e3
🐛✅ Set up Git user name and email in tests
webknjaz ae151c6
✅🎨 Use fixtures in find config tests
webknjaz 0263b57
✅🎨 Use fixtures in load config tests
webknjaz 683c3a8
🚑Use pathlib's write_text for saving test config
webknjaz e7c0d2b
🚑 Use UTF-8 encoding for saving test config
webknjaz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,9 +84,19 @@ def git_cherry_pick(): | |
|
||
|
||
@pytest.fixture | ||
def tmp_git_repo_dir(tmpdir, cd, git_init, git_commit): | ||
def git_config(): | ||
git_config_cmd = 'git', 'config' | ||
return lambda *extra_args: ( | ||
subprocess.run(git_config_cmd + extra_args, check=True) | ||
) | ||
|
||
|
||
@pytest.fixture | ||
def tmp_git_repo_dir(tmpdir, cd, git_init, git_commit, git_config): | ||
cd(tmpdir) | ||
git_init() | ||
git_config('--local', 'user.name', 'Monty Python') | ||
git_config('--local', 'user.email', '[email protected]') | ||
git_commit('Initial commit', '--allow-empty') | ||
yield tmpdir | ||
|
||
|
@@ -258,22 +268,16 @@ def test_is_not_cpython_repo(): | |
["3.6"]) | ||
|
||
|
||
def test_find_config(tmpdir, cd): | ||
cd(tmpdir) | ||
subprocess.run('git init .'.split(), check=True) | ||
def test_find_config(tmp_git_repo_dir, git_add, git_commit): | ||
relative_config_path = '.cherry_picker.toml' | ||
cfg = tmpdir.join(relative_config_path) | ||
cfg.write('param = 1') | ||
subprocess.run('git add .'.split(), check=True) | ||
subprocess.run(('git', 'commit', '-m', 'Initial commit'), check=True) | ||
tmp_git_repo_dir.join(relative_config_path).write('param = 1') | ||
git_add(relative_config_path) | ||
git_commit('Add config') | ||
scm_revision = get_sha1_from('HEAD') | ||
assert find_config(scm_revision) == scm_revision + ':' + relative_config_path | ||
assert find_config(scm_revision) == f'{scm_revision}:{relative_config_path}' | ||
|
||
|
||
def test_find_config_not_found(tmpdir, cd): | ||
cd(tmpdir) | ||
subprocess.run('git init .'.split(), check=True) | ||
subprocess.run(('git', 'commit', '-m', 'Initial commit', '--allow-empty'), check=True) | ||
def test_find_config_not_found(tmp_git_repo_dir): | ||
scm_revision = get_sha1_from('HEAD') | ||
assert find_config(scm_revision) is None | ||
|
||
|
@@ -283,19 +287,16 @@ def test_find_config_not_git(tmpdir, cd): | |
assert find_config(None) is None | ||
|
||
|
||
def test_load_full_config(tmpdir, cd): | ||
cd(tmpdir) | ||
subprocess.run('git init .'.split(), check=True) | ||
def test_load_full_config(tmp_git_repo_dir, git_add, git_commit): | ||
relative_config_path = '.cherry_picker.toml' | ||
cfg = tmpdir.join(relative_config_path) | ||
cfg.write('''\ | ||
tmp_git_repo_dir.join(relative_config_path).write('''\ | ||
team = "python" | ||
repo = "core-workfolow" | ||
check_sha = "5f007046b5d4766f971272a0cc99f8461215c1ec" | ||
default_branch = "devel" | ||
''') | ||
subprocess.run('git add .'.split(), check=True) | ||
subprocess.run(('git', 'commit', '-m', 'Initial commit'), check=True) | ||
git_add(relative_config_path) | ||
git_commit('Add config') | ||
scm_revision = get_sha1_from('HEAD') | ||
cfg = load_config(None) | ||
assert cfg == ( | ||
|
@@ -310,16 +311,13 @@ def test_load_full_config(tmpdir, cd): | |
) | ||
|
||
|
||
def test_load_partial_config(tmpdir, cd): | ||
cd(tmpdir) | ||
subprocess.run('git init .'.split(), check=True) | ||
def test_load_partial_config(tmp_git_repo_dir, git_add, git_commit): | ||
relative_config_path = '.cherry_picker.toml' | ||
cfg = tmpdir.join(relative_config_path) | ||
cfg.write('''\ | ||
tmp_git_repo_dir.join(relative_config_path).write('''\ | ||
repo = "core-workfolow" | ||
''') | ||
subprocess.run('git add .'.split(), check=True) | ||
subprocess.run(('git', 'commit', '-m', 'Initial commit'), check=True) | ||
git_add(relative_config_path) | ||
git_commit('Add config') | ||
scm_revision = get_sha1_from('HEAD') | ||
cfg = load_config(relative_config_path) | ||
assert cfg == ( | ||
|
@@ -417,7 +415,9 @@ def test_from_git_rev_read_negative( | |
def test_from_git_rev_read_uncommitted(tmp_git_repo_dir, git_add, git_commit): | ||
some_text = 'blah blah 🤖' | ||
relative_file_path = '.some.file' | ||
tmp_git_repo_dir.join(relative_file_path).write(some_text) | ||
( | ||
pathlib.Path(tmp_git_repo_dir) / relative_file_path | ||
).write_text(some_text, encoding='utf-8') | ||
git_add('.') | ||
with pytest.raises(ValueError): | ||
from_git_rev_read('HEAD:' + relative_file_path) == some_text | ||
|
@@ -426,7 +426,9 @@ def test_from_git_rev_read_uncommitted(tmp_git_repo_dir, git_add, git_commit): | |
def test_from_git_rev_read(tmp_git_repo_dir, git_add, git_commit): | ||
some_text = 'blah blah 🤖' | ||
relative_file_path = '.some.file' | ||
tmp_git_repo_dir.join(relative_file_path).write(some_text) | ||
( | ||
pathlib.Path(tmp_git_repo_dir) / relative_file_path | ||
).write_text(some_text, encoding='utf-8') | ||
git_add('.') | ||
git_commit('Add some file') | ||
assert from_git_rev_read('HEAD:' + relative_file_path) == some_text | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.