Last change
on this file since 612 was
602,
checked in by anonymous, 7 years ago
|
Confirm tests run correctly (for mysql >= 5.7 need to set sql-mode=)
|
File size:
1.2 KB
|
Rev | Line | |
---|
[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] | 10 | function 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. |
---|
| 18 | cd `dirname $0`; |
---|
| 19 | |
---|
[468] | 20 | # Get required ENV variables. |
---|
| 21 | if [[ -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."; |
---|
| 23 | fi |
---|
[599] | 24 | for 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; |
---|
| 29 | done |
---|
| 30 | |
---|
[399] | 31 | # Create database. |
---|
[599] | 32 | mysql -e "CREATE DATABASE IF NOT EXISTS \`${DB_NAME}\`" || err "Failed to create database '${DB_NAME}"; |
---|
[399] | 33 | |
---|
[468] | 34 | # Go! |
---|
| 35 | echo "Running the tests!"; |
---|
| 36 | echo "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 ' |
---|
[602] | 40 | phpunit --stderr || err "\nSomething went wrong (code $?). If there is no output above, check the php_error_log"; |
---|
[599] | 41 | |
---|
Note: See
TracBrowser
for help on using the repository browser.