Commit d7ba4ae3 authored by Matthew Brett's avatar Matthew Brett
Browse files

Add tests for multibuild utilities

parent 7c126324
language: erlang
matrix:
include:
- os: linux
- os: osx
language: objective-c
env:
- PYTHON_VERSION=2.7.11
- os: osx
language: objective-c
env:
- PYTHON_VERSION=2.7.11
- VENV=venv
- os: osx
language: objective-c
env:
- PYTHON_VERSION=3.4.4
- os: osx
language: objective-c
env:
- PYTHON_VERSION=3.4.4
- VENV=venv
- os: osx
language: objective-c
env:
- PYTHON_VERSION=3.5.1
- os: osx
language: objective-c
env:
- PYTHON_VERSION=3.5.1
- VENV=venv
script:
- source tests/test_multibuild.sh
......@@ -28,9 +28,9 @@ function lex_ver {
}
function is_function {
set +e
$(declare -Ff "$1") > /dev/null && echo true
set -e
# Echo "true" if input argument string is a function
# Allow errors during "set -e" blocks.
(set +e; echo $($(declare -Ff "$1") > /dev/null && echo true))
}
function gh-clone {
......
......@@ -99,15 +99,16 @@ function pyinst_ext_for_version {
# Earlier Python installers are .dmg, later are .pkg.
local py_version=$1
check_var $py_version
py_version=$(fill_pyver $py_version)
local py_0=${py_version:0:1}
if [ $py_0 -eq 2 ]; then
if [ $(lex_ver $py_version) -ge $(lex_ver 2.7.9) ]; then
if [ "$(lex_ver $py_version)" -ge "$(lex_ver 2.7.9)" ]; then
echo "pkg"
else
echo "dmg"
fi
elif [ $py_0 -ge 3 ]; then
if [ $(lex_ver $py_version) -ge $(lex_ver 3.4.2) ]; then
if [ "$(lex_ver $py_version)" -ge "$(lex_ver 3.4.2)" ]; then
echo "pkg"
else
echo "dmg"
......@@ -160,7 +161,7 @@ function install_virtualenv {
# install even if installed already
$PIP_CMD install virtualenv --ignore-installed
check_python
VIRTUALENV_CMD="`dirname $PYTHON_EXE`/virtualenv"
VIRTUALENV_CMD="$(dirname $PYTHON_EXE)/virtualenv"
}
function make_workon_venv {
......
# Test common_utils
[ "$(abspath foo)" == "$PWD/foo" ] || ingest "abspath foo"
[ "$(abspath foo/bar)" == "$PWD/foo/bar" ] || ingest "abspath foo/bar"
[ "$(abspath /foo)" == "/foo" ] || ingest "abspath /foo"
[ "$(relpath $PWD/foo)" == "foo" ] || ingest "relpath foo"
[ "$(relpath foo/bar foo)" == "bar" ] || ingest "relpath foo/bar"
[ "$(realpath /foo)" == "/foo" ] || ingest "realpath /foo"
[ "$(lex_ver 2)" == "002000000" ] || ingest "lex_ver 2"
[ "$(lex_ver 2.1)" == "002001000" ] || ingest "lex_ver 2.1"
[ "$(lex_ver 2.1.4)" == "002001004" ] || ingest "lex_ver 2.1.4"
[ "$(lex_ver 2.1.4rc1)" == "002001004" ] || ingest "lex_ver 2.1.4"
[ "$(is_function abspath)" == "true" ] || ingest "is_function abspath"
[ "$(is_function foo)" == "" ] || ingest "is_function foo"
bar=baz
[ "$(is_function bar)" == "" ] || ingest "is_function bar"
rm_mkdir tmp_dir
[ -d tmp_dir ] || ingest "tmp_dir does not exist"
touch tmp_dir/afile
rm_mkdir tmp_dir
[ -e tmp_dir/afile ] && ingest "tmp_dir/afile should have been deleted"
rmdir tmp_dir
# Test python version fill utility
[ "$(fill_pyver 2)" == $LATEST_2p7 ] || ingest
[ "$(fill_pyver 2.7)" == $LATEST_2p7 ] || ingest
[ "$(fill_pyver 2.7.8)" == "2.7.8" ] || ingest
[ "$(fill_pyver 2.6)" == $LATEST_2p6 ] || ingest
[ "$(fill_pyver 2.6.2)" == "2.6.2" ] || ingest
[ "$(fill_pyver 3)" == $LATEST_3p5 ] || ingest
[ "$(fill_pyver 3.5)" == $LATEST_3p5 ] || ingest
[ "$(fill_pyver 3.5.0)" == "3.5.0" ] || ingest
[ "$(fill_pyver 3.4)" == $LATEST_3p4 ] || ingest
[ "$(fill_pyver 3.3)" == $LATEST_3p3 ] || ingest
[ "$(fill_pyver 3.2)" == $LATEST_3p2 ] || ingest
# Tests for manylinux utils
[ "$(get_platform)" == x86_64 ] || [ "$(get_platform)" == i686 ] || exit 1
# cpython path calculator
[ "$(cpython_path 2.6)" == "/opt/python/cp26-cp26mu" ] || ingest "cp 2.6"
[ "$(cpython_path 2.6 32)" == "/opt/python/cp26-cp26mu" ] || ingest "cp 2.6 32"
[ "$(cpython_path 2.6 16)" == "/opt/python/cp26-cp26m" ] || ingest "cp 2.6 16"
[ "$(cpython_path 2.7)" == "/opt/python/cp27-cp27mu" ] || ingest "cp 2.7"
[ "$(cpython_path 2.7 32)" == "/opt/python/cp27-cp27mu" ] || ingest "cp 2.7 32"
[ "$(cpython_path 2.7 16)" == "/opt/python/cp27-cp27m" ] || ingest "cp 2.7 16"
[ "$(cpython_path 3.3)" == "/opt/python/cp33-cp33m" ] || ingest "cp 3.3"
[ "$(cpython_path 3.3 32)" == "/opt/python/cp33-cp33m" ] || ingest "cp 3.3 32"
[ "$(cpython_path 3.3 16)" == "/opt/python/cp33-cp33m" ] || ingest "cp 3.3 16"
[ "$(cpython_path 3.4)" == "/opt/python/cp34-cp34m" ] || ingest "cp 3.4"
[ "$(cpython_path 3.4 32)" == "/opt/python/cp34-cp34m" ] || ingest "cp 3.4 32"
[ "$(cpython_path 3.4 16)" == "/opt/python/cp34-cp34m" ] || ingest "cp 3.4 16"
[ "$(cpython_path 3.5)" == "/opt/python/cp35-cp35m" ] || ingest "cp 3.5"
[ "$(cpython_path 3.5 32)" == "/opt/python/cp35-cp35m" ] || ingest "cp 3.5 32"
[ "$(cpython_path 3.5 16)" == "/opt/python/cp35-cp35m" ] || ingest "cp 3.5 16"
# Test multibuild utilities
source common_utils.sh
source tests/utils.sh
source tests/test_common_utils.sh
if [ -n "$IS_OSX" ]; then
source osx_utils.sh
get_macpython_environment $PYTHON_VERSION $VENV
source tests/test_python_install.sh
source tests/test_fill_pyver.sh
source tests/test_osx_utils.sh
else
source manylinux_utils.sh
source tests/test_manylinux_utils.sh
fi
# Exit 1 if any test errors
barf
# Tests for OSX utils
# Test extension for downloaded Python.org installer
[ "$(pyinst_ext_for_version 2.7.8)" == dmg ] || ingest
[ "$(pyinst_ext_for_version 2.7.9)" == pkg ] || ingest
[ "$(pyinst_ext_for_version 2.7)" == pkg ] || ingest
[ "$(pyinst_ext_for_version 2)" == pkg ] || ingest
[ "$(pyinst_ext_for_version 3.3.5)" == dmg ] || ingest
[ "$(pyinst_ext_for_version 3.4.1)" == dmg ] || ingest
[ "$(pyinst_ext_for_version 3.4.2)" == pkg ] || ingest
[ "$(pyinst_ext_for_version 3.5.0)" == pkg ] || ingest
[ "$(pyinst_ext_for_version 3.3)" == dmg ] || ingest
[ "$(pyinst_ext_for_version 3.4)" == pkg ] || ingest
[ "$(pyinst_ext_for_version 3)" == pkg ] || ingest
# Test utilities for getting Python version versions
[ "$(get_py_digit)" == "${PYTHON_VERSION:0:1}" ] || ingest
[ "$(get_py_mm)" == "${PYTHON_VERSION:0:3}" ] || ingest
[ "$(get_py_mm_nodot)" == $(echo "${PYTHON_VERSION:0:3}" | tr -d .) ] || \
ingest
# Some debug echoes
echo "Python on path: `which python`"
echo "Python cmd: $PYTHON_EXE"
echo "pip on path: $(which pip)"
echo "pip cmd: $PIP_CMD"
echo "virtualenv on path: $(which virtualenv)"
echo "virtualenv cmd: $VIRTUALENV_CMD"
# Check that a pip install puts scripts on path
pip install delocate
delocate-listdeps --version || ingest "Delocate not installed right"
# Python version from Python to compare against required
python_version=$($PYTHON_EXE --version 2>&1 | awk '{print $2}')
python_mm="${PYTHON_VERSION:0:1}.${PYTHON_VERSION:2:1}"
if [ "$python_version" != $PYTHON_VERSION ]; then
ingest "Wrong macpython python version $python_version"
fi
if [ -n "$VENV" ]; then # in virtualenv
# Correct pip and Python versions should be on PATH
if [ "$($PYTHON_EXE --version)" != "$(python --version)" ]; then
ingest "Python versions do not match"
fi
if [ "$($PIP_CMD --version)" != "$(pip --version)" ]; then
ingest "Pip versions do not match"
fi
# Versions in environment variables have full path
if [ "$PYTHON_EXE" != "$PWD/venv/bin/python" ]; then
ingest "Wrong virtualenv python '$PYTHON_EXE'"
fi
if [ "$PIP_CMD" != "$PWD/venv/bin/pip" ]; then
ingest "Wrong virtualenv pip '$PIP_CMD'"
fi
else # not virtualenv
macpie_bin="$MACPYTHON_PY_PREFIX/$python_mm/bin"
if [ "$PYTHON_EXE" != "$macpie_bin/python$python_mm" ]; then
ingest "Wrong macpython python cmd '$PYTHON_EXE'"
fi
if [ "$PIP_CMD" != "sudo $macpie_bin/pip$python_mm" ]; then
ingest "Wrong macpython pip '$PIP_CMD'"
fi
fi
# Test utilities
RET=${RET:-0}
function ingest {
local msg="${1:-"no message"}"
echo "Test failed: $msg"
RET=1
}
function barf {
[ "$RET" == 0 ] || exit 1
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment