mirror of
https://github.com/google/nomulus.git
synced 2025-05-14 00:17:20 +02:00
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:
parent
7f0665783b
commit
badda1d407
1 changed files with 77 additions and 78 deletions
|
@ -20,88 +20,87 @@ files.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def GenTestRules(
|
||||||
def GenTestRules(name,
|
name,
|
||||||
test_files,
|
test_files,
|
||||||
deps,
|
deps,
|
||||||
exclude_tests=[],
|
exclude_tests = [],
|
||||||
default_test_size="small",
|
default_test_size = "small",
|
||||||
small_tests=[],
|
small_tests = [],
|
||||||
medium_tests=[],
|
medium_tests = [],
|
||||||
large_tests=[],
|
large_tests = [],
|
||||||
enormous_tests=[],
|
enormous_tests = [],
|
||||||
resources=[],
|
resources = [],
|
||||||
flaky_tests=[],
|
flaky_tests = [],
|
||||||
tags=[],
|
tags = [],
|
||||||
prefix="",
|
prefix = "",
|
||||||
jvm_flags=[],
|
jvm_flags = [],
|
||||||
args=[],
|
args = [],
|
||||||
visibility=None,
|
visibility = None,
|
||||||
shard_count=1):
|
shard_count = 1):
|
||||||
for test in _get_test_names(test_files):
|
for test in _get_test_names(test_files):
|
||||||
if test in exclude_tests:
|
if test in exclude_tests:
|
||||||
continue
|
continue
|
||||||
test_size = default_test_size
|
test_size = default_test_size
|
||||||
if test in small_tests:
|
if test in small_tests:
|
||||||
test_size = "small"
|
test_size = "small"
|
||||||
if test in medium_tests:
|
if test in medium_tests:
|
||||||
test_size = "medium"
|
test_size = "medium"
|
||||||
if test in large_tests:
|
if test in large_tests:
|
||||||
test_size = "large"
|
test_size = "large"
|
||||||
if test in enormous_tests:
|
if test in enormous_tests:
|
||||||
test_size = "enormous"
|
test_size = "enormous"
|
||||||
flaky = 0
|
flaky = 0
|
||||||
if (test in flaky_tests) or ("flaky" in tags):
|
if (test in flaky_tests) or ("flaky" in tags):
|
||||||
flaky = 1
|
flaky = 1
|
||||||
java_class = _package_from_path(
|
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,
|
package = java_class[:java_class.rfind(".")]
|
||||||
runtime_deps = deps,
|
native.java_test(
|
||||||
resources = resources,
|
name = prefix + test,
|
||||||
size = test_size,
|
runtime_deps = deps,
|
||||||
jvm_flags = jvm_flags,
|
resources = resources,
|
||||||
args = args,
|
size = test_size,
|
||||||
flaky = flaky,
|
jvm_flags = jvm_flags,
|
||||||
tags = tags,
|
args = args,
|
||||||
test_class = java_class,
|
flaky = flaky,
|
||||||
visibility = visibility,
|
tags = tags,
|
||||||
shard_count = shard_count)
|
test_class = java_class,
|
||||||
|
visibility = visibility,
|
||||||
|
shard_count = shard_count,
|
||||||
|
)
|
||||||
|
|
||||||
def _get_test_names(test_files):
|
def _get_test_names(test_files):
|
||||||
test_names = []
|
test_names = []
|
||||||
for test_file in test_files:
|
for test_file in test_files:
|
||||||
if not test_file.endswith("Test.java"):
|
if not test_file.endswith("Test.java"):
|
||||||
continue
|
continue
|
||||||
test_names += [test_file[:-5]]
|
test_names += [test_file[:-5]]
|
||||||
return test_names
|
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):
|
def _strip_right(str, suffix):
|
||||||
"""Returns str without the suffix if it ends with suffix."""
|
"""Returns str without the suffix if it ends with suffix."""
|
||||||
if str.endswith(suffix):
|
if str.endswith(suffix):
|
||||||
return str[0: len(str) - len(suffix)]
|
return str[0:len(str) - len(suffix)]
|
||||||
else:
|
else:
|
||||||
return str
|
return str
|
||||||
|
|
||||||
|
|
||||||
def _index_of_end(str, part):
|
def _index_of_end(str, part):
|
||||||
"""If part is in str, return the index of the first character after part.
|
"""If part is in str, return the index of the first character after part.
|
||||||
Return -1 if part is not in str."""
|
Return -1 if part is not in str."""
|
||||||
index = str.find(part)
|
index = str.find(part)
|
||||||
if index >= 0:
|
if index >= 0:
|
||||||
return index + len(part)
|
return index + len(part)
|
||||||
return -1
|
return -1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue