]> git.phdru.name Git - sqlconvert.git/commitdiff
Test at AppVeyor
authorOleg Broytman <phd@phdru.name>
Sat, 29 Apr 2017 12:36:37 +0000 (15:36 +0300)
committerOleg Broytman <phd@phdru.name>
Sat, 29 Apr 2017 13:22:30 +0000 (16:22 +0300)
TODO
appveyor.yml [new file with mode: 0644]
devscripts/cmp.py [new file with mode: 0755]
devscripts/rm.py [new file with mode: 0755]
docs/news.rst
setup.py
tox.ini

diff --git a/TODO b/TODO
index 533c825dd6ed650070a29c30eb85baaa62d4fd09..8ce63ac0cfc825f1d49ffa8af1af0c00f8335039 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1 +1 @@
-AppVeyor, PyPI.
+PyPI.
diff --git a/appveyor.yml b/appveyor.yml
new file mode 100644 (file)
index 0000000..34872fb
--- /dev/null
@@ -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 (executable)
index 0000000..0168bec
--- /dev/null
@@ -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 (executable)
index 0000000..4278fef
--- /dev/null
@@ -0,0 +1,7 @@
+#! /usr/bin/env python
+
+import os
+import sys
+
+for filename in sys.argv[1:]:
+    os.unlink(filename)
index 5f06370373a4c9d1f39ef96060eca2fbabd890be..bfd3c77a1bc86ddb169e88e45124d97c42ec87d2 100644 (file)
@@ -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)
 --------------------------
index 16af60fbd7ef84d3bea5b05d7f26824fda36f520..b7de6e4c66e3cfc00699d20453d521034a8b9f8f 100755 (executable)
--- 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 7d25d514217d7001ada11703fea505d486d3d1f9..eb6b3550ced5083e3ed9375c3f1ef48580e61ae4 100644 (file)
--- 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