From a388767848b8628bd368a32c7468f2693215dabd Mon Sep 17 00:00:00 2001 From: David Grudl Date: Thu, 18 Oct 2012 23:00:12 +0200 Subject: [PATCH] added .travis.yml & other files --- .travis.yml | 11 +++ readme.md | 6 ++ tests/.gitignore | 4 + tests/RunTests.bat | 11 +++ tests/bootstrap.php | 18 ---- tests/config.ini | 67 --------------- tests/{ => dibi}/DibiFluent.cloning.phpt | 3 +- tests/dibi/bootstrap.php | 14 ++++ tests/dibi/config.php | 77 ++++++++++++++++++ tests/{ => dibi}/data/sample.mdb | Bin .../data/sample.mysql.sql} | 0 tests/{ => dibi}/data/sample.sdb | Bin tests/{ => dibi}/data/sample.sdb3 | Bin tests/php-unix.ini | 2 + tests/php-win.ini | 3 + tests/run-tests.sh | 50 ++++++++++++ 16 files changed, 179 insertions(+), 87 deletions(-) create mode 100644 .travis.yml create mode 100644 tests/.gitignore create mode 100644 tests/RunTests.bat delete mode 100644 tests/bootstrap.php delete mode 100644 tests/config.ini rename tests/{ => dibi}/DibiFluent.cloning.phpt (95%) create mode 100644 tests/dibi/bootstrap.php create mode 100644 tests/dibi/config.php rename tests/{ => dibi}/data/sample.mdb (100%) rename tests/{data/sample.mysql => dibi/data/sample.mysql.sql} (100%) rename tests/{ => dibi}/data/sample.sdb (100%) rename tests/{ => dibi}/data/sample.sdb3 (100%) create mode 100644 tests/php-unix.ini create mode 100644 tests/php-win.ini create mode 100755 tests/run-tests.sh diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..9229fd85 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,11 @@ +language: php +php: + - 5.3.3 + - 5.4 + - 5.5 + +script: VERBOSE=true ./tests/run-tests.sh -s tests/ + +before_script: + # Install Nette Tester + - composer install --no-interaction --dev diff --git a/readme.md b/readme.md index 82d395bb..9f0f1bd9 100644 --- a/readme.md +++ b/readme.md @@ -16,3 +16,9 @@ Refer to the `examples` directory for examples. Dibi documentation is available on the [homepage](http://dibiphp.com). Dibi requires PHP 5.2.0 or later. It has been tested with PHP 5.5 too. + + + +----- + +[![Build Status](https://secure.travis-ci.org/dg/dibi.png?branch=master)](http://travis-ci.org/dg/dibi) diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 00000000..2c211780 --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1,4 @@ +/*/output +/coverage.dat +/test.log +/tmp diff --git a/tests/RunTests.bat b/tests/RunTests.bat new file mode 100644 index 00000000..98a5d8ac --- /dev/null +++ b/tests/RunTests.bat @@ -0,0 +1,11 @@ +@ECHO OFF + +IF NOT EXIST "%~dp0..\vendor\nette\tester" ( + ECHO Nette Tester is missing. You can install it using Composer: + ECHO php composer.phar update --dev + EXIT /B 2 +) + +php.exe -n "%~dp0..\vendor\nette\tester\Tester\tester.php" -p php-cgi.exe -c "%~dp0php-win.ini" -j 20 -log "%~dp0test.log" %* + +rmdir "%~dp0/tmp" /S /Q diff --git a/tests/bootstrap.php b/tests/bootstrap.php deleted file mode 100644 index 4e291c2b..00000000 --- a/tests/bootstrap.php +++ /dev/null @@ -1,18 +0,0 @@ - array( + 'driver' => 'mysql', + 'host' => 'localhost', + 'username' => 'root', + 'password' => 'xxx', + 'charset' => 'utf8', + ), + + 'mysqli' => array( + 'driver' => 'mysqli', + 'host' => 'localhost', + 'username' => 'dibi', + 'password' => 'dibi', + 'charset' => 'utf8', + ), + + 'sqlite' => array( + 'driver' => 'sqlite', + 'database' => dirname(__FILE__) . '/data/sample.sdb', + ), + + 'sqlite3' => array( + 'driver' => 'sqlite3', + 'database' => dirname(__FILE__) . '/data/sample.sdb3', + ), + + 'odbc' => array( + 'driver' => 'odbc', + 'username' => 'dibi', + 'password' => 'dibi', + 'dsn' => 'Driver={Microsoft Access Driver (*.mdb)};Dbq=' . dirname(__FILE__) . '/data/sample.mdb', + ), + + 'postgresql' => array( + 'driver' => 'postgre', + 'host' => 'localhost', + 'port' => '5432', + 'username' => 'dibi', + 'password' => 'dibi', + 'persistent' => '1', + ), + + 'sqlite-pdo' => array( + 'driver' => 'pdo', + 'dsn' => 'sqlite2::' . dirname(__FILE__) . '/data/sample.sdb', + ), + + 'mysql-pdo' => array( + 'driver' => 'pdo', + 'dsn' => 'mysql:host=localhost', + 'username' => 'dibi', + 'password' => 'dibi', + ), + + 'mssql' => array( + 'driver' => 'mssql', + 'host' => 'localhost', + 'username' => 'dibi', + 'password' => 'dibi', + ), + + 'mssql2005' => array( + 'driver' => 'mssql2005', + 'host' => '(local)', + 'username' => 'dibi', + 'password' => 'dibi', + ), + + 'oracle' => array( + 'driver' => 'oracle', + 'username' => 'dibi', + 'password' => 'dibi', + ), +); diff --git a/tests/data/sample.mdb b/tests/dibi/data/sample.mdb similarity index 100% rename from tests/data/sample.mdb rename to tests/dibi/data/sample.mdb diff --git a/tests/data/sample.mysql b/tests/dibi/data/sample.mysql.sql similarity index 100% rename from tests/data/sample.mysql rename to tests/dibi/data/sample.mysql.sql diff --git a/tests/data/sample.sdb b/tests/dibi/data/sample.sdb similarity index 100% rename from tests/data/sample.sdb rename to tests/dibi/data/sample.sdb diff --git a/tests/data/sample.sdb3 b/tests/dibi/data/sample.sdb3 similarity index 100% rename from tests/data/sample.sdb3 rename to tests/dibi/data/sample.sdb3 diff --git a/tests/php-unix.ini b/tests/php-unix.ini new file mode 100644 index 00000000..e3794e17 --- /dev/null +++ b/tests/php-unix.ini @@ -0,0 +1,2 @@ +[PHP] +;extension_dir = "./ext" diff --git a/tests/php-win.ini b/tests/php-win.ini new file mode 100644 index 00000000..0f8d7b63 --- /dev/null +++ b/tests/php-win.ini @@ -0,0 +1,3 @@ +[PHP] +extension_dir = "./ext" +extension=php_sqlite3.dll diff --git a/tests/run-tests.sh b/tests/run-tests.sh new file mode 100755 index 00000000..80a8f3bb --- /dev/null +++ b/tests/run-tests.sh @@ -0,0 +1,50 @@ +#!/bin/sh + +# Path to this script's directory +dir=$(cd `dirname $0` && pwd) + +# Path to test runner script +runnerScript="$dir/../vendor/nette/tester/Tester/tester.php" +if [ ! -f "$runnerScript" ]; then + echo "Nette Tester is missing. You can install it using Composer:" >&2 + echo "php composer.phar update --dev." >&2 + exit 2 +fi + +# Default runner arguments +jobsNum=20 +phpIni="$dir/php-unix.ini" + +# Command line arguments processing +for i in `seq 1 $#`; do + if [ "$1" = "-j" ]; then + shift + if [ -z "$1" ]; then + echo "Missing argument for -j option." >&2 + exit 2 + fi + jobsNum="$1" + + elif [ "$1" = "-c" ]; then + shift + if [ -z "$1" ]; then + echo "Missing argument for -c option." >&2 + exit 2 + fi + phpIni="$1" + + else + set -- "$@" "$1" + fi + shift +done + +# Run tests with script's arguments, doubled -c option intentionally +php -c "$phpIni" "$runnerScript" -j "$jobsNum" -c "$phpIni" "$@" +error=$? + +# Print *.actual content if tests failed +if [ "${VERBOSE-false}" != "false" -a $error -ne 0 ]; then + for i in $(find . -name \*.actual); do echo "--- $i"; cat $i; echo; echo; done + exit $error +fi