Skip to content

Commit

Permalink
run tests in docker container
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony Crisci committed May 9, 2019
1 parent 64aebe1 commit 97d0455
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 15 deletions.
19 changes: 7 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
language: python
sudo: required
dist: bionic
python:
- "3.6"
language: minimal
dist: xenial
services:
- docker
before_install:
- /usr/lib/apt/apt-helper download-file http://debian.sur5r.net/i3/pool/main/s/sur5r-keyring/sur5r-keyring_2019.02.01_all.deb keyring.deb SHA256:176af52de1a976f103f9809920d80d02411ac5e763f695327de9fa6aff23f416
- sudo dpkg -i ./keyring.deb
- echo "deb http://debian.sur5r.net/i3/ $(grep '^DISTRIB_CODENAME=' /etc/lsb-release | cut -f2 -d=) universe" | sudo tee /etc/apt/sources.list.d/sur5r-i3.list > /dev/null
- sudo apt-get update -qq
- sudo apt-get install xvfb i3
- sudo pip install pytest
script: ./run-tests.py
- docker build -t i3ipc-python-test .
script:
- docker run -it i3ipc-python-test
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM ubuntu:19.04

WORKDIR /app

RUN apt-get update && apt-get install -y python3-pip i3 xvfb

COPY requirements.txt .
RUN pip3 install -r requirements.txt

ADD . /app

RUN find -name __pycache__ | xargs rm -r || true
CMD ["./run-tests.py"]
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: test format lint all clean publish docs coverage
.PHONY: test format lint all clean publish docs coverage docker-test
.DEFAULT_GOAL := all

source_dirs = i3ipc test examples
Expand All @@ -12,6 +12,10 @@ format:
test:
./run-tests.py

docker-test:
docker build -t i3ipc-python-test .
docker run -it i3ipc-python-test

clean:
rm -rf dist i3ipc.egg-info build docs/_build
rm -rf `find -type d -name __pycache__`
Expand All @@ -26,4 +30,4 @@ docs:
livedocs:
sphinx-autobuild docs docs/_build/html --watch i3ipc -i '*swp' -i '*~'

all: format lint test
all: format lint docker-test
1 change: 1 addition & 0 deletions i3ipc/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def message(self, message_type, payload):
if not self.auto_reconnect:
raise (e)

# XXX: can the socket path change between restarts?
if not self._wait_for_socket():
raise (e)

Expand Down
4 changes: 3 additions & 1 deletion run-tests.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

import subprocess
from subprocess import Popen
Expand All @@ -8,6 +8,7 @@
import sys
import re
import time
import random

try:
from shutil import which
Expand Down Expand Up @@ -112,6 +113,7 @@ def run_pytest(display):
env['DISPLAY'] = ':%d' % display
env['PYTHONPATH'] = here
env['_I3IPC_TEST'] = '1'
env['I3SOCK'] = f'/tmp/i3ipc-test-sock-{display}'
subprocess.run([PYTEST], env=env)


Expand Down

0 comments on commit 97d0455

Please sign in to comment.