Format .bzl files with buildifier

This is a part of a large-scale change: [] . All .bzl files are being formatted with buildifier.

To format a file manually run `buildifier path/to/file.bzl`. Integration with `g4 fix` will be available later, but you can try using `g4 fix --format=bzl`.
Tested:
    tap_presubmit
    Some tests failed; test failures are believed to be unrelated to this CL

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=204137752
This commit is contained in:
jianglai 2018-07-11 09:31:48 -07:00
parent 7f0665783b
commit badda1d407

View file

@ -20,24 +20,24 @@ files.
"""
def GenTestRules(name,
def GenTestRules(
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=[],
args=[],
visibility=None,
shard_count=1):
exclude_tests = [],
default_test_size = "small",
small_tests = [],
medium_tests = [],
large_tests = [],
enormous_tests = [],
resources = [],
flaky_tests = [],
tags = [],
prefix = "",
jvm_flags = [],
args = [],
visibility = None,
shard_count = 1):
for test in _get_test_names(test_files):
if test in exclude_tests:
continue
@ -54,9 +54,11 @@ def GenTestRules(name,
if (test in flaky_tests) or ("flaky" in tags):
flaky = 1
java_class = _package_from_path(
native.package_name() + "/" + _strip_right(test, ".java"))
native.package_name() + "/" + _strip_right(test, ".java"),
)
package = java_class[:java_class.rfind(".")]
native.java_test(name = prefix + test,
native.java_test(
name = prefix + test,
runtime_deps = deps,
resources = resources,
size = test_size,
@ -66,8 +68,8 @@ def GenTestRules(name,
tags = tags,
test_class = java_class,
visibility = visibility,
shard_count = shard_count)
shard_count = shard_count,
)
def _get_test_names(test_files):
test_names = []
@ -77,27 +79,24 @@ def _get_test_names(test_files):
test_names += [test_file[:-5]]
return test_names
def _package_from_path(package_path, src_impls=None):
src_impls = src_impls or ['javatests/', 'java/']
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 += '/'
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('/', '.')
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)]
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."""