source: trunk/tests/run_tests.sh @ 599

Last change on this file since 599 was 599, checked in by anonymous, 7 years ago

Update tests to function with phpunit 5.7 (not tested)

File size: 1.2 KB
RevLine 
[468]1#!/bin/bash
[15]2
[468]3# This script sets-up the test environment and runs all tests.
4# You'll want to define your local mysql credentials for a test
5# database as environment variables, e.g., in ~/.bash_profile:
6#  export DB_NAME="test"
7#  export DB_USER="test"
8#  export DB_PASS="..."
9
[599]10function err {
11    MSG="$1";
12    IFS='';
13    echo -e $MSG 1>&2
14    exit 1;
15}
16
[15]17# Be in the directory with all the tests.
18cd `dirname $0`;
19
[468]20# Get required ENV variables.
21if [[ -z "$DB_USER$DB_PASS$DB_NAME" ]]; then
22    echo "MySQL test DB credential environment variables are missing.\nSet these in ~/.bash_profile to avoid seeing these prompts each time.";
23fi
[599]24for E in DB_SERVER DB_NAME DB_USER DB_PASS; do
[468]25    while [[ -z ${!E} ]]; do
26        read -p "$E: " $E;
27    done
28    export $E;
29done
30
[399]31# Create database.
[599]32mysql -e "CREATE DATABASE IF NOT EXISTS \`${DB_NAME}\`" || err "Failed to create database '${DB_NAME}";
[399]33
[468]34# Go!
35echo "Running the tests!";
36echo "You'll want to 'tail -f /tmp/codebase_test_log' and watch for errors.";
37
38# Config options go in phpunit.xml
39# phpunit --tap | grep -v '^ok '
[599]40phpunit --stderr --colors --debug || err "\nSomething went wrong (code $?). If there is no output above, check the php_error_log";
41
Note: See TracBrowser for help on using the repository browser.