From dd72943501135cf9bcafb697c098f8f2afcf6fe2 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Fri, 16 Dec 2016 17:01:33 +0100 Subject: [PATCH] Added test script. This will fix #9 --- composer.json | 8 ++------ run-tests.sh | 32 ++++++++++++++++++++++++++++++++ tests/{Unit => }/.gitkeep | 0 3 files changed, 34 insertions(+), 6 deletions(-) create mode 100755 run-tests.sh rename tests/{Unit => }/.gitkeep (100%) diff --git a/composer.json b/composer.json index f0dd639..9682d9a 100644 --- a/composer.json +++ b/composer.json @@ -12,9 +12,6 @@ "php": "^5.5 || ^7.0", "php-translation/common": "dev-master" }, - "require-dev": { - "phpunit/phpunit": "^4.5 || ^5.4" - }, "autoload": { "psr-4": { "Translation\\PlatformAdapter\\": "src/" @@ -26,8 +23,7 @@ } }, "scripts": { - "test": "vendor/bin/phpunit", - "test-ci": "vendor/bin/phpunit --coverage-text --coverage-clover=build/coverage.xml" + "test": "./run-tests.sh", + "test-ci": "./run-tests.sh --coverage-text --coverage-clover=build/coverage.xml" } } - diff --git a/run-tests.sh b/run-tests.sh new file mode 100755 index 0000000..84f8fbb --- /dev/null +++ b/run-tests.sh @@ -0,0 +1,32 @@ +#!/bin/bash +EXIT="0" +ROOT=$(pwd) + +for D in `find ./src -type d -mindepth 1 -maxdepth 1` +do + echo "Checking $D" + if grep -Fxq "$TRAVIS_PHP_VERSION" $D/travis.ini + then + cd $D + echo "Updating dependencies" + composer update + + echo "Running tests" + ./vendor/bin/phpunit "$@" + + EXITCODE=$? + + # If there is an error, make sure to return it. + if [ "$EXITCODE" -ne "0" ]; then + EXIT=$EXITCODE + printError $DIR $EXITCODE + fi + + cd $ROOT + else + echo "Skipping" + fi +done + +echo "Exiting with code: $EXIT" +exit "$EXIT" \ No newline at end of file diff --git a/tests/Unit/.gitkeep b/tests/.gitkeep similarity index 100% rename from tests/Unit/.gitkeep rename to tests/.gitkeep