Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
f62140d5
Commit
f62140d5
authored
8 years ago
by
Matt Kwong
Browse files
Options
Downloads
Patches
Plain Diff
improve pull request test filtering
parent
3020bb79
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tools/run_tests/filter_pull_request_tests.py
+59
-51
59 additions, 51 deletions
tools/run_tests/filter_pull_request_tests.py
with
59 additions
and
51 deletions
tools/run_tests/filter_pull_request_tests.py
+
59
−
51
View file @
f62140d5
...
...
@@ -57,44 +57,68 @@ class TestSuite:
self
.
triggers
.
append
(
trigger
)
# Create test suites
_
core_test_suite
=
TestSuite
([
'
_c_
'
])
_
cpp_test_suite
=
TestSuite
([
'
_c++_
'
])
_
csharp_test_suite
=
TestSuite
([
'
_csharp_
'
])
_
node_test_suite
=
TestSuite
([
'
_node_
'
])
_
objc_test_suite
=
TestSuite
([
'
_objc_
'
])
_
php_test_suite
=
TestSuite
([
'
_php_
'
,
'
_php7_
'
])
_
python_test_suite
=
TestSuite
([
'
_python_
'
])
_
ruby_test_suite
=
TestSuite
([
'
_ruby
'
])
_
all_test_suites
=
[
_core_test_suite
,
_cpp_test_suite
,
_csharp_test_suite
,
_
node_test_suite
,
_objc_test_suite
,
_php_test_suite
,
_
python_test_suite
,
_ruby_test_suite
]
_
CORE_TEST_SUITE
=
TestSuite
([
'
_c_
'
])
_
CPP_TEST_SUITE
=
TestSuite
([
'
_c++_
'
])
_
CSHARP_TEST_SUITE
=
TestSuite
([
'
_csharp_
'
])
_
NODE_TEST_SUITE
=
TestSuite
([
'
_node_
'
])
_
OBJC_TEST_SUITE
=
TestSuite
([
'
_objc_
'
])
_
PHP_TEST_SUITE
=
TestSuite
([
'
_php_
'
,
'
_php7_
'
])
_
PYTHON_TEST_SUITE
=
TestSuite
([
'
_python_
'
])
_
RUBY_TEST_SUITE
=
TestSuite
([
'
_ruby
'
])
_
ALL_TEST_SUITES
=
[
_CORE_TEST_SUITE
,
_CPP_TEST_SUITE
,
_CSHARP_TEST_SUITE
,
_
NODE_TEST_SUITE
,
_OBJC_TEST_SUITE
,
_PHP_TEST_SUITE
,
_
PYTHON_TEST_SUITE
,
_RUBY_TEST_SUITE
]
# Dictionary of whitelistable files where the key is a regex matching changed files
# and the value is a list of tests that should be run. An empty list means that
# the changed files should not trigger any tests. Any changed file that does not
# match any of these regexes will trigger all tests
_WHITELIST_DICT
=
{
'
^templates/.*
'
:
[],
'
^doc/.*
'
:
[],
'
^examples/.*
'
:
[],
'
^summerofcode/.*
'
:
[],
'
.*README.md$
'
:
[],
'
.*LICENSE$
'
:
[],
'
^src/cpp.*
'
:
[
_cpp_test_suite
],
'
^src/csharp.*
'
:
[
_csharp_test_suite
],
'
^src/node.*
'
:
[
_node_test_suite
],
'
^src/objective-c.*
'
:
[
_objc_test_suite
],
'
^src/php.*
'
:
[
_php_test_suite
],
'
^src/python.*
'
:
[
_python_test_suite
],
'
^src/ruby.*
'
:
[
_ruby_test_suite
],
'
^test/core.*
'
:
[
_core_test_suite
],
'
^test/cpp.*
'
:
[
_cpp_test_suite
],
'
^test/distrib/cpp.*
'
:
[
_cpp_test_suite
],
'
^test/distrib/csharp.*
'
:
[
_csharp_test_suite
],
'
^test/distrib/node.*
'
:
[
_node_test_suite
],
'
^test/distrib/php.*
'
:
[
_php_test_suite
],
'
^test/distrib/python.*
'
:
[
_python_test_suite
],
'
^test/distrib/ruby.*
'
:
[
_ruby_test_suite
]
#'^templates/.*': [_sanity_test_suite],
# todo(mattkwong): add sanity test suite
'
^doc/
'
:
[],
'
^examples/
'
:
[],
'
^summerofcode/
'
:
[],
'
README\.md$
'
:
[],
'
CONTRIBUTING\.md$
'
:
[],
'
LICENSE$
'
:
[],
'
INSTALL\.md$
'
:
[],
'
MANIFEST\.md$
'
:
[],
'
PATENTS$
'
:
[],
'
binding\.grp$
'
:
[
_NODE_TEST_SUITE
],
'
gRPC\-Core\.podspec$
'
:
[
_OBJC_TEST_SUITE
],
'
gRPC\-ProtoRPC\.podspec$
'
:
[
_OBJC_TEST_SUITE
],
'
gRPC\-RxLibrary\.podspec$
'
:
[
_OBJC_TEST_SUITE
],
'
gRPC\.podspec$
'
:
[
_OBJC_TEST_SUITE
],
'
composer\.json$
'
:
[
_PHP_TEST_SUITE
],
'
config\.m4$
'
:
[
_PHP_TEST_SUITE
],
'
package\.json$
'
:
[
_PHP_TEST_SUITE
],
'
package\.xml$
'
:
[
_PHP_TEST_SUITE
],
'
PYTHON\-MANIFEST\.in$
'
:
[
_PYTHON_TEST_SUITE
],
'
requirements\.txt$
'
:
[
_PYTHON_TEST_SUITE
],
'
setup\.cfg$
'
:
[
_PYTHON_TEST_SUITE
],
'
setup\.py$
'
:
[
_PYTHON_TEST_SUITE
],
'
grpc\.gemspec$
'
:
[
_RUBY_TEST_SUITE
],
'
Gemfile$
'
:
[
_RUBY_TEST_SUITE
],
# 'grpc.def$': [_WINDOWS_TEST_SUITE],
'
^src/cpp/
'
:
[
_CPP_TEST_SUITE
],
'
^src/csharp/
'
:
[
_CSHARP_TEST_SUITE
],
'
^src/node/
'
:
[
_NODE_TEST_SUITE
],
'
^src/objective\-c/
'
:
[
_OBJC_TEST_SUITE
],
'
^src/php/
'
:
[
_PHP_TEST_SUITE
],
'
^src/python/
'
:
[
_PYTHON_TEST_SUITE
],
'
^src/ruby/
'
:
[
_RUBY_TEST_SUITE
],
'
^test/core/
'
:
[
_CORE_TEST_SUITE
],
'
^test/cpp/
'
:
[
_CPP_TEST_SUITE
],
'
^test/distrib/cpp/
'
:
[
_CPP_TEST_SUITE
],
'
^test/distrib/csharp/
'
:
[
_CSHARP_TEST_SUITE
],
'
^test/distrib/node/
'
:
[
_NODE_TEST_SUITE
],
'
^test/distrib/php/
'
:
[
_PHP_TEST_SUITE
],
'
^test/distrib/python/
'
:
[
_PYTHON_TEST_SUITE
],
'
^test/distrib/ruby/
'
:
[
_RUBY_TEST_SUITE
],
'
^include/grpc\+\+/
'
:
[
_CPP_TEST_SUITE
]
#'^vsprojects/': [_WINDOWS_TEST_SUITE]
# todo(mattkwong): add windows test suite
}
# Add all triggers to their respective test suites
for
trigger
,
test_suites
in
_WHITELIST_DICT
.
iteritems
():
...
...
@@ -108,7 +132,7 @@ def _get_changed_files(base_branch):
"""
# git fetch might need to be called on Jenkins slave
# todo(mattkwong): remove or uncomment below after seeing if Jenkins needs this
#
call(['git', 'fetch'])
call
([
'
git
'
,
'
fetch
'
])
# Get file changes between branch and merge-base of specified branch
# Not combined to be Windows friendly
...
...
@@ -137,19 +161,7 @@ def _remove_irrelevant_tests(tests, tag):
:return: list of relevant tests
"""
# todo(mattkwong): find a more reliable way to filter tests - don't use shortname
return
[
test
for
test
in
tests
if
tag
not
in
test
.
shortname
or
any
(
san_tag
in
test
.
shortname
for
san_tag
in
[
'
_asan
'
,
'
_tsan
'
,
'
_msan
'
])]
def
_remove_sanitizer_tests
(
tests
):
"""
Filters out sanitizer tests
:param tests: list of all tests generated by run_tests_matrix.py
:return: list of relevant tests
"""
# todo(mattkwong): find a more reliable way to filter tests - don't use shortname
return
[
test
for
test
in
tests
if
all
(
san_tag
not
in
test
.
shortname
for
san_tag
in
[
'
_asan
'
,
'
_tsan
'
,
'
_msan
'
])]
return
[
test
for
test
in
tests
if
tag
not
in
test
.
shortname
]
def
filter_tests
(
tests
,
base_branch
):
...
...
@@ -171,14 +183,10 @@ def filter_tests(tests, base_branch):
if
not
re
.
match
(
all_triggers
,
changed_file
):
return
(
tests
)
# Filter out tests by language
for
test_suite
in
_
all_test_suites
:
for
test_suite
in
_
ALL_TEST_SUITES
:
if
_can_skip_tests
(
changed_files
,
test_suite
.
triggers
):
for
tag
in
test_suite
.
tags
:
print
(
"
Filtering %s tests
"
%
tag
)
tests
=
_remove_irrelevant_tests
(
tests
,
tag
)
# Sanitizer tests skipped if core and c++ are skipped
if
_can_skip_tests
(
changed_files
,
_cpp_test_suite
.
triggers
+
_core_test_suite
.
triggers
):
print
(
"
Filtering Sanitizer tests
"
)
tests
=
_remove_sanitizer_tests
(
tests
)
return
tests
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment