Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 74cb963

Browse filesBrowse files
author
Takashi Matsuo
committed
add a script for running tests locally
1 parent 8a97151 commit 74cb963
Copy full SHA for 74cb963

File tree

Expand file treeCollapse file tree

1 file changed

+64
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+64
-0
lines changed

‎scripts/run_tests_local.sh

Copy file name to clipboard
+64Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2020 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
# run_tests_local.sh
17+
#
18+
# This script is a helper script for running tests with
19+
# .kokoro/trampoline_v2.sh.
20+
# run_tests_local.sh directory (sessions..)
21+
22+
set -euo pipefail
23+
24+
sessions=(
25+
"lint"
26+
"py-3.6"
27+
"py-3.7"
28+
)
29+
30+
# The only required argument is a directory for running the tests.
31+
if [[ $# -lt 1 ]]; then
32+
echo "Please provide at least one argument."
33+
echo "Usage: run_tests_local.sh directory (sessions..)"
34+
exit 1
35+
fi
36+
37+
function repo_root() {
38+
local dir="$1"
39+
while [[ ! -d "${dir}/.git" ]]; do
40+
dir="$(dirname "$dir")"
41+
done
42+
echo "${dir}"
43+
}
44+
45+
PROGRAM_PATH="$(realpath "$0")"
46+
PROGRAM_DIR="$(dirname "${PROGRAM_PATH}")"
47+
PROJECT_ROOT="$(repo_root "${PROGRAM_DIR}")"
48+
49+
directory="$(realpath "$1")"
50+
relative_dir=${directory#"${PROJECT_ROOT}/"}
51+
export RUN_TESTS_DIRS="${relative_dir}"
52+
53+
if [[ $# -ge 2 ]]; then
54+
sessions=("${@:2}")
55+
fi
56+
57+
echo "Running tests for directory: ${directory}"
58+
echo "Sessions: ${sessions[@]}"
59+
60+
for session in "${sessions[@]}"
61+
do
62+
export RUN_TESTS_SESSION="${session}"
63+
"${PROJECT_ROOT}/.kokoro/trampoline_v2.sh"
64+
done

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.