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
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
[653]10# Run an individual test like this:
11# ./tests/run_tests.sh /Users/q/src/codebase/trunk/tests/UtilitiesTest.php
12
[599]13function err {
14    MSG="$1";
15    IFS='';
16    echo -e $MSG 1>&2
17    exit 1;
18}
19
[15]20# Be in the directory with all the tests.
21cd `dirname $0`;
22
[468]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
[599]27for E in DB_SERVER DB_NAME DB_USER DB_PASS; do
[468]28    while [[ -z ${!E} ]]; do
29        read -p "$E: " $E;
30    done
31    export $E;
32done
33
[399]34# Create database.
[599]35mysql -e "CREATE DATABASE IF NOT EXISTS \`${DB_NAME}\`" || err "Failed to create database '${DB_NAME}";
[399]36
[468]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 '
[653]43../vendor/phpunit/phpunit/composer/bin/phpunit --stderr "$@" || err "\nSomething went wrong (code $?). If there is no output above, check the php_error_log";
[599]44
Note: See TracBrowser for help on using the repository browser.