Skip to content

Commit af8c0e1

Browse files
authored
test script improvements (GoogleCloudPlatform#397)
* CS fixer now works from any path * test suites run from any path and if `TEST_DIRECTORIES` is set, only tests those * ensures the check happens from the current path * adds path-mode intersection to cs fixer
1 parent ccca98d commit af8c0e1

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

testing/run_all_tests.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515

1616
set -ex
1717

18+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
1819
# only run when explicitly set
1920
if [ "${RUN_CS_FIXER}" = "true" ]; then
20-
testing/run_cs_check.sh;
21+
$DIR/run_cs_check.sh;
2122
fi
22-
testing/run_test_suite.sh;
23+
$DIR/run_test_suite.sh;
2324
# only run for travis crons
2425
if [ "${TRAVIS_EVENT_TYPE}" != "pull_request" ]; then
25-
testing/run_dependency_check.sh;
26+
$DIR/run_dependency_check.sh;
2627
fi

testing/run_cs_check.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,6 @@ if [ -f "vendor/bin/php-cs-fixer" ]; then
2222
elif [ -f "./php-cs-fixer" ]; then
2323
PHP_CS_FIXER="./php-cs-fixer"
2424
fi
25-
$PHP_CS_FIXER fix --dry-run --diff
25+
26+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
27+
$PHP_CS_FIXER fix --dry-run --diff --config="$DIR/../.php_cs.dist" --path-mode=intersection .

testing/run_test_suite.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@ else
2929
RUN_ALL_TESTS=0
3030
fi
3131

32+
if [ "${TEST_DIRECTORIES}" = "" ]; then
33+
TEST_DIRECTORIES="*"
34+
fi
35+
3236
# Loop through all directories containing "phpunit.xml*" and run the test suites.
33-
find * -name 'phpunit.xml*' -not -path '*/vendor/*' -exec dirname {} \; | while read DIR
37+
find $TEST_DIRECTORIES -name 'phpunit.xml*' -not -path '*vendor/*' -exec dirname {} \; | while read DIR
3438
do
3539
# Only run tests for samples that have changed.
3640
if [ "$RUN_ALL_TESTS" -ne "1" ]; then

0 commit comments

Comments
 (0)