forked from googleapis/google-cloud-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-package-tests.sh
More file actions
67 lines (62 loc) · 2.57 KB
/
run-package-tests.sh
File metadata and controls
67 lines (62 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
# Copyright 2022 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# first argument can be a directory
DIRS=$(find * -maxdepth 0 -type d -name '[A-Z]*')
if [ "$#" -eq 1 ]; then
DIRS=$1
elif [ "$#" -ne 0 ]; then
echo "usage: run-package-tests.sh [DIR]"
exit 1;
fi
# Use "composer-local.json" to avoid unwanted changes
export COMPOSER=composer-local.json
FAILED_FILE=$(mktemp -d)/failed
for DIR in ${DIRS}; do {
cp ${DIR}/composer.json ${DIR}/composer-local.json
# Update composer to use local packages
for i in BigQuery,cloud-bigquery Core,cloud-core Logging,cloud-logging PubSub,cloud-pubsub Storage,cloud-storage ShoppingCommonProtos,shopping-common-protos,0.1; do
IFS=","; set -- $i;
if grep -q "\"google/$2\":" ${DIR}/composer.json; then
if [ -z "$3" ]; then VERSION="1.100"; else VERSION=$3; fi
composer config repositories.$2 "{\"type\": \"path\", \"url\": \"../$1\", \"options\":{\"versions\":{\"google/$2\":\"$VERSION\"}}}" -d ${DIR}
fi
done
echo "Installing composer in $DIR"
COMPOSER_ROOT_VERSION=$(cat $DIR/VERSION) composer -q --no-interaction --no-ansi --no-progress update -d ${DIR};
if [ $? != 0 ]; then
echo "$DIR: composer install failed" >> "${FAILED_FILE}"
# run again but without "-q" so we can see the error
COMPOSER_ROOT_VERSION=$(cat $DIR/VERSION) composer --no-interaction --no-ansi --no-progress update -d ${DIR};
continue
fi
echo "Running $DIR Unit Tests"
${DIR}/vendor/bin/phpunit -c ${DIR}/phpunit.xml.dist;
if [ $? != 0 ]; then
echo "$DIR: failed" >> "${FAILED_FILE}"
fi
if [ -f "${DIR}/phpunit-snippets.xml.dist" ]; then
echo "Running $DIR Snippet Tests"
${DIR}/vendor/bin/phpunit -c ${DIR}/phpunit-snippets.xml.dist;
if [ $? != 0 ]; then
echo "$DIR (snippets): failed" >> "${FAILED_FILE}"
fi
fi
}; done
if [ -f "${FAILED_FILE}" ]; then
echo "--------- Failed tests --------------"
cat "${FAILED_FILE}"
echo "-------------------------------------"
exit 1
fi