Skip to content

Commit 2df1dc9

Browse files
committed
Add python3.5, pypy3, and latest git to travis
1 parent d24a937 commit 2df1dc9

File tree

7 files changed

+48
-5
lines changed

7 files changed

+48
-5
lines changed

.travis.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ env: # These should match the tox env list
44
- TOXENV=py27
55
- TOXENV=py33
66
- TOXENV=py34
7+
- TOXENV=py35
78
- TOXENV=pypy
9+
- TOXENV=pypy3
10+
- TOXENV=py27 LATEST_GIT=1
811
install: pip install coveralls tox
912
script: tox
1013
# Special snowflake. Our tests depend on making real commits.
@@ -13,10 +16,23 @@ before_install:
1316
- git config --global user.email "user@example.com"
1417
# Our tests inspect some of *our* git history
1518
- git fetch --unshallow
19+
- git --version
20+
- |
21+
if [ "$LATEST_GIT" = "1" ]; then
22+
./latest-git.sh
23+
export PATH="/tmp/git:$PATH"
24+
fi
25+
- git --version
1626
after_success:
1727
- coveralls
1828
sudo: false
1929
cache:
2030
directories:
2131
- $HOME/.cache/pip
2232
- $HOME/.pre-commit
33+
addons:
34+
apt:
35+
sources:
36+
- deadsnakes
37+
packages:
38+
- python3.5-dev

latest-git.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
# This is a script used in travis-ci to have latest git
3+
set -ex
4+
git clone git://github.com/git/git --depth 1 /tmp/git
5+
pushd /tmp/git
6+
make -j 8
7+
popd

pre_commit/commands/install_uninstall.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import sys
1010

1111
from pre_commit.logging_handler import LoggingHandler
12+
from pre_commit.util import mkdirp
1213
from pre_commit.util import resource_filename
1314

1415

@@ -54,8 +55,7 @@ def install(runner, overwrite=False, hooks=False, hook_type='pre-commit'):
5455
hook_path = runner.get_hook_path(hook_type)
5556
legacy_path = hook_path + '.legacy'
5657

57-
if not os.path.exists(os.path.dirname(hook_path)):
58-
os.makedirs(os.path.dirname(hook_path))
58+
mkdirp(os.path.dirname(hook_path))
5959

6060
# If we have an existing hook, move it to pre-commit.legacy
6161
if (

pre_commit/util.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ def cwd(path):
2626
os.chdir(original_cwd)
2727

2828

29+
def mkdirp(path):
30+
try:
31+
os.makedirs(path)
32+
except OSError:
33+
if not os.path.exists(path):
34+
raise
35+
36+
2937
def memoize_by_cwd(func):
3038
"""Memoize a function call based on os.getcwd()."""
3139
@functools.wraps(func)

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
'Programming Language :: Python :: 3',
2424
'Programming Language :: Python :: 3.3',
2525
'Programming Language :: Python :: 3.4',
26+
'Programming Language :: Python :: 3.5',
2627
'Programming Language :: Python :: Implementation :: CPython',
2728
'Programming Language :: Python :: Implementation :: PyPy',
2829
],

tests/commands/install_uninstall_test.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from pre_commit.runner import Runner
2222
from pre_commit.util import cmd_output
2323
from pre_commit.util import cwd
24+
from pre_commit.util import mkdirp
2425
from pre_commit.util import resource_filename
2526
from testing.fixtures import git_dir
2627
from testing.fixtures import make_consuming_repo
@@ -83,7 +84,9 @@ def test_install_pre_commit(tempdir_factory):
8384
def test_install_hooks_directory_not_present(tempdir_factory):
8485
path = git_dir(tempdir_factory)
8586
# Simulate some git clients which don't make .git/hooks #234
86-
shutil.rmtree(os.path.join(path, '.git', 'hooks'))
87+
hooks = os.path.join(path, '.git', 'hooks')
88+
if os.path.exists(hooks): # pragma: no cover (latest git)
89+
shutil.rmtree(hooks)
8790
runner = Runner(path)
8891
install(runner)
8992
assert os.path.exists(runner.pre_commit_path)
@@ -94,8 +97,9 @@ def test_install_hooks_dead_symlink(
9497
tempdir_factory,
9598
): # pragma: no cover (non-windows)
9699
path = git_dir(tempdir_factory)
97-
os.symlink('/fake/baz', os.path.join(path, '.git', 'hooks', 'pre-commit'))
98100
runner = Runner(path)
101+
mkdirp(os.path.dirname(runner.pre_commit_path))
102+
os.symlink('/fake/baz', os.path.join(path, '.git', 'hooks', 'pre-commit'))
99103
install(runner)
100104
assert os.path.exists(runner.pre_commit_path)
101105

@@ -249,6 +253,7 @@ def test_install_existing_hooks_no_overwrite(tempdir_factory):
249253
runner = Runner(path)
250254

251255
# Write out an "old" hook
256+
mkdirp(os.path.dirname(runner.pre_commit_path))
252257
with io.open(runner.pre_commit_path, 'w') as hook_file:
253258
hook_file.write('#!/usr/bin/env bash\necho "legacy hook"\n')
254259
make_executable(runner.pre_commit_path)
@@ -274,6 +279,7 @@ def test_install_existing_hook_no_overwrite_idempotent(tempdir_factory):
274279
runner = Runner(path)
275280

276281
# Write out an "old" hook
282+
mkdirp(os.path.dirname(runner.pre_commit_path))
277283
with io.open(runner.pre_commit_path, 'w') as hook_file:
278284
hook_file.write('#!/usr/bin/env bash\necho "legacy hook"\n')
279285
make_executable(runner.pre_commit_path)
@@ -302,6 +308,7 @@ def test_failing_existing_hook_returns_1(tempdir_factory):
302308
runner = Runner(path)
303309

304310
# Write out a failing "old" hook
311+
mkdirp(os.path.dirname(runner.pre_commit_path))
305312
with io.open(runner.pre_commit_path, 'w') as hook_file:
306313
hook_file.write('#!/usr/bin/env bash\necho "fail!"\nexit 1\n')
307314
make_executable(runner.pre_commit_path)
@@ -330,6 +337,7 @@ def test_install_overwrite(tempdir_factory):
330337
runner = Runner(path)
331338

332339
# Write out the "old" hook
340+
mkdirp(os.path.dirname(runner.pre_commit_path))
333341
with io.open(runner.pre_commit_path, 'w') as hook_file:
334342
hook_file.write('#!/usr/bin/env bash\necho "legacy hook"\n')
335343
make_executable(runner.pre_commit_path)
@@ -347,6 +355,7 @@ def test_uninstall_restores_legacy_hooks(tempdir_factory):
347355
runner = Runner(path)
348356

349357
# Write out an "old" hook
358+
mkdirp(os.path.dirname(runner.pre_commit_path))
350359
with io.open(runner.pre_commit_path, 'w') as hook_file:
351360
hook_file.write('#!/usr/bin/env bash\necho "legacy hook"\n')
352361
make_executable(runner.pre_commit_path)
@@ -374,6 +383,7 @@ def test_replace_old_commit_script(tempdir_factory):
374383
IDENTIFYING_HASH, PREVIOUS_IDENTIFYING_HASHES[-1],
375384
)
376385

386+
mkdirp(os.path.dirname(runner.pre_commit_path))
377387
with io.open(runner.pre_commit_path, 'w') as pre_commit_file:
378388
pre_commit_file.write(new_contents)
379389
make_executable(runner.pre_commit_path)
@@ -390,6 +400,7 @@ def test_uninstall_doesnt_remove_not_our_hooks(tempdir_factory):
390400
path = git_dir(tempdir_factory)
391401
with cwd(path):
392402
runner = Runner(path)
403+
mkdirp(os.path.dirname(runner.pre_commit_path))
393404
with io.open(runner.pre_commit_path, 'w') as pre_commit_file:
394405
pre_commit_file.write('#!/usr/bin/env bash\necho 1\n')
395406
make_executable(runner.pre_commit_path)

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[tox]
22
project = pre_commit
33
# These should match the travis env list
4-
envlist = py26,py27,py33,py34,pypy
4+
envlist = py26,py27,py33,py34,py35,pypy,pypy3
55

66
[testenv]
77
deps = -rrequirements-dev.txt

0 commit comments

Comments
 (0)