Skip to content

Commit 8ce9edd

Browse files
committed
[unittest] Refactoring the gtest sharding option.
This patch addresses the missed review comment from PR llvm#67063. It renames LIT flag "--disable-gtest-sharding" to "--no-gtest-sharding" and corrects the code style issue.
1 parent 6c6749c commit 8ce9edd

File tree

5 files changed

+15
-9
lines changed

5 files changed

+15
-9
lines changed

llvm/utils/lit/lit/LitConfig.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def __init__(
3737
maxIndividualTestTime=0,
3838
parallelism_groups={},
3939
per_test_coverage=False,
40-
disableGTestSharding=False,
40+
gtest_sharding=True,
4141
):
4242
# The name of the test runner.
4343
self.progname = progname
@@ -88,7 +88,7 @@ def __init__(
8888
self.maxIndividualTestTime = maxIndividualTestTime
8989
self.parallelism_groups = parallelism_groups
9090
self.per_test_coverage = per_test_coverage
91-
self.disableGTestSharding = bool(disableGTestSharding)
91+
self.gtest_sharding = bool(gtest_sharding)
9292

9393
@property
9494
def maxIndividualTestTime(self):

llvm/utils/lit/lit/cl_arguments.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,16 @@ def parse_args():
119119

120120
execution_group = parser.add_argument_group("Test Execution")
121121
execution_group.add_argument(
122-
"--disable-gtest-sharding",
123-
dest="disableGTestSharding",
124-
help="Disable sharding for GoogleTest format",
122+
"--gtest-sharding",
123+
help="Enable sharding for GoogleTest format",
125124
action="store_true",
125+
default=True,
126+
)
127+
execution_group.add_argument(
128+
"--no-gtest-sharding",
129+
dest="gtest_sharding",
130+
help="Disable sharding for GoogleTest format",
131+
action="store_false",
126132
)
127133
execution_group.add_argument(
128134
"--path",

llvm/utils/lit/lit/formats/googletest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def getTestsInDirectory(self, testSuite, path_in_suite, litConfig, localConfig):
6868
self.seen_executables.add(execpath)
6969
num_tests = self.get_num_tests(execpath, litConfig, localConfig)
7070
if num_tests is not None:
71-
if not litConfig.disableGTestSharding:
71+
if litConfig.gtest_sharding:
7272
# Compute the number of shards.
7373
shard_size = init_shard_size
7474
nshard = int(math.ceil(num_tests / shard_size))
@@ -151,7 +151,7 @@ def execute(self, test, litConfig):
151151
"GTEST_OUTPUT": "json:" + test.gtest_json_file,
152152
"GTEST_SHUFFLE": "1" if use_shuffle else "0",
153153
}
154-
if not litConfig.disableGTestSharding:
154+
if litConfig.gtest_sharding:
155155
testPath, testName = os.path.split(test.getSourcePath())
156156
while not os.path.exists(testPath):
157157
# Handle GTest parameterized and typed tests, whose name includes

llvm/utils/lit/lit/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def main(builtin_params={}):
4141
params=params,
4242
config_prefix=opts.configPrefix,
4343
per_test_coverage=opts.per_test_coverage,
44-
disableGTestSharding=opts.disableGTestSharding,
44+
gtest_sharding=opts.gtest_sharding,
4545
)
4646

4747
discovered_tests = lit.discovery.find_tests_for_inputs(

llvm/utils/lit/tests/googletest-no-sharding.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Check the various features of the GoogleTest format.
22

3-
# RUN: not %{lit} -v --disable-gtest-sharding --order=random %{inputs}/googletest-no-sharding > %t.out
3+
# RUN: not %{lit} -v --no-gtest-sharding --order=random %{inputs}/googletest-no-sharding > %t.out
44
# FIXME: Temporarily dump test output so we can debug failing tests on
55
# buildbots.
66
# RUN: cat %t.out

0 commit comments

Comments
 (0)