Skip to content

Commit 0df9bb6

Browse files
committed
Merge pull request spyder-ide#2281 from goanpeca/travis-test
Add travis support to test that Spyder starts correctly.
2 parents 3988ba6 + 1637bc4 commit 0df9bb6

File tree

4 files changed

+218
-0
lines changed

4 files changed

+218
-0
lines changed

.travis.yml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# After changing this file, check it on http://yaml-online-parser.appspot.com/
2+
3+
language: python
4+
5+
env:
6+
global:
7+
- MINICONDA_VERSION="latest"
8+
- MINICONDA_LINUX="Linux-x86_64"
9+
- MINICONDA_OSX="MacOSX-x86_64"
10+
11+
matrix:
12+
include:
13+
# Linux using miniconda
14+
- python: "2.7"
15+
env: USE_QT_API=PyQt4 USE_CONDA=true
16+
os: linux
17+
- python: "3.3"
18+
env: USE_QT_API=PyQt4 USE_CONDA=true
19+
os: linux
20+
- python: "3.4"
21+
env: USE_QT_API=PyQt4 USE_CONDA=true
22+
os: linux
23+
#- python: "2.7"
24+
# env: USE_QT_API=PyQt5 USE_CONDA=true
25+
# os: linux
26+
#- python: "3.3"
27+
# env: USE_QT_API=PyQt5 USE_CONDA=true
28+
# os: linux
29+
#- python: "3.4"
30+
# env: USE_QT_API=PyQt5 USE_CONDA=true
31+
# os: linux
32+
#- python: "2.7"
33+
# env: USE_QT_API=PySide USE_CONDA=true
34+
# os: linux
35+
# Linux using apt-get/pip packages
36+
#- python: "2.7"
37+
# env: USE_QT_API=PyQt4 USE_CONDA=false
38+
# os: linux
39+
#- python: "2.7"
40+
# env: USE_QT_API=PySide USE_CONDA=false
41+
# os: linux
42+
#- python: "3.3"
43+
# env: USE_QT_API=PySide USE_CONDA=false
44+
# os: linux
45+
#- python: "3.4"
46+
# env: USE_QT_API=PySide USE_CONDA=false
47+
# os: linux
48+
49+
before_install:
50+
- sudo apt-get update
51+
- "export DISPLAY=:99.0"
52+
- "sh -e /etc/init.d/xvfb start"
53+
54+
install:
55+
- ./continuous_integration/travis_install.sh;
56+
- export PATH="$HOME/miniconda/bin:$PATH";
57+
- source activate test-environment;
58+
- QT_API=$USE_QT_API;
59+
60+
script:
61+
- python bootstrap.py --test-travis 30
62+

bootstrap.py

+12
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242
default=False, help="Disable Apport exception hook (Ubuntu)")
4343
parser.add_option('--debug', action='store_true',
4444
default=False, help="Run Spyder in debug mode")
45+
parser.add_option('--test-travis', dest="shutdown_time", default=None,
46+
help="Closes the application after the entered number of "
47+
"seconds. Useful in continuous integration testing.")
48+
4549
options, args = parser.parse_args()
4650

4751
assert options.gui in (None, 'pyqt5', 'pyqt', 'pyside'), \
@@ -159,4 +163,12 @@
159163
# gmtime() converts float into tuple, but loses milliseconds
160164
("%.4f" % time_lapse).split('.')[1])
161165

166+
# Set variable to start timer inside spyder application
167+
if options.shutdown_time is not None:
168+
timer_seconds = int(options.shutdown_time)
169+
os.environ['SPYDER_TEST_TRAVIS'] = 'True'
170+
# In miliseconds
171+
os.environ['SPYDER_TEST_TRAVIS_TIMER'] = str(timer_seconds*1000)
172+
print("\nSpyder will automatically shut down in {} seconds.\n".format(timer_seconds))
173+
162174
start_app.main()
+135
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
#!/usr/bin/env bash
2+
3+
set -ex
4+
5+
PY_VERSION=$TRAVIS_PYTHON_VERSION
6+
WHEELHOUSE_URI=http://travis-wheels.scikit-image.org/
7+
8+
install_conda()
9+
{
10+
# Define the value to download
11+
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
12+
MINICONDA_OS=$MINICONDA_LINUX;
13+
elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
14+
MINICONDA_OS=$MINICONDA_OSX;
15+
fi
16+
17+
# You may want to periodically update this, although the conda update
18+
# conda line below will keep everything up-to-date. We do this
19+
# conditionally because it saves us some downloading if the version is
20+
# the same.
21+
22+
if [ "$PY_VERSION" = "2.7" ]; then
23+
wget "http://repo.continuum.io/miniconda/Miniconda-$MINICONDA_VERSION-$MINICONDA_OS.sh" -O miniconda.sh;
24+
else
25+
wget "http://repo.continuum.io/miniconda/Miniconda3-$MINICONDA_VERSION-$MINICONDA_OS.sh" -O miniconda.sh;
26+
fi
27+
28+
bash miniconda.sh -b -p "$HOME/miniconda";
29+
export PATH="$HOME/miniconda/bin:$PATH";
30+
hash -r;
31+
conda config --set always_yes yes --set changeps1 no;
32+
conda update -q conda;
33+
34+
# Useful for debugging any issues with conda
35+
conda info -a;
36+
37+
# Test environments for different Qt bindings
38+
if [ "$USE_QT_API" = "PyQt5" ]; then
39+
#sudo apt-get install -q "^libxcb.*" libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev
40+
#sudo apt-get install -q libxcb-sync0-dev libxcb-render-util0 libxcb-image0 libxcb-xfixes0 libxcb-randr0 libxcb-keysyms1
41+
#sudo cp- /usr/lib/libxcb-render-util.so.0 /usr/lib/x86_64-linux-gnu/libxcb-render-util.so.0
42+
43+
sudo apt-get install -q "^libxcb.*" libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev
44+
#sudo ln -sf /usr/lib/x86_64-linux-gnu/libxcb-render-util.so.0 /usr/lib/libxcb-render-util.so.0
45+
46+
conda config --add channels dsdale24;
47+
conda create -q -n test-environment python=$PY_VERSION sphinx sip qt5 pyqt5;
48+
ldd "$HOME/miniconda/envs/test-environment/lib/qt5/plugins/platforms/libqxcb.so"
49+
50+
# libxcb-atom1-dev libxcb-event1-dev libxcb-icccm1-dev
51+
# ldd /home/goanpeca/anaconda/envs/test-environment/lib/qt5/plugins/platforms/libqxcb.so
52+
#
53+
elif [ "$USE_QT_API" = "PyQt4" ]; then
54+
conda create -q -n test-environment python=$PY_VERSION sphinx sip qt pyqt;
55+
elif [ "$USE_QT_API" = "PySide" ]; then
56+
conda create -q -n test-environment python=$PY_VERSION sphinx sip qt pyside;
57+
fi
58+
59+
conda install -q -n test-environment $TEST_PACKAGES
60+
}
61+
62+
install_pyside()
63+
{
64+
# Currently support for python 2.7, 3.3, 3.4
65+
# http://stackoverflow.com/questions/24489588/how-can-i-install-pyside-on-travis
66+
sudo apt-get install libqt4-dev;
67+
pip install --upgrade pip;
68+
pip install PySide --no-index --find-links=$WHEELHOUSE_URI;
69+
# Travis CI servers use virtualenvs, so we need to finish the install by the following
70+
POSTINSTALL=$(find ~/virtualenv/ -type f -name "pyside_postinstall.py";)
71+
python $POSTINSTALL -install;
72+
}
73+
74+
install_qt4()
75+
{
76+
# Install Qt and then update the Matplotlib settings
77+
sudo apt-get install -q libqt4-dev pyqt4-dev-tools;
78+
79+
if [[ $PY_VERSION == 2.7* ]]; then
80+
sudo apt-get install python-dev
81+
sudo apt-get install -q python-qt4
82+
else
83+
sudo apt-get install python3-dev
84+
fi
85+
86+
# http://stackoverflow.com/a/9716100
87+
LIBS=( PyQt4 sip.so )
88+
89+
VAR=( $(which -a python$PY_VERSION) )
90+
91+
GET_PYTHON_LIB_CMD="from distutils.sysconfig import get_python_lib; print (get_python_lib())"
92+
LIB_VIRTUALENV_PATH=$(python -c "$GET_PYTHON_LIB_CMD")
93+
LIB_SYSTEM_PATH=$(${VAR[-1]} -c "$GET_PYTHON_LIB_CMD")
94+
95+
for LIB in ${LIBS[@]}
96+
do
97+
sudo ln -sf $LIB_SYSTEM_PATH/$LIB $LIB_VIRTUALENV_PATH/$LIB
98+
done
99+
}
100+
101+
install_qt5()
102+
{
103+
echo "Not supported yet"
104+
}
105+
106+
107+
install_apt_pip()
108+
{
109+
# Test for different Qt bindings
110+
if [ "$USE_QT_API" = "PyQt5" ]; then
111+
#sudo apt-get install -qq python-sip python-qt5 python-sphinx --fix-missing;
112+
#sudo apt-get install -qq python3-sip python3-pyqt5 --fix-missing;
113+
install_qt5
114+
elif [ "$USE_QT_API" = "PyQt4" ]; then
115+
install_qt4;
116+
elif [ "$USE_QT_API" = "PySide" ]; then
117+
install_pyside;
118+
fi
119+
120+
if [ "$PY_VERSION" = "2.7" ]; then
121+
TEST_PACKAGES+=" rope"
122+
fi
123+
pip install -U $TEST_PACKAGES
124+
}
125+
126+
if [ "$USE_CONDA" = true ] ; then
127+
export TEST_PACKAGES="ipython-qtconsole matplotlib pandas pep8 psutil pyflakes pygments pylint sphinx sympy"
128+
export SOURCE=`source activate test-environment`
129+
install_conda;
130+
else
131+
export TEST_PACKAGES="IPython jedi matplotlib pandas pep8 psutil pyflakes pygments pylint sphinx sympy"
132+
install_apt_pip;
133+
fi
134+
135+
#sleep 60;

spyderlib/spyder.py

+9
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ def __init__(self, options=None):
306306
self.multithreaded = options.multithreaded
307307
self.light = options.light
308308
self.new_instance = options.new_instance
309+
self.test_travis = os.environ.get('SPYDER_TEST_TRAVIS', None)
309310

310311
self.debug_print("Start of MainWindow constructor")
311312

@@ -459,6 +460,14 @@ def __init__(self, options=None):
459460
res = set_windows_appusermodelid()
460461
debug_print("appusermodelid: " + str(res))
461462

463+
# Setting QTimer if running in travis
464+
if self.test_travis is not None:
465+
global MAIN_APP
466+
timer_shutdown_time = int(os.environ['SPYDER_TEST_TRAVIS_TIMER'])
467+
self.timer_shutdown = QTimer(self)
468+
self.timer_shutdown.timeout.connect(MAIN_APP.quit)
469+
self.timer_shutdown.start(timer_shutdown_time)
470+
462471
# Showing splash screen
463472
self.splash = SPLASH
464473
if not self.light:

0 commit comments

Comments
 (0)