summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>2019-04-15 02:26:18 +0100
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>2019-04-22 02:54:56 +0100
commit5858b0b9b422470b3e54e41b0fa8cd0e604c398d (patch)
treeaa269dc2eff4837c8f25739d6d447723c00a2c0a
parent169ce222289b9a23079276345830cadaa0b281af (diff)
downloadpsycopg2-5858b0b9b422470b3e54e41b0fa8cd0e604c398d.tar.gz
Test packages from Python
-rw-r--r--.appveyor.yml12
-rwxr-xr-xscripts/appveyor.py53
2 files changed, 47 insertions, 18 deletions
diff --git a/.appveyor.yml b/.appveyor.yml
index 0ffa732..809775c 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -93,18 +93,14 @@ build: off
build_script:
- "%PYEXE% C:\\appveyor.py build_script"
+after_build:
+ - "%PYEXE% C:\\appveyor.py after_build"
before_test:
- # Create and setup PostgreSQL database for the tests
- - createdb %PSYCOPG2_TESTDB%
- - psql -d %PSYCOPG2_TESTDB% -c "CREATE EXTENSION HSTORE;"
+ - "%PYEXE% C:\\appveyor.py before_test"
test_script:
- # Print psycopg and libpq versions
- - "%PYTHON%\\python.exe -c \"import psycopg2; print(psycopg2.__version__)\""
- - "%PYTHON%\\python.exe -c \"import psycopg2; print(psycopg2.__libpq_version__)\""
- - "%PYTHON%\\python.exe -c \"import psycopg2; print(psycopg2.extensions.libpq_version())\""
- - "%PYTHON%\\python.exe -c \"import tests; tests.unittest.main(defaultTest='tests.test_suite')\" --verbose"
+ - "%PYEXE% C:\\appveyor.py test_script"
# vim: set ts=4 sts=4 sw=4:
diff --git a/scripts/appveyor.py b/scripts/appveyor.py
index 896bfc9..f10775b 100755
--- a/scripts/appveyor.py
+++ b/scripts/appveyor.py
@@ -43,8 +43,6 @@ def setup_env():
"""
Set the environment variables according to the build environment
"""
- python_info()
-
setenv('VS_VER', vs_ver())
if vs_ver() == '10.0' and opt.arch_64:
@@ -103,6 +101,8 @@ def python_info():
def step_init():
+ python_info()
+
# The program rc.exe on 64bit with some versions look in the wrong path
# location when building postgresql. This cheats by copying the x64 bit
# files to that location.
@@ -124,11 +124,14 @@ def step_init():
def step_install():
# TODO: enable again
- # build_openssl()
+ return
+ build_openssl()
build_libpq()
def step_build_script():
+ # TODO: enable again
+ return
build_psycopg()
@@ -286,13 +289,6 @@ $config->{openssl} = "%s";
def build_psycopg():
- # Add PostgreSQL binaries to the path
- setenv(
- 'PATH',
- os.pathsep.join(
- [r'C:\Program Files\PostgreSQL\9.6\bin', os.environ['PATH']]
- ),
- )
os.chdir(r"C:\Project")
# Find the pg_config just built
@@ -312,6 +308,43 @@ def build_psycopg():
shutil.rmtree("psycopg2.egg-info")
+def step_before_test():
+ # Add PostgreSQL binaries to the path
+ setenv(
+ 'PATH',
+ os.pathsep.join([os.path.join(pg_dir(), 'bin'), os.environ['PATH']]),
+ )
+
+ # Create and setup PostgreSQL database for the tests
+ run_command(['createdb', os.environ['PSYCOPG2_TESTDB']])
+ run_command(
+ ['psql', '-d', os.environ['PSYCOPG2_TESTDB']]
+ + ['-c', "CREATE EXTENSION hstore"]
+ )
+
+
+def step_after_build():
+ # Print psycopg and libpq versions
+ # TODO: enable
+ return
+
+ for expr in (
+ 'psycopg2.__version__',
+ 'psycopg2.__libpq_version__',
+ 'psycopg2.extensions.libpq_version()',
+ ):
+ out = out_command([py_exe(), '-c', f"import psycopg2; print({expr})"])
+ logger.info("built %s: %s", expr, out.decode('ascii'))
+
+
+def step_test_script():
+ run_command(
+ [py_exe(), '-c']
+ + ["import tests; tests.unittest.main(defaultTest='tests.test_suite')"]
+ + ["--verbose"]
+ )
+
+
def download(url, fn):
"""Download a file locally"""
logger.info("downloading %s", url)