From a8651752de6da58ae65dac089d293c2ae15cd069 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sat, 29 Apr 2017 15:36:37 +0300 Subject: [PATCH] Test at AppVeyor --- TODO | 2 +- appveyor.yml | 67 +++++++++++++++++++++++++++++++++++ devscripts/cmp.py | 89 +++++++++++++++++++++++++++++++++++++++++++++++ devscripts/rm.py | 7 ++++ docs/news.rst | 2 +- setup.py | 2 +- tox.ini | 29 ++++++++++----- 7 files changed, 187 insertions(+), 11 deletions(-) create mode 100644 appveyor.yml create mode 100755 devscripts/cmp.py create mode 100755 devscripts/rm.py diff --git a/TODO b/TODO index 533c825..8ce63ac 100644 --- a/TODO +++ b/TODO @@ -1 +1 @@ -AppVeyor, PyPI. +PyPI. diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..34872fb --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,67 @@ +# 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:\\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/devscripts/cmp.py b/devscripts/cmp.py new file mode 100755 index 0000000..0168bec --- /dev/null +++ b/devscripts/cmp.py @@ -0,0 +1,89 @@ +#! /usr/bin/env python +"""cmp.py: compare two files. Portable replacement for cmp.""" + +import os +import sys + +if sys.argv[1] in ("-h", "--help"): + print("Broytman cmp.py 1.0, Copyright (C) 2003-2017 PhiloSoft Design") + print("Usage: cmp.py [-h|--help|-V|--version] [-i] file1 file2") + sys.exit() +elif sys.argv[1] in ("-V", "--version"): + print("Broytman cmp.py 1.0, Copyright (C) 2003-2017 PhiloSoft Design") + sys.exit() +elif sys.argv[1] == "-i": + show_pbar = False + fname1 = sys.argv[2] + fname2 = sys.argv[3] +else: + show_pbar = sys.stderr.isatty() + fname1 = sys.argv[1] + fname2 = sys.argv[2] + +if show_pbar: + try: + from m_lib.pbar.tty_pbar import ttyProgressBar + except ImportError: + show_pbar = 0 + +if show_pbar: + try: + size = os.path.getsize(fname1) + except: + print(fname1, ": no such file") + sys.exit(1) + +if show_pbar: + pbar = ttyProgressBar(0, size) + +file1 = open(fname1, 'rb') +file2 = open(fname2, 'rb') + +M = 1024*1024 +diff = False +count = 0 + + +def report(): + if show_pbar: + global pbar + del pbar + sys.stderr.write("Files differ at %d megabayte block\n" % count) + global diff + diff = True + + +while True: + block1 = file1.read(M) + block2 = file2.read(M) + + if show_pbar: + pbar.display(file1.tell()) + + if block1 and block2: + if len(block1) != len(block2): + report() + break + elif block1: + report() + break + elif block2: + report() + break + else: + break + + if block1 != block2: + report() + break + + count += 1 + +if show_pbar and not diff: + del pbar + +file1.close() +file2.close() + +if diff: + sys.exit(1) diff --git a/devscripts/rm.py b/devscripts/rm.py new file mode 100755 index 0000000..4278fef --- /dev/null +++ b/devscripts/rm.py @@ -0,0 +1,7 @@ +#! /usr/bin/env python + +import os +import sys + +for filename in sys.argv[1:]: + os.unlink(filename) diff --git a/docs/news.rst b/docs/news.rst index 5f06370..bfd3c77 100644 --- a/docs/news.rst +++ b/docs/news.rst @@ -6,7 +6,7 @@ Version 0.2.0 (2017-05-??) * Python 3.5, 3.6. -* Test at Travis. +* Test at Travis and AppVeyor. Version 0.1.2 (2017-04-27) -------------------------- diff --git a/setup.py b/setup.py index 16af60f..b7de6e4 100755 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ if is_setuptools: setup(name='sqlconvert', version=__version__, description='Broytman sqlconvert', - long_description=open('README.txt', 'rtU').read(), + long_description=open('README.txt', 'rU').read(), author='Oleg Broytman', author_email='phd@phdru.name', url='http://phdru.name/Software/Python/', diff --git a/tox.ini b/tox.ini index 7d25d51..eb6b355 100644 --- a/tox.ini +++ b/tox.ini @@ -4,6 +4,14 @@ envlist = {py26,py27,py34,py35,py36},{py26,py27,py34,py35,py36}-{postgres,sqlite # Base test environment settings [testenv] +basepython = + py27: {env:TOXPYTHON:python2.7} + 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 = sqlparse pytest @@ -20,15 +28,14 @@ whitelist_externals = flake8 createdb dropdb - cmp - rm [general] commands = + {[testenv]commands} {envpython} -m pytest --cov=sqlconvert - mysql2sql demo/demo.sql test.out - cmp -s tests/mysql2sql/test.out test.out - rm test.out + {envpython} {envbindir}/mysql2sql -P demo/demo.sql test.out + {envpython} devscripts/cmp.py -i tests/mysql2sql/test.out test.out + {envpython} devscripts/rm.py test.out [testenv:py26] commands = {[general]commands} @@ -48,6 +55,7 @@ commands = {[general]commands} # PostgreSQL test environments [postgresql] commands = + {[testenv]commands} -dropdb test createdb test {envpython} -m pytest --cov=sqlconvert -D postgres:///test @@ -71,8 +79,9 @@ commands = {[postgresql]commands} # SQLite test environments [sqlite] commands = + {[testenv]commands} {envpython} -m pytest --cov=sqlconvert -D sqlite:///tmp/test.sqdb - rm -f /tmp/test.sqdb + {envpython} devscripts/rm.py /tmp/test.sqdb [testenv:py26-sqlite] commands = {[sqlite]commands} @@ -93,9 +102,13 @@ commands = {[sqlite]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.5