Permalink
Browse files

Build config for travis-ci and appveyor.

Test failure will now cause non-zero return from setup.py.
JAVA_HOME is used to find java in tests.
Limit precision in jdbc testing.
  • Loading branch information...
bsteffensmeier committed Jan 30, 2017
1 parent b63beb0 commit c604a675cb51422e8d1316630c0644b9f8ff92a5
Showing with 64 additions and 7 deletions.
  1. +18 −0 .travis.yml
  2. +26 −0 appveyor.yml
  3. +12 −3 commands/test.py
  4. +4 −1 tests/runtests.py
  5. +4 −3 tests/test_jdbc.py
View
@@ -0,0 +1,18 @@
language: python
python:
- 2.7
- 3.3
- 3.4
- 3.5
env:
global:
# Force error for earlier detection of python 2.7 windows build problems
- CFLAGS="-Wdeclaration-after-statement -Werror=declaration-after-statement"
matrix:
- JAVA_HOME=/usr/lib/jvm/java-7-oracle
- JAVA_HOME=/usr/lib/jvm/java-8-oracle
addons:
apt:
packages:
- oracle-java8-installer
script: ./setup.py test
View
@@ -0,0 +1,26 @@
environment:
matrix:
# TODO need to figure out why 32bit python 2.7 crashes in the tests.
# - PYTHON: "C:\\Python27"
# JAVA_HOME: "C:\\Program Files (x86)\\Java\\jdk1.6.0"
- PYTHON: "C:\\Python33"
JAVA_HOME: "C:\\Program Files (x86)\\Java\\jdk1.8.0"
- PYTHON: "C:\\Python34"
JAVA_HOME: "C:\\Program Files (x86)\\Java\\jdk1.8.0"
- PYTHON: "C:\\Python35"
JAVA_HOME: "C:\\Program Files (x86)\\Java\\jdk1.8.0"
- PYTHON: "C:\\Python35"
JAVA_HOME: "C:\\Program Files (x86)\\Java\\jdk1.7.0"
- PYTHON: "C:\\Python27-x64"
JAVA_HOME: "C:\\Program Files\\Java\\jdk1.8.0"
- PYTHON: "C:\\Python35-x64"
JAVA_HOME: "C:\\Program Files\\Java\\jdk1.8.0"
- PYTHON: "C:\\Python35-x64"
JAVA_HOME: "C:\\Program Files\\Java\\jdk1.7.0"
# TODO there are more possible combinations that can be added
build: off
test_script:
- "%PYTHON%\\python.exe setup.py test"
View
@@ -1,12 +1,15 @@
from __future__ import print_function
from distutils.cmd import Command
from distutils import sysconfig
from distutils.errors import DistutilsExecError
from commands.util import configure_error
from commands.util import is_osx
from commands.util import is_windows
from commands.link_util import link_native_lib
from commands.python import get_libpython
from commands.java import get_java_home
import os
import os.path
import sys
@@ -51,11 +54,15 @@ def run(self):
if is_windows():
environment['SYSTEMROOT'] = os.environ['SYSTEMROOT']
java_path = os.path.join(get_java_home(), 'bin')
# if multiple versions of python are installed, this helps ensure the right
# version is used
executable = sys.executable
if executable:
environment['PATH'] = os.path.dirname(executable) + os.pathsep + os.environ['PATH']
py_path = os.path.dirname(executable)
environment['PATH'] = py_path + os.pathsep + java_path + os.pathsep + os.environ['PATH']
else:
environment['PATH'] = java_path + os.pathsep + os.environ['PATH']
# find the jep library and makes sure it's named correctly
build_ext = self.get_finalized_command('build_ext')
@@ -65,9 +72,11 @@ def run(self):
# actually kick off the tests
import subprocess
args = ['java',
args = [os.path.join(java_path, 'java'),
'-classpath', '{0}'.format(classpath),
'-Djava.library.path={0}'.format(built_dir),
'jep.Run', 'tests/runtests.py']
p = subprocess.Popen(args, env=environment)
p.wait()
rc = p.wait()
if rc != 0:
raise DistutilsExecError("Unit tests failed with exit status %d" % (rc))
View
@@ -1,5 +1,8 @@
import unittest
import sys
if __name__ == '__main__':
tests = unittest.TestLoader().discover('tests')
unittest.TextTestRunner().run(tests)
result = unittest.TextTestRunner().run(tests)
if not result.wasSuccessful():
sys.exit(1)
View
@@ -89,8 +89,9 @@ def test_dbapi_primitives(self):
)
''')
# sqlite double precision is iffy at best on some systems
doubleValue = Math.nextAfter(Double.MAX_VALUE, -1)
# Some versions of sqlite are not storing full precision.
# This is Double.MAX_VALUE, but truncated to 10 digits after the decimal.
doubleValue = 1.7976931348e+308
cursor.execute('insert into primitives values (?, ?, ?, ?, ?)',
Integer.MAX_VALUE,
@@ -112,7 +113,7 @@ def test_dbapi_primitives(self):
self.assertIsNone(row[2])
self.assertEqual(cursor.description[2][0], 'three')
self.assertAlmostEqual(row[3], doubleValue, delta=Double.MAX_VALUE / 1e6)
self.assertEqual(row[3], doubleValue)
self.assertEqual(cursor.description[3][0], 'four')
self.assertEqual(row[4], 5.6)

0 comments on commit c604a67

Please sign in to comment.