Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b6cb030

Browse files
committed
TST: add 32 bit travis tests
Implemented by setting up a chroot in the travis VM and moving all the test logic, including bento build, to a single script. This is still reasonable fast, about twice as slow as the normal tests. When Travis updates to a newer OS it can be replaced by standard cross compiling.
1 parent bb91617 commit b6cb030

3 files changed

Lines changed: 107 additions & 46 deletions

File tree

.bento_travisci.sh

Lines changed: 0 additions & 26 deletions
This file was deleted.

.travis.yml

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ matrix:
1818
env: NPY_RELAXED_STRIDES_CHECKING=1
1919
- python: 2.7
2020
env: USE_BENTO=1
21+
- python: 2.7
22+
env: USE_CHROOT=1 ARCH=i386 DIST=saucy
2123
before_install:
2224
- uname -a
2325
- free -m
@@ -31,24 +33,5 @@ before_install:
3133
- sudo apt-get install -qq libatlas-dev libatlas-base-dev gfortran
3234
- popd
3335

34-
install:
35-
# We used to use 'setup.py install' here, but that has the terrible
36-
# behaviour that if a copy of the package is already installed in
37-
# the install location, then the new copy just gets dropped on top
38-
# of it. Travis typically has a stable numpy release pre-installed,
39-
# and if we don't remove it, then we can accidentally end up
40-
# e.g. running old test modules that were in the stable release but
41-
# have been removed from master. (See gh-2765, gh-2768.) Using 'pip
42-
# install' also has the advantage that it tests that numpy is 'pip
43-
# install' compatible, see e.g. gh-2766...
44-
- if [ "${USE_BENTO}" == "1" ]; then source .bento_travisci.sh; else pip install .; fi
4536
script:
46-
# We change directories to make sure that python won't find the copy
47-
# of numpy in the source directory.
48-
- mkdir empty
49-
- cd empty
50-
- INSTALLDIR=$(python -c "import os; import numpy; print(os.path.dirname(numpy.__file__))")
51-
- export PYTHONWARNINGS=default
52-
- python ../tools/test-installed-numpy.py --mode=full
53-
# - coverage run --source=$INSTALLDIR --rcfile=../.coveragerc $(which python) ../tools/test-installed-numpy.py
54-
# - coverage report --rcfile=../.coveragerc --show-missing
37+
- ./tools/travis-test.sh

tools/travis-test.sh

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
#!/bin/sh
2+
set -ex
3+
4+
# setup env
5+
if [ -r /usr/lib/libeatmydata/libeatmydata.so ]; then
6+
# much faster package installation
7+
export LD_PRELOAD=/usr/lib/libeatmydata/libeatmydata.so
8+
fi
9+
10+
11+
setup_base()
12+
{
13+
# We used to use 'setup.py install' here, but that has the terrible
14+
# behaviour that if a copy of the package is already installed in
15+
# the install location, then the new copy just gets dropped on top
16+
# of it. Travis typically has a stable numpy release pre-installed,
17+
# and if we don't remove it, then we can accidentally end up
18+
# e.g. running old test modules that were in the stable release but
19+
# have been removed from master. (See gh-2765, gh-2768.) Using 'pip
20+
# install' also has the advantage that it tests that numpy is 'pip
21+
# install' compatible, see e.g. gh-2766...
22+
pip install .
23+
}
24+
25+
setup_chroot()
26+
{
27+
# this can all be replaced with:
28+
# apt-get install libpython2.7-dev:i386
29+
# CC="gcc -m32" LDSHARED="gcc -m32 -shared" LDFLAGS="-m32 -shared" linux32 python setup.py build
30+
# when travis updates to ubuntu 14.04
31+
DIR=$1
32+
set -u
33+
sudo apt-get -qq -y --force-yes install debootstrap eatmydata
34+
sudo debootstrap --variant=buildd --include=fakeroot,build-essential --arch=$ARCH --foreign $DIST $DIR
35+
sudo chroot $DIR ./debootstrap/debootstrap --second-stage
36+
sudo rsync -a $TRAVIS_BUILD_DIR $DIR/
37+
echo deb http://archive.ubuntu.com/ubuntu/ saucy main restricted universe multiverse | sudo tee -a $DIR/etc/apt/sources.list
38+
echo deb http://archive.ubuntu.com/ubuntu/ saucy-updates main restricted universe multiverse | sudo tee -a $DIR/etc/apt/sources.list
39+
echo deb http://security.ubuntu.com/ubuntu saucy-security main restricted universe multiverse | sudo tee -a $DIR/etc/apt/sources.list
40+
sudo chroot $DIR bash -c "apt-get update"
41+
sudo chroot $DIR bash -c "apt-get install -qq -y --force-yes eatmydata"
42+
echo /usr/lib/libeatmydata/libeatmydata.so | sudo tee -a $DIR/etc/ld.so.preload
43+
sudo chroot $DIR bash -c "apt-get install -qq -y --force-yes libatlas-dev libatlas-base-dev gfortran python-dev python-nose python-pip"
44+
}
45+
46+
setup_bento()
47+
{
48+
export CI_ROOT=$PWD
49+
cd ..
50+
51+
# Waf
52+
wget http://waf.googlecode.com/files/waf-1.7.13.tar.bz2
53+
tar xjvf waf-1.7.13.tar.bz2
54+
cd waf-1.7.13
55+
python waf-light
56+
export WAFDIR=$PWD
57+
cd ..
58+
59+
# Bento
60+
wget https://github.com/cournape/Bento/archive/master.zip
61+
unzip master.zip
62+
cd Bento-master
63+
python bootstrap.py
64+
export BENTO_ROOT=$PWD
65+
cd ..
66+
67+
cd $CI_ROOT
68+
69+
# In-place numpy build
70+
$BENTO_ROOT/bentomaker build -i -j
71+
72+
# Prepend to PYTHONPATH so tests can be run
73+
export PYTHONPATH=$PWD:$PYTHONPATH
74+
}
75+
76+
run_test()
77+
{
78+
# We change directories to make sure that python won't find the copy
79+
# of numpy in the source directory.
80+
mkdir -p empty
81+
cd empty
82+
INSTALLDIR=$(python -c "import os; import numpy; print(os.path.dirname(numpy.__file__))")
83+
export PYTHONWARNINGS=default
84+
python ../tools/test-installed-numpy.py # --mode=full
85+
# - coverage run --source=$INSTALLDIR --rcfile=../.coveragerc $(which python) ../tools/test-installed-numpy.py
86+
# - coverage report --rcfile=../.coveragerc --show-missing
87+
}
88+
89+
if [ "$USE_CHROOT" != "1" ] && [ "$USE_BENTO" != "1" ]; then
90+
setup_base
91+
run_test
92+
elif [ -n "$USE_CHROOT" ] && [ $# -eq 0 ]; then
93+
DIR=/chroot
94+
setup_chroot $DIR
95+
# run again in chroot with this time testing
96+
sudo linux32 chroot $DIR bash -c "cd numpy && $0 test"
97+
elif [ -n "$USE_BENTO" ] && [ $# -eq 0 ]; then
98+
setup_bento
99+
# run again this time testing
100+
$0 test
101+
else
102+
run_test
103+
fi
104+

0 commit comments

Comments
 (0)