Merge pull request #11622 from mehrdada/shellckec

Fix tools/run_tests/helper_scripts/*.sh to pass shellcheck
pull/13788/merge
Mehrdad Afshari 7 years ago committed by GitHub
commit 336bce09d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      tools/run_tests/helper_scripts/build_csharp.sh
  2. 8
      tools/run_tests/helper_scripts/build_php.sh
  3. 56
      tools/run_tests/helper_scripts/build_python.sh
  4. 4
      tools/run_tests/helper_scripts/build_python_msys2.sh
  5. 2
      tools/run_tests/helper_scripts/build_ruby.sh
  6. 4
      tools/run_tests/helper_scripts/bundle_install_wrapper.sh
  7. 14
      tools/run_tests/helper_scripts/post_tests_c.sh
  8. 2
      tools/run_tests/helper_scripts/post_tests_csharp.sh
  9. 14
      tools/run_tests/helper_scripts/post_tests_php.sh
  10. 2
      tools/run_tests/helper_scripts/post_tests_python.sh
  11. 16
      tools/run_tests/helper_scripts/post_tests_ruby.sh
  12. 4
      tools/run_tests/helper_scripts/pre_build_cmake.sh
  13. 2
      tools/run_tests/helper_scripts/pre_build_csharp.sh
  14. 2
      tools/run_tests/helper_scripts/pre_build_ruby.sh
  15. 6
      tools/run_tests/helper_scripts/run_grpc-node.sh
  16. 16
      tools/run_tests/helper_scripts/run_lcov.sh
  17. 14
      tools/run_tests/helper_scripts/run_python.sh
  18. 2
      tools/run_tests/helper_scripts/run_ruby.sh
  19. 2
      tools/run_tests/helper_scripts/run_ruby_end2end_tests.sh
  20. 8
      tools/run_tests/helper_scripts/run_tests_in_workspace.sh

@ -15,12 +15,12 @@
set -ex set -ex
cd $(dirname $0)/../../../src/csharp cd "$(dirname "$0")/../../../src/csharp"
if [ "$CONFIG" == "gcov" ] if [ "$CONFIG" == "gcov" ]
then then
# overriding NativeDependenciesConfigurationUnix makes C# project pick up the gcov flavor of grpc_csharp_ext # overriding NativeDependenciesConfigurationUnix makes C# project pick up the gcov flavor of grpc_csharp_ext
dotnet build --configuration $MSBUILD_CONFIG /p:NativeDependenciesConfigurationUnix=gcov Grpc.sln dotnet build --configuration "$MSBUILD_CONFIG" /p:NativeDependenciesConfigurationUnix=gcov Grpc.sln
else else
dotnet build --configuration $MSBUILD_CONFIG Grpc.sln dotnet build --configuration "$MSBUILD_CONFIG" Grpc.sln
fi fi

@ -18,9 +18,9 @@ set -ex
CONFIG=${CONFIG:-opt} CONFIG=${CONFIG:-opt}
# change to grpc repo root # change to grpc repo root
cd $(dirname $0)/../../.. cd "$(dirname "$0")/../../.."
root=`pwd` root=$(pwd)
export GRPC_LIB_SUBDIR=libs/$CONFIG export GRPC_LIB_SUBDIR=libs/$CONFIG
export CFLAGS="-Wno-parentheses-equality" export CFLAGS="-Wno-parentheses-equality"
@ -30,8 +30,8 @@ cd src/php
cd ext/grpc cd ext/grpc
phpize phpize
if [ "$CONFIG" != "gcov" ] ; then if [ "$CONFIG" != "gcov" ] ; then
./configure --enable-grpc=$root ./configure --enable-grpc="$root"
else else
./configure --enable-grpc=$root --enable-coverage ./configure --enable-grpc="$root" --enable-coverage
fi fi
make make

@ -16,13 +16,13 @@
set -ex set -ex
# change to grpc repo root # change to grpc repo root
cd $(dirname $0)/../../.. cd "$(dirname "$0")/../../.."
########################## ##########################
# Portability operations # # Portability operations #
########################## ##########################
PLATFORM=`uname -s` PLATFORM=$(uname -s)
function is_msys() { function is_msys() {
if [ "${PLATFORM/MSYS}" != "$PLATFORM" ]; then if [ "${PLATFORM/MSYS}" != "$PLATFORM" ]; then
@ -64,7 +64,7 @@ function venv() {
# Path to python executable within a virtual environment depending on the # Path to python executable within a virtual environment depending on the
# system. # system.
function venv_relative_python() { function venv_relative_python() {
if [ $(is_mingw) ]; then if [ "$(is_mingw)" ]; then
echo 'Scripts/python.exe' echo 'Scripts/python.exe'
else else
echo 'bin/python' echo 'bin/python'
@ -73,7 +73,7 @@ function venv_relative_python() {
# Distutils toolchain to use depending on the system. # Distutils toolchain to use depending on the system.
function toolchain() { function toolchain() {
if [ $(is_mingw) ]; then if [ "$(is_mingw)" ]; then
echo 'mingw32' echo 'mingw32'
else else
echo 'unix' echo 'unix'
@ -97,17 +97,17 @@ function script_realpath() {
#################### ####################
PYTHON=${1:-python2.7} PYTHON=${1:-python2.7}
VENV=${2:-$(venv $PYTHON)} VENV=${2:-$(venv "$PYTHON")}
VENV_RELATIVE_PYTHON=${3:-$(venv_relative_python)} VENV_RELATIVE_PYTHON=${3:-$(venv_relative_python)}
TOOLCHAIN=${4:-$(toolchain)} TOOLCHAIN=${4:-$(toolchain)}
if [ $(is_msys) ]; then if [ "$(is_msys)" ]; then
echo "MSYS doesn't directly provide the right compiler(s);" echo "MSYS doesn't directly provide the right compiler(s);"
echo "switch to a MinGW shell." echo "switch to a MinGW shell."
exit 1 exit 1
fi fi
ROOT=`pwd` ROOT=$(pwd)
export CFLAGS="-I$ROOT/include -std=gnu99 -fno-wrapv $CFLAGS" export CFLAGS="-I$ROOT/include -std=gnu99 -fno-wrapv $CFLAGS"
export GRPC_PYTHON_BUILD_WITH_CYTHON=1 export GRPC_PYTHON_BUILD_WITH_CYTHON=1
export LANG=en_US.UTF-8 export LANG=en_US.UTF-8
@ -117,7 +117,7 @@ export LANG=en_US.UTF-8
HOST_PYTHON=${HOST_PYTHON:-python} HOST_PYTHON=${HOST_PYTHON:-python}
# If ccache is available on Linux, use it. # If ccache is available on Linux, use it.
if [ $(is_linux) ]; then if [ "$(is_linux)" ]; then
# We're not on Darwin (Mac OS X) # We're not on Darwin (Mac OS X)
if [ -x "$(command -v ccache)" ]; then if [ -x "$(command -v ccache)" ]; then
if [ -x "$(command -v gcc)" ]; then if [ -x "$(command -v gcc)" ]; then
@ -137,46 +137,46 @@ fi
# it's possible that the virtualenv is still usable and we trust the tester to # it's possible that the virtualenv is still usable and we trust the tester to
# be able to 'figure it out' instead of us e.g. doing potentially expensive and # be able to 'figure it out' instead of us e.g. doing potentially expensive and
# unnecessary error recovery by `rm -rf`ing the virtualenv. # unnecessary error recovery by `rm -rf`ing the virtualenv.
($PYTHON -m virtualenv $VENV || ($PYTHON -m virtualenv "$VENV" ||
$HOST_PYTHON -m virtualenv -p $PYTHON $VENV || $HOST_PYTHON -m virtualenv -p "$PYTHON" "$VENV" ||
true) true)
VENV_PYTHON=`script_realpath "$VENV/$VENV_RELATIVE_PYTHON"` VENV_PYTHON=$(script_realpath "$VENV/$VENV_RELATIVE_PYTHON")
# pip-installs the directory specified. Used because on MSYS the vanilla Windows # pip-installs the directory specified. Used because on MSYS the vanilla Windows
# Python gets confused when parsing paths. # Python gets confused when parsing paths.
pip_install_dir() { pip_install_dir() {
PWD=`pwd` PWD=$(pwd)
cd $1 cd "$1"
($VENV_PYTHON setup.py build_ext -c $TOOLCHAIN || true) ($VENV_PYTHON setup.py build_ext -c "$TOOLCHAIN" || true)
$VENV_PYTHON -m pip install --no-deps . $VENV_PYTHON -m pip install --no-deps .
cd $PWD cd "$PWD"
} }
$VENV_PYTHON -m pip install --upgrade pip==9.0.1 $VENV_PYTHON -m pip install --upgrade pip==9.0.1
$VENV_PYTHON -m pip install setuptools $VENV_PYTHON -m pip install setuptools
$VENV_PYTHON -m pip install cython $VENV_PYTHON -m pip install cython
$VENV_PYTHON -m pip install six enum34 protobuf futures $VENV_PYTHON -m pip install six enum34 protobuf futures
pip_install_dir $ROOT pip_install_dir "$ROOT"
$VENV_PYTHON $ROOT/tools/distrib/python/make_grpcio_tools.py $VENV_PYTHON "$ROOT/tools/distrib/python/make_grpcio_tools.py"
pip_install_dir $ROOT/tools/distrib/python/grpcio_tools pip_install_dir "$ROOT/tools/distrib/python/grpcio_tools"
# Build/install health checking # Build/install health checking
$VENV_PYTHON $ROOT/src/python/grpcio_health_checking/setup.py preprocess $VENV_PYTHON "$ROOT/src/python/grpcio_health_checking/setup.py" preprocess
$VENV_PYTHON $ROOT/src/python/grpcio_health_checking/setup.py build_package_protos $VENV_PYTHON "$ROOT/src/python/grpcio_health_checking/setup.py" build_package_protos
pip_install_dir $ROOT/src/python/grpcio_health_checking pip_install_dir "$ROOT/src/python/grpcio_health_checking"
# Build/install reflection # Build/install reflection
$VENV_PYTHON $ROOT/src/python/grpcio_reflection/setup.py preprocess $VENV_PYTHON "$ROOT/src/python/grpcio_reflection/setup.py" preprocess
$VENV_PYTHON $ROOT/src/python/grpcio_reflection/setup.py build_package_protos $VENV_PYTHON "$ROOT/src/python/grpcio_reflection/setup.py" build_package_protos
pip_install_dir $ROOT/src/python/grpcio_reflection pip_install_dir "$ROOT/src/python/grpcio_reflection"
# Install testing # Install testing
pip_install_dir $ROOT/src/python/grpcio_testing pip_install_dir "$ROOT/src/python/grpcio_testing"
# Build/install tests # Build/install tests
$VENV_PYTHON -m pip install coverage==4.4 oauth2client==4.1.0 \ $VENV_PYTHON -m pip install coverage==4.4 oauth2client==4.1.0 \
google-auth==1.0.0 requests==2.14.2 google-auth==1.0.0 requests==2.14.2
$VENV_PYTHON $ROOT/src/python/grpcio_tests/setup.py preprocess $VENV_PYTHON "$ROOT/src/python/grpcio_tests/setup.py" preprocess
$VENV_PYTHON $ROOT/src/python/grpcio_tests/setup.py build_package_protos $VENV_PYTHON "$ROOT/src/python/grpcio_tests/setup.py" build_package_protos
pip_install_dir $ROOT/src/python/grpcio_tests pip_install_dir "$ROOT/src/python/grpcio_tests"

@ -15,7 +15,7 @@
set -ex set -ex
BUILD_PYTHON=`realpath "$(dirname $0)/build_python.sh"` BUILD_PYTHON=$(realpath "$(dirname "$0")/build_python.sh")
export MSYSTEM=$1 export MSYSTEM=$1
shift 1 shift 1
bash --login $BUILD_PYTHON "$@" bash --login "$BUILD_PYTHON" "$@"

@ -19,7 +19,7 @@ set -ex
export GRPC_CONFIG=${CONFIG:-opt} export GRPC_CONFIG=${CONFIG:-opt}
# change to grpc's ruby directory # change to grpc's ruby directory
cd $(dirname $0)/../../.. cd "$(dirname "$0")/../../.."
rm -rf ./tmp rm -rf ./tmp
rake compile rake compile

@ -17,9 +17,9 @@
set -ex set -ex
# change to grpc repo root # change to grpc repo root
cd $(dirname $0)/../../.. cd "$(dirname "$0")/../../.."
SYSTEM=`uname | cut -f 1 -d_` SYSTEM=$(uname | cut -f 1 -d_)
if [ "$SYSTEM" == "Darwin" ] ; then if [ "$SYSTEM" == "Darwin" ] ; then
# Workaround for crash during bundle install # Workaround for crash during bundle install

@ -17,14 +17,14 @@ set -ex
if [ "$CONFIG" != "gcov" ] ; then exit ; fi if [ "$CONFIG" != "gcov" ] ; then exit ; fi
root=$(readlink -f $(dirname $0)/../../..) root=$(readlink -f "$(dirname "$0")/../../..")
out=$root/reports/c_cxx_coverage out=$root/reports/c_cxx_coverage
tmp1=$(mktemp) tmp1=$(mktemp)
tmp2=$(mktemp) tmp2=$(mktemp)
cd $root cd "$root"
lcov --capture --directory . --output-file $tmp1 lcov --capture --directory . --output-file "$tmp1"
lcov --extract $tmp1 "$root/src/*" "$root/include/*" --output-file $tmp2 lcov --extract "$tmp1" "$root/src/*" "$root/include/*" --output-file "$tmp2"
genhtml $tmp2 --output-directory $out genhtml "$tmp2" --output-directory "$out"
rm $tmp2 rm "$tmp2"
rm $tmp1 rm "$tmp1"

@ -18,7 +18,7 @@ set -ex
if [ "$CONFIG" != "gcov" ] ; then exit ; fi if [ "$CONFIG" != "gcov" ] ; then exit ; fi
# change to gRPC repo root # change to gRPC repo root
cd $(dirname $0)/../../.. cd "$(dirname "$0")/../../.."
# Generate the csharp extension coverage report # Generate the csharp extension coverage report
gcov objs/gcov/src/csharp/ext/*.o gcov objs/gcov/src/csharp/ext/*.o

@ -17,15 +17,15 @@ set -ex
if [ "$CONFIG" != "gcov" ] ; then exit ; fi if [ "$CONFIG" != "gcov" ] ; then exit ; fi
root=$(readlink -f $(dirname $0)/../../..) root=$(readlink -f "$(dirname "$0")/../../..")
out=$root/reports/php_ext_coverage out=$root/reports/php_ext_coverage
tmp1=$(mktemp) tmp1=$(mktemp)
tmp2=$(mktemp) tmp2=$(mktemp)
cd $root cd "$root"
lcov --capture --directory . --output-file $tmp1 lcov --capture --directory . --output-file "$tmp1"
lcov --extract $tmp1 "$root/src/php/ext/grpc/*" --output-file $tmp2 lcov --extract "$tmp1" "$root/src/php/ext/grpc/*" --output-file "$tmp2"
genhtml $tmp2 --output-directory $out genhtml "$tmp2" --output-directory "$out"
rm $tmp2 rm "$tmp2"
rm $tmp1 rm "$tmp1"
# todo(mattkwong): generate coverage report for php and copy to reports/php # todo(mattkwong): generate coverage report for php and copy to reports/php

@ -18,7 +18,7 @@ set -ex
if [ "$CONFIG" != "gcov" ] ; then exit ; fi if [ "$CONFIG" != "gcov" ] ; then exit ; fi
# change to directory of Python coverage files # change to directory of Python coverage files
cd $(dirname $0)/../../../src/python/grpcio_tests/ cd "$(dirname "$0")/../../../src/python/grpcio_tests/"
coverage combine . coverage combine .
coverage html -i -d ./../../../reports/python coverage html -i -d ./../../../reports/python

@ -17,15 +17,15 @@ set -ex
if [ "$CONFIG" != "gcov" ] ; then exit ; fi if [ "$CONFIG" != "gcov" ] ; then exit ; fi
root=$(readlink -f $(dirname $0)/../../..) root=$(readlink -f "$(dirname "$0")/../../..")
out=$root/reports/ruby_ext_coverage out=$root/reports/ruby_ext_coverage
tmp1=$(mktemp) tmp1=$(mktemp)
tmp2=$(mktemp) tmp2=$(mktemp)
cd $root cd "$root"
lcov --capture --directory . --output-file $tmp1 lcov --capture --directory . --output-file "$tmp1"
lcov --extract $tmp1 "$root/src/ruby/*" --output-file $tmp2 lcov --extract "$tmp1" "$root/src/ruby/*" --output-file "$tmp2"
genhtml $tmp2 --output-directory $out genhtml "$tmp2" --output-directory "$out"
rm $tmp2 rm "$tmp2"
rm $tmp1 rm "$tmp1"
cp -rv $root/coverage $root/reports/ruby cp -rv "$root/coverage" "$root/reports/ruby"

@ -15,10 +15,10 @@
set -ex set -ex
cd $(dirname $0)/../../.. cd "$(dirname "$0")/../../.."
mkdir -p cmake/build mkdir -p cmake/build
cd cmake/build cd cmake/build
# MSBUILD_CONFIG's values are suitable for cmake as well # MSBUILD_CONFIG's values are suitable for cmake as well
cmake -DgRPC_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=${MSBUILD_CONFIG} ../.. cmake -DgRPC_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE="${MSBUILD_CONFIG}" ../..

@ -16,6 +16,6 @@
set -ex set -ex
# cd to gRPC csharp directory # cd to gRPC csharp directory
cd $(dirname $0)/../../../src/csharp cd "$(dirname "$0")/../../../src/csharp"
dotnet restore Grpc.sln dotnet restore Grpc.sln

@ -19,6 +19,6 @@ set -ex
export GRPC_CONFIG=${CONFIG:-opt} export GRPC_CONFIG=${CONFIG:-opt}
# change to grpc repo root # change to grpc repo root
cd $(dirname $0)/../../.. cd "$(dirname "$0")/../../.."
tools/run_tests/helper_scripts/bundle_install_wrapper.sh tools/run_tests/helper_scripts/bundle_install_wrapper.sh

@ -17,12 +17,12 @@
# to this reference # to this reference
# cd to gRPC root directory # cd to gRPC root directory
cd $(dirname $0)/../../.. cd "$(dirname "$0")/../../.."
CURRENT_COMMIT=$(git rev-parse --verify HEAD) CURRENT_COMMIT="$(git rev-parse --verify HEAD)"
rm -rf ./../grpc-node rm -rf ./../grpc-node
git clone --recursive https://github.com/grpc/grpc-node ./../grpc-node git clone --recursive https://github.com/grpc/grpc-node ./../grpc-node
cd ./../grpc-node cd ./../grpc-node
./test-grpc-submodule.sh $CURRENT_COMMIT ./test-grpc-submodule.sh "$CURRENT_COMMIT"

@ -15,17 +15,17 @@
set -ex set -ex
out=$(readlink -f ${1:-coverage}) out=$(readlink -f "${1:-coverage}")
root=$(readlink -f $(dirname $0)/../../..) root=$(readlink -f "$(dirname "$0")/../../..")
shift || true shift || true
tmp=$(mktemp) tmp=$(mktemp)
cd $root cd "$root"
tools/run_tests/run_tests.py -c gcov -l c c++ $@ || true tools/run_tests/run_tests.py -c gcov -l c c++ "$@" || true
lcov --capture --directory . --output-file $tmp lcov --capture --directory . --output-file "$tmp"
genhtml $tmp --output-directory $out genhtml "$tmp" --output-directory "$out"
rm $tmp rm "$tmp"
if which xdg-open > /dev/null if which xdg-open > /dev/null
then then
xdg-open file://$out/index.html xdg-open "file://$out/index.html"
fi fi

@ -16,15 +16,15 @@
set -ex set -ex
# change to grpc repo root # change to grpc repo root
cd $(dirname $0)/../../.. cd "$(dirname "$0")/../../.."
PYTHON=`realpath "${1:-py27/bin/python}"` PYTHON=$(realpath "${1:-py27/bin/python}")
ROOT=`pwd` ROOT=$(pwd)
$PYTHON $ROOT/src/python/grpcio_tests/setup.py test_lite $PYTHON "$ROOT/src/python/grpcio_tests/setup.py" test_lite
mkdir -p $ROOT/reports mkdir -p "$ROOT/reports"
rm -rf $ROOT/reports/python-coverage rm -rf "$ROOT/reports/python-coverage"
(mv -T $ROOT/htmlcov $ROOT/reports/python-coverage) || true (mv -T "$ROOT/htmlcov" "$ROOT/reports/python-coverage") || true

@ -16,6 +16,6 @@
set -ex set -ex
# change to grpc repo root # change to grpc repo root
cd $(dirname $0)/../../.. cd "$(dirname "$0")/../../.."
rake rake

@ -16,7 +16,7 @@
set -ex set -ex
# change to grpc repo root # change to grpc repo root
cd $(dirname $0)/../../.. cd "$(dirname "$0")/../../.."
EXIT_CODE=0 EXIT_CODE=0
ruby src/ruby/end2end/sig_handling_driver.rb || EXIT_CODE=1 ruby src/ruby/end2end/sig_handling_driver.rb || EXIT_CODE=1

@ -19,15 +19,15 @@
# newly created workspace) # newly created workspace)
set -ex set -ex
cd $(dirname $0)/../../.. cd "$(dirname "$0")/../../.."
export repo_root=$(pwd) export repo_root="$(pwd)"
rm -rf "${WORKSPACE_NAME}" rm -rf "${WORKSPACE_NAME}"
git clone . "${WORKSPACE_NAME}" git clone . "${WORKSPACE_NAME}"
# clone gRPC submodules, use data from locally cloned submodules where possible # clone gRPC submodules, use data from locally cloned submodules where possible
# shellcheck disable=SC2016,SC1004
git submodule foreach 'cd "${repo_root}/${WORKSPACE_NAME}" \ git submodule foreach 'cd "${repo_root}/${WORKSPACE_NAME}" \
&& git submodule update --init --reference ${repo_root}/${name} ${name}' && git submodule update --init --reference ${repo_root}/${name} ${name}'
echo "Running run_tests.py in workspace ${WORKSPACE_NAME}" echo "Running run_tests.py in workspace ${WORKSPACE_NAME}"
python "${WORKSPACE_NAME}/tools/run_tests/run_tests.py" $@ python "${WORKSPACE_NAME}/tools/run_tests/run_tests.py" "$@"

Loading…
Cancel
Save