reformat bazel files to use Google coding standards
Change-Id: I320f0ca7ccb1b2247ccdd9fa58fefca7dad8a16f
diff --git a/tools/build/bazel/generate_test_rules.bzl b/tools/build/bazel/generate_test_rules.bzl
index c8c3976..03f5073 100644
--- a/tools/build/bazel/generate_test_rules.bzl
+++ b/tools/build/bazel/generate_test_rules.bzl
@@ -21,93 +21,93 @@
"""
def testIsExcluded(exclude_tests, test):
- for excluded_test in exclude_tests:
- normalized_excluded_test = excluded_test.replace('.', '/')
- if test.endswith(normalized_excluded_test):
- return True;
- return False
+ for excluded_test in exclude_tests:
+ normalized_excluded_test = excluded_test.replace(".", "/")
+ if test.endswith(normalized_excluded_test):
+ return True
+ return False
-def generate_test_rules(name,
- test_files,
- deps,
- exclude_tests=[],
- default_test_size="small",
- small_tests=[],
- medium_tests=[],
- large_tests=[],
- enormous_tests=[],
- resources=[],
- flaky_tests=[],
- tags=[],
- prefix="",
- jvm_flags=["-XX:MaxPermSize=128m"],
- args=[],
- visibility=None,
- shard_count=1):
- for test in _get_test_names(test_files):
- if testIsExcluded(exclude_tests, test):
- continue
- test_size = default_test_size
- if test in small_tests:
- test_size = "small"
- if test in medium_tests:
- test_size = "medium"
- if test in large_tests:
- test_size = "large"
- if test in enormous_tests:
- test_size = "enormous"
- flaky = 0
- if (test in flaky_tests) or ("flaky" in tags):
- flaky = 1
- java_class = _package_from_path(
- PACKAGE_NAME + "/" + _strip_right(test, ".java"))
- package = java_class[:java_class.rfind(".")]
- native.java_test(name = prefix + test,
- runtime_deps = deps,
- resources = resources,
- size = test_size,
- jvm_flags = jvm_flags,
- args = args,
- flaky = flaky,
- tags = tags,
- test_class = java_class,
- visibility = visibility,
- shard_count = shard_count)
-
+def generate_test_rules(
+ name,
+ test_files,
+ deps,
+ exclude_tests = [],
+ default_test_size = "small",
+ small_tests = [],
+ medium_tests = [],
+ large_tests = [],
+ enormous_tests = [],
+ resources = [],
+ flaky_tests = [],
+ tags = [],
+ prefix = "",
+ jvm_flags = ["-XX:MaxPermSize=128m"],
+ args = [],
+ visibility = None,
+ shard_count = 1):
+ for test in _get_test_names(test_files):
+ if testIsExcluded(exclude_tests, test):
+ continue
+ test_size = default_test_size
+ if test in small_tests:
+ test_size = "small"
+ if test in medium_tests:
+ test_size = "medium"
+ if test in large_tests:
+ test_size = "large"
+ if test in enormous_tests:
+ test_size = "enormous"
+ flaky = 0
+ if (test in flaky_tests) or ("flaky" in tags):
+ flaky = 1
+ java_class = _package_from_path(
+ PACKAGE_NAME + "/" + _strip_right(test, ".java"),
+ )
+ package = java_class[:java_class.rfind(".")]
+ native.java_test(
+ name = prefix + test,
+ runtime_deps = deps,
+ resources = resources,
+ size = test_size,
+ jvm_flags = jvm_flags,
+ args = args,
+ flaky = flaky,
+ tags = tags,
+ test_class = java_class,
+ visibility = visibility,
+ shard_count = shard_count,
+ )
def _get_test_names(test_files):
- test_names = []
- for test_file in test_files:
- if not test_file.endswith("Test.java"):
- continue
- test_names += [test_file[:-5]]
- return test_names
+ test_names = []
+ for test_file in test_files:
+ if not test_file.endswith("Test.java"):
+ continue
+ test_names += [test_file[:-5]]
+ return test_names
-
-def _package_from_path(package_path, src_impls=None):
- src_impls = src_impls or ['javatests/', 'java/']
- for src_impl in src_impls:
- if not src_impl.endswith('/'):
- src_impl += '/'
- index = _index_of_end(package_path, src_impl)
- if index >= 0:
- package_path = package_path[index:]
- break
- return package_path.replace('/', '.')
-
+def _package_from_path(package_path, src_impls = None):
+ src_impls = src_impls or ["javatests/", "java/"]
+ for src_impl in src_impls:
+ if not src_impl.endswith("/"):
+ src_impl += "/"
+ index = _index_of_end(package_path, src_impl)
+ if index >= 0:
+ package_path = package_path[index:]
+ break
+ return package_path.replace("/", ".")
def _strip_right(str, suffix):
- """Returns str without the suffix if it ends with suffix."""
- if str.endswith(suffix):
- return str[0: len(str) - len(suffix)]
- else:
- return str
-
+ """Returns str without the suffix if it ends with suffix."""
+ if str.endswith(suffix):
+ return str[0:len(str) - len(suffix)]
+ else:
+ return str
def _index_of_end(str, part):
- """If part is in str, return the index of the first character after part.
- Return -1 if part is not in str."""
- index = str.find(part)
- if index >= 0:
- return index + len(part)
- return -1
+ """If part is in str, return the index of the first character after part.
+ Return -1 if part is not in str."""
+ index = str.find(part)
+ if index >= 0:
+ return index + len(part)
+ return -1