From dd127f84569ceebec6243a16c3bb9e4130493a6b Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sat, 29 Apr 2017 16:42:07 +0300 Subject: [PATCH] Test at Travis and AppVeyor --- .travis.yml | 30 ++++++++++++++ TODO | 2 +- appveyor.yml | 75 ++++++++++++++++++++++++++++++++++ docs/news.rst | 5 +++ tests/test_remove_old_files.py | 22 +++++++--- tox.ini | 48 ++++++++++++++++++---- 6 files changed, 169 insertions(+), 13 deletions(-) create mode 100644 .travis.yml create mode 100644 appveyor.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..ddec68a --- /dev/null +++ b/.travis.yml @@ -0,0 +1,30 @@ +# Config file for automatic testing at travis-ci.org + +# Only test master and pull requests; skip tags. +# Other branches can allow themselves. +branches: + only: + - master + +# Prefer docker containers +sudo: required + +language: python + +python: + - "3.6" + +cache: pip + +env: + - TOXENV=py27 + - TOXENV=py33 + - TOXENV=py34 + - TOXENV=py35 + - TOXENV=py36 + +install: + - travis_retry pip install tox + +script: + - tox diff --git a/TODO b/TODO index 5666c9c..b0fd453 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,4 @@ -Travis, AppVeyor, PyPI. +PyPI. Add option -v/--verbose to report every removed file. diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..859db9b --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,75 @@ +# Test on windows +# Heavily inspired by Oliver Grisel's appveyor-demo (https://github.com/ogrisel/python-appveyor-demo) +version: '{branch}-{build}' + +# Only test master and pull requests; skip tags. +# Other branches can allow themselves. +branches: + only: + - master +skip_branch_with_pr: false +skip_tags: true + +cache: + - '%LOCALAPPDATA%\pip\Cache' + +# Match travis +clone_depth: 50 + +environment: + matrix: + - PYTHON_HOME: "C:\\Python27" + PYTHON_VERSION: "2.7" + PYTHON_ARCH: "32" + TOX_ENV: "py27" + - PYTHON_HOME: "C:\\Python27-x64" + PYTHON_VERSION: "2.7" + PYTHON_ARCH: "64" + TOX_ENV: "py27" + - PYTHON_HOME: "C:\\Python33" + PYTHON_VERSION: "3.3" + PYTHON_ARCH: "32" + TOX_ENV: "py33" + - PYTHON_HOME: "C:\\Python33-x64" + PYTHON_VERSION: "3.3" + PYTHON_ARCH: "64" + TOX_ENV: "py33" + - PYTHON_HOME: "C:\\Python34" + PYTHON_VERSION: "3.4" + PYTHON_ARCH: "32" + TOX_ENV: "py34" + - PYTHON_HOME: "C:\\Python34-x64" + PYTHON_VERSION: "3.4" + PYTHON_ARCH: "64" + TOX_ENV: "py34" + - PYTHON_HOME: "C:\\Python35" + PYTHON_VERSION: "3.5" + PYTHON_ARCH: "32" + TOX_ENV: "py35" + - PYTHON_HOME: "C:\\Python35-x64" + PYTHON_VERSION: "3.5" + PYTHON_ARCH: "64" + TOX_ENV: "py35" + - PYTHON_HOME: "C:\\Python36" + PYTHON_VERSION: "3.6" + PYTHON_ARCH: "32" + TOX_ENV: "py36" + - PYTHON_HOME: "C:\\Python36-x64" + PYTHON_VERSION: "3.6" + PYTHON_ARCH: "64" + TOX_ENV: "py36" + +install: + # Ensure we use the right python version + - "SET PATH=%PYTHON_HOME%;%PYTHON_HOME%\\Scripts;%PATH%" + - "SET TOXPYTHON=%PYTHON_HOME%\\python.exe" + - "python --version" + - "python -c \"import struct; print(struct.calcsize('P') * 8)\"" + - "pip --version" + - "pip install tox" + +# No build step - _namemapper extension will be built under tox +build: false + +test_script: + - "tox -e %TOX_ENV%" diff --git a/docs/news.rst b/docs/news.rst index 45a3f5a..8642710 100644 --- a/docs/news.rst +++ b/docs/news.rst @@ -1,6 +1,11 @@ News ==== +Version 0.2.0 (2017-05-??) +-------------------------- + +* Test at Travis and AppVeyor. + 0.1.0 (2017-04-16) ------------------ diff --git a/tests/test_remove_old_files.py b/tests/test_remove_old_files.py index 67da601..87fc3e3 100755 --- a/tests/test_remove_old_files.py +++ b/tests/test_remove_old_files.py @@ -1,11 +1,19 @@ #! /usr/bin/env python -import shutil import os +import shutil +import sys from tempfile import mkdtemp tmp_dir = None +for path in os.environ["PATH"].split(os.pathsep): + path = path.strip('"') + test_prog_path = os.path.join(path, 'remove-old-files.py') + if os.path.exists(test_prog_path): + break +else: + sys.exit("Cannot find remove-old-files.py in %s" % os.environ["PATH"]) def setup(): @@ -47,7 +55,8 @@ def test_remove_old_files(): create_files(['test1', 'test2']) assert_files_exist(['test1', 'test2']) os.utime('test2', (0, 0)) - assert os.system("remove-old-files.py --older 100 .") == 0 + assert os.system( + "%s %s --older 100 ." % (sys.executable, test_prog_path)) == 0 assert_files_exist('test1') assert_files_not_exist('test2') @@ -58,7 +67,8 @@ def test_recursive(): test4 = os.path.join('subdir', 'test4') assert_files_exist([test3, test4]) os.utime(test4, (0, 0)) - assert os.system("remove-old-files.py --older 100 .") == 0 + assert os.system( + "%s %s --older 100 ." % (sys.executable, test_prog_path)) == 0 assert_files_exist(test3) assert_files_not_exist(test4) @@ -70,8 +80,10 @@ def test_remove_empty_directory(): assert_files_exist([test3, test4]) os.utime(test3, (0, 0)) os.utime(test4, (0, 0)) - assert os.system("remove-old-files.py --older 100 .") == 0 + assert os.system( + "%s %s --older 100 ." % (sys.executable, test_prog_path)) == 0 assert_files_exist('subdir') assert_files_not_exist([test3, test4]) - assert os.system("remove-old-files.py -e --older 100 .") == 0 + assert os.system( + "%s %s -e --older 100 ." % (sys.executable, test_prog_path)) == 0 assert_files_not_exist('subdir') diff --git a/tox.ini b/tox.ini index 18cfb29..c32d7b6 100644 --- a/tox.ini +++ b/tox.ini @@ -1,10 +1,19 @@ [tox] minversion = 1.8 -toxworkdir={homedir}/.tox/remove-old-files envlist = {py26,py27,py33,py34,py35,py36},{py27,py34}-flake8 # Base test environment settings [testenv] +basepython = + py26: {env:TOXPYTHON:python2.6} + py27: {env:TOXPYTHON:python2.7} + py33: {env:TOXPYTHON:python3.3} + py34: {env:TOXPYTHON:python3.4} + py35: {env:TOXPYTHON:python3.5} + py36: {env:TOXPYTHON:python3.6} +commands = + {envpython} --version + {envpython} -c "import struct; print(struct.calcsize('P') * 8)" deps = pytest pytest-cov @@ -15,23 +24,48 @@ whitelist_externals = [general] commands = - python -m pytest + {envpython} -m pytest [testenv:py26] -commands = {[general]commands} +commands = + {[testenv]commands} + {[general]commands} [testenv:py27] -commands = {[general]commands} +commands = + {[testenv]commands} + {[general]commands} + +[testenv:py33] +commands = + {[testenv]commands} + {[general]commands} [testenv:py34] -commands = {[general]commands} +commands = + {[testenv]commands} + {[general]commands} + +[testenv:py35] +commands = + {[testenv]commands} + {[general]commands} + +[testenv:py36] +commands = + {[testenv]commands} + {[general]commands} [testenv:py27-flake8] deps = flake8 -commands = flake8 +commands = + {[testenv]commands} + flake8 [testenv:py34-flake8] deps = flake8 -commands = flake8 +commands = + {[testenv]commands} + flake8 -- 2.39.2