diff --git a/install.sh b/install.sh index 4bd112a5..e3c9f72d 100755 --- a/install.sh +++ b/install.sh @@ -6,12 +6,19 @@ should_add_alias () { # Install os dependencies: if [ -f $(which apt-get) ]; then - sudo apt-get update - sudo apt-get install python-pip + # Debian/ubuntu: + sudo apt-get update -yy + sudo apt-get install -yy python-pip python-dev else if [ -f $(which brew) ]; then + # OS X: brew update brew install python + else + # Genreic way: + wget https://bootstrap.pypa.io/get-pip.py + sudo python get-pip.py + rm get-pip.py fi fi diff --git a/tests/functional/plots.py b/tests/functional/plots.py index 11b1f6be..611742f2 100644 --- a/tests/functional/plots.py +++ b/tests/functional/plots.py @@ -1,4 +1,3 @@ -from time import sleep from pexpect import TIMEOUT diff --git a/tests/functional/test_install.py b/tests/functional/test_install.py new file mode 100644 index 00000000..b1867f62 --- /dev/null +++ b/tests/functional/test_install.py @@ -0,0 +1,25 @@ +import pytest +from pexpect import TIMEOUT +from tests.functional.utils import spawn, functional, bare + +envs = ((u'bash', 'ubuntu-bash', u''' +FROM ubuntu:latest +RUN apt-get update +RUN apt-get install -yy bash +'''), (u'bash', 'generic-bash', u''' +FROM fedora:latest +RUN dnf install -yy python-devel sudo which gcc +''')) + + +@functional +@pytest.mark.skipif( + bool(bare), reason="Can't be tested in bare run") +@pytest.mark.parametrize('shell, tag, dockerfile', envs) +def test_installation(request, shell, tag, dockerfile): + proc = spawn(request, tag, dockerfile, shell, install=False) + proc.sendline(u'cat /src/install.sh | sh - && $0') + proc.sendline(u'thefuck --version') + assert proc.expect([TIMEOUT, u'The Fuck'], timeout=600) + proc.sendline(u'fuck') + assert proc.expect([TIMEOUT, u'No fucks given']) diff --git a/tests/functional/utils.py b/tests/functional/utils.py index a1aeebb2..2a7c1627 100644 --- a/tests/functional/utils.py +++ b/tests/functional/utils.py @@ -24,7 +24,7 @@ def build_container(tag, dockerfile): shutil.rmtree(tmpdir) -def spawn(request, tag, dockerfile, cmd): +def spawn(request, tag, dockerfile, cmd, install=True): if bare: proc = pexpect.spawnu(cmd) else: @@ -32,7 +32,9 @@ def spawn(request, tag, dockerfile, cmd): build_container(tag, dockerfile) proc = pexpect.spawnu('docker run --volume {}:/src --tty=true ' '--interactive=true {} {}'.format(root, tag, cmd)) - proc.sendline('pip install /src') + if install: + proc.sendline('pip install /src') + proc.sendline('cd /') proc.logfile = sys.stdout