source: trunk/tests/run_tests.sh

Last change on this file was 653, checked in by anonymous, 5 years ago

Update fancyTxt()

File size: 1.3 KB
Line 
1#!/bin/bash
2
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
10# Run an individual test like this:
11# ./tests/run_tests.sh /Users/q/src/codebase/trunk/tests/UtilitiesTest.php
12
13function err {
14    MSG="$1";
15    IFS='';
16    echo -e $MSG 1>&2
17    exit 1;
18}
19
20# Be in the directory with all the tests.
21cd `dirname $0`;
22
23# Get required ENV variables.
24if [[ -z "$DB_USER$DB_PASS$DB_NAME" ]]; then
25    echo "MySQL test DB credential environment variables are missing.\nSet these in ~/.bash_profile to avoid seeing these prompts each time.";
26fi
27for E in DB_SERVER DB_NAME DB_USER DB_PASS; do
28    while [[ -z ${!E} ]]; do
29        read -p "$E: " $E;
30    done
31    export $E;
32done
33
34# Create database.
35mysql -e "CREATE DATABASE IF NOT EXISTS \`${DB_NAME}\`" || err "Failed to create database '${DB_NAME}";
36
37# Go!
38echo "Running the tests!";
39echo "You'll want to 'tail -f /tmp/codebase_test_log' and watch for errors.";
40
41# Config options go in phpunit.xml
42# phpunit --tap | grep -v '^ok '
43../vendor/phpunit/phpunit/composer/bin/phpunit --stderr "$@" || err "\nSomething went wrong (code $?). If there is no output above, check the php_error_log";
44
Note: See TracBrowser for help on using the repository browser.