mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-28 05:46:06 +00:00
[unittest] Refactoring the gtest sharding option. (#69537)
This patch addresses the missed review comment from PR #67063. It renames LIT flag "--disable-gtest-sharding" to "--no-gtest-sharding" and corrects the code style issue.
This commit is contained in:
parent
bd21efe24c
commit
44d4b30ca3
@ -37,7 +37,7 @@ class LitConfig(object):
|
||||
maxIndividualTestTime=0,
|
||||
parallelism_groups={},
|
||||
per_test_coverage=False,
|
||||
disableGTestSharding=False,
|
||||
gtest_sharding=True,
|
||||
):
|
||||
# The name of the test runner.
|
||||
self.progname = progname
|
||||
@ -88,7 +88,7 @@ class LitConfig(object):
|
||||
self.maxIndividualTestTime = maxIndividualTestTime
|
||||
self.parallelism_groups = parallelism_groups
|
||||
self.per_test_coverage = per_test_coverage
|
||||
self.disableGTestSharding = bool(disableGTestSharding)
|
||||
self.gtest_sharding = bool(gtest_sharding)
|
||||
|
||||
@property
|
||||
def maxIndividualTestTime(self):
|
||||
|
@ -119,10 +119,16 @@ def parse_args():
|
||||
|
||||
execution_group = parser.add_argument_group("Test Execution")
|
||||
execution_group.add_argument(
|
||||
"--disable-gtest-sharding",
|
||||
dest="disableGTestSharding",
|
||||
help="Disable sharding for GoogleTest format",
|
||||
"--gtest-sharding",
|
||||
help="Enable sharding for GoogleTest format",
|
||||
action="store_true",
|
||||
default=True,
|
||||
)
|
||||
execution_group.add_argument(
|
||||
"--no-gtest-sharding",
|
||||
dest="gtest_sharding",
|
||||
help="Disable sharding for GoogleTest format",
|
||||
action="store_false",
|
||||
)
|
||||
execution_group.add_argument(
|
||||
"--path",
|
||||
|
@ -68,7 +68,7 @@ class GoogleTest(TestFormat):
|
||||
self.seen_executables.add(execpath)
|
||||
num_tests = self.get_num_tests(execpath, litConfig, localConfig)
|
||||
if num_tests is not None:
|
||||
if not litConfig.disableGTestSharding:
|
||||
if litConfig.gtest_sharding:
|
||||
# Compute the number of shards.
|
||||
shard_size = init_shard_size
|
||||
nshard = int(math.ceil(num_tests / shard_size))
|
||||
@ -151,7 +151,7 @@ class GoogleTest(TestFormat):
|
||||
"GTEST_OUTPUT": "json:" + test.gtest_json_file,
|
||||
"GTEST_SHUFFLE": "1" if use_shuffle else "0",
|
||||
}
|
||||
if not litConfig.disableGTestSharding:
|
||||
if litConfig.gtest_sharding:
|
||||
testPath, testName = os.path.split(test.getSourcePath())
|
||||
while not os.path.exists(testPath):
|
||||
# Handle GTest parameterized and typed tests, whose name includes
|
||||
|
@ -41,7 +41,7 @@ def main(builtin_params={}):
|
||||
params=params,
|
||||
config_prefix=opts.configPrefix,
|
||||
per_test_coverage=opts.per_test_coverage,
|
||||
disableGTestSharding=opts.disableGTestSharding,
|
||||
gtest_sharding=opts.gtest_sharding,
|
||||
)
|
||||
|
||||
discovered_tests = lit.discovery.find_tests_for_inputs(
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Check the various features of the GoogleTest format.
|
||||
|
||||
# RUN: not %{lit} -v --disable-gtest-sharding --order=random %{inputs}/googletest-no-sharding > %t.out
|
||||
# RUN: not %{lit} -v --no-gtest-sharding --order=random %{inputs}/googletest-no-sharding > %t.out
|
||||
# FIXME: Temporarily dump test output so we can debug failing tests on
|
||||
# buildbots.
|
||||
# RUN: cat %t.out
|
||||
|
Loading…
x
Reference in New Issue
Block a user