Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9cf0ac1

Browse filesBrowse files
encukouMariatta
authored andcommitted
cherry-picker: Run Travis CI test on Windows (#311)
1 parent b3c68fe commit 9cf0ac1
Copy full SHA for 9cf0ac1

File tree

2 files changed

+46
-30
lines changed
Filter options

2 files changed

+46
-30
lines changed

‎.travis.yml

Copy file name to clipboardExpand all lines: .travis.yml
+15-1Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ sudo: false
77
cache: pip
88

99
before_install:
10-
- pip install --upgrade flit
10+
- &install-flit >-
11+
pip install --upgrade flit
1112

1213
.mixtures:
1314
- &run-if-tagged
@@ -99,6 +100,19 @@ jobs:
99100
env:
100101
TARGET_PKG: cherry_picker
101102

103+
- os: windows
104+
language: sh
105+
python: 3.7
106+
before_install:
107+
- choco install python --version 3.7
108+
- python -m pip install --upgrade pip wheel
109+
- *install-flit
110+
<<: *install-and-test-cherry-picker
111+
env:
112+
PATH: >-
113+
/c/Python37:/c/Python37/Scripts:$PATH
114+
TARGET_PKG: cherry_picker
115+
102116
- <<: *deploy-base
103117
<<: *run-if-blurb
104118
if: 1 != 1

‎cherry_picker/cherry_picker/test.py

Copy file name to clipboardExpand all lines: cherry_picker/cherry_picker/test.py
+31-29Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,19 @@ def git_cherry_pick():
8484

8585

8686
@pytest.fixture
87-
def tmp_git_repo_dir(tmpdir, cd, git_init, git_commit):
87+
def git_config():
88+
git_config_cmd = 'git', 'config'
89+
return lambda *extra_args: (
90+
subprocess.run(git_config_cmd + extra_args, check=True)
91+
)
92+
93+
94+
@pytest.fixture
95+
def tmp_git_repo_dir(tmpdir, cd, git_init, git_commit, git_config):
8896
cd(tmpdir)
8997
git_init()
98+
git_config('--local', 'user.name', 'Monty Python')
99+
git_config('--local', 'user.email', 'bot@python.org')
90100
git_commit('Initial commit', '--allow-empty')
91101
yield tmpdir
92102

@@ -258,22 +268,16 @@ def test_is_not_cpython_repo():
258268
["3.6"])
259269

260270

261-
def test_find_config(tmpdir, cd):
262-
cd(tmpdir)
263-
subprocess.run('git init .'.split(), check=True)
271+
def test_find_config(tmp_git_repo_dir, git_add, git_commit):
264272
relative_config_path = '.cherry_picker.toml'
265-
cfg = tmpdir.join(relative_config_path)
266-
cfg.write('param = 1')
267-
subprocess.run('git add .'.split(), check=True)
268-
subprocess.run(('git', 'commit', '-m', 'Initial commit'), check=True)
273+
tmp_git_repo_dir.join(relative_config_path).write('param = 1')
274+
git_add(relative_config_path)
275+
git_commit('Add config')
269276
scm_revision = get_sha1_from('HEAD')
270-
assert find_config(scm_revision) == scm_revision + ':' + relative_config_path
277+
assert find_config(scm_revision) == f'{scm_revision}:{relative_config_path}'
271278

272279

273-
def test_find_config_not_found(tmpdir, cd):
274-
cd(tmpdir)
275-
subprocess.run('git init .'.split(), check=True)
276-
subprocess.run(('git', 'commit', '-m', 'Initial commit', '--allow-empty'), check=True)
280+
def test_find_config_not_found(tmp_git_repo_dir):
277281
scm_revision = get_sha1_from('HEAD')
278282
assert find_config(scm_revision) is None
279283

@@ -283,19 +287,16 @@ def test_find_config_not_git(tmpdir, cd):
283287
assert find_config(None) is None
284288

285289

286-
def test_load_full_config(tmpdir, cd):
287-
cd(tmpdir)
288-
subprocess.run('git init .'.split(), check=True)
290+
def test_load_full_config(tmp_git_repo_dir, git_add, git_commit):
289291
relative_config_path = '.cherry_picker.toml'
290-
cfg = tmpdir.join(relative_config_path)
291-
cfg.write('''\
292+
tmp_git_repo_dir.join(relative_config_path).write('''\
292293
team = "python"
293294
repo = "core-workfolow"
294295
check_sha = "5f007046b5d4766f971272a0cc99f8461215c1ec"
295296
default_branch = "devel"
296297
''')
297-
subprocess.run('git add .'.split(), check=True)
298-
subprocess.run(('git', 'commit', '-m', 'Initial commit'), check=True)
298+
git_add(relative_config_path)
299+
git_commit('Add config')
299300
scm_revision = get_sha1_from('HEAD')
300301
cfg = load_config(None)
301302
assert cfg == (
@@ -310,16 +311,13 @@ def test_load_full_config(tmpdir, cd):
310311
)
311312

312313

313-
def test_load_partial_config(tmpdir, cd):
314-
cd(tmpdir)
315-
subprocess.run('git init .'.split(), check=True)
314+
def test_load_partial_config(tmp_git_repo_dir, git_add, git_commit):
316315
relative_config_path = '.cherry_picker.toml'
317-
cfg = tmpdir.join(relative_config_path)
318-
cfg.write('''\
316+
tmp_git_repo_dir.join(relative_config_path).write('''\
319317
repo = "core-workfolow"
320318
''')
321-
subprocess.run('git add .'.split(), check=True)
322-
subprocess.run(('git', 'commit', '-m', 'Initial commit'), check=True)
319+
git_add(relative_config_path)
320+
git_commit('Add config')
323321
scm_revision = get_sha1_from('HEAD')
324322
cfg = load_config(relative_config_path)
325323
assert cfg == (
@@ -417,7 +415,9 @@ def test_from_git_rev_read_negative(
417415
def test_from_git_rev_read_uncommitted(tmp_git_repo_dir, git_add, git_commit):
418416
some_text = 'blah blah 🤖'
419417
relative_file_path = '.some.file'
420-
tmp_git_repo_dir.join(relative_file_path).write(some_text)
418+
(
419+
pathlib.Path(tmp_git_repo_dir) / relative_file_path
420+
).write_text(some_text, encoding='utf-8')
421421
git_add('.')
422422
with pytest.raises(ValueError):
423423
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):
426426
def test_from_git_rev_read(tmp_git_repo_dir, git_add, git_commit):
427427
some_text = 'blah blah 🤖'
428428
relative_file_path = '.some.file'
429-
tmp_git_repo_dir.join(relative_file_path).write(some_text)
429+
(
430+
pathlib.Path(tmp_git_repo_dir) / relative_file_path
431+
).write_text(some_text, encoding='utf-8')
430432
git_add('.')
431433
git_commit('Add some file')
432434
assert from_git_rev_read('HEAD:' + relative_file_path) == some_text

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.