run-tests.sh 1.2 KB
Newer Older
Loïc Dachary's avatar
tmp  
Loïc Dachary committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#!/bin/bash

set -ex

function run_selenium() {
    if ! docker inspect --type=container enough_selenium > /dev/null 2>&1 ; then
        docker run --rm --name enough_selenium -d selenium/standalone-firefox:2.53.1-beryllium
    fi
}

function kill_selenium() {
    docker rm -f enough_selenium || true
}

trap "kill_selenium" EXIT

17 18 19 20 21 22 23 24 25 26
function run_phpunit() {
    local docker_args
    if ! test "$GITLAB_CI" ; then
        docker_args="-v $(pwd):/opt/core/apps/enough"
    fi
    docker run --link enough_selenium:selenium --rm -e TRAVIS=true $docker_args enough_ci:latest /opt/vendor/bin/phpunit --bootstrap /opt/core/tests/bootstrap.php --fail-on-warning "$@"
}

function run_unit_tests() {
    local phpunit_args
27
    if ! test "$GITLAB_CI" ; then
28
        phpunit_args="--coverage-html=html"
29
    fi
30
    run_phpunit $phpunit_args --configuration phpunit.xml
31 32 33
    if ! test "$GITLAB_CI" ; then
        firefox html/index.html
    fi
Loïc Dachary's avatar
tmp  
Loïc Dachary committed
34 35
}

36 37 38 39 40 41 42 43 44 45 46 47 48
function run_acceptance_tests() {
    run_phpunit --configuration phpunit.integration.xml    
}

function run_tests() {
    run_selenium
    docker build -t enough_ci:latest ./
    for suite in "$@" ; do
        $suite || return 1
    done
}

run_tests "${@:-run_acceptance_tests run_unit_tests}"