d323c65240afc7a47c7c42fdcadb57d70fab1157,src/python/pants/backend/python/tasks/pytest_run.py,PytestRun,_maybe_shard,#PytestRun#,173
Before Change
yield []
return
components = shard_spec.split("/", 1)
if len(components) != 2:
raise self.InvalidShardSpecification("Invalid shard specification "{}", should be of form: "
"[shard index]/[total shards]".format(shard_spec))
def ensure_int(item):
try:
return int(item)
except ValueError:
raise self.InvalidShardSpecification("Invalid shard specification "{}", item {} is not an "
"int".format(shard_spec, item))
shard = ensure_int(components[0])
total = ensure_int(components[1])
if not (0 <= shard and shard < total):
raise self.InvalidShardSpecification("Invalid shard specification "{}", shard must "
"be >= 0 and < {}".format(shard_spec, total))
if total < 2:
yield []
return
After Change
yield []
return
try:
sharder = Sharder(shard_spec)
if sharder.nshards < 2:
yield []
return
with temporary_dir() as tmp:
path = os.path.join(tmp, "conftest.py")
with open(path, "w") as fp:
fp.write(dedent(
def pytest_report_header(config):
return "shard: {shard} of {nshards} (0-based shard numbering)"
def pytest_collection_modifyitems(session, config, items):
total_count = len(items)
removed = 0
for i, item in enumerate(list(items)):
if i % {nshards} != {shard}:
del items[i - removed]
removed += 1
reporter = config.pluginmanager.getplugin("terminalreporter")
reporter.write_line("Only executing {{}} of {{}} total tests in shard {shard} of "
"{nshards}".format(total_count - removed, total_count),
bold=True, invert=True, yellow=True)
.format(shard=sharder.shard, nshards=sharder.nshards)))
yield [path]
except Sharder.InvalidShardSpec as e:
raise self.InvalidShardSpecification(e)
@contextmanager
def _maybe_emit_junit_xml(self, targets):
args = []
xml_base = self.get_options().junit_xml_dir
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 8
Instances
Project Name: pantsbuild/pants
Commit Name: d323c65240afc7a47c7c42fdcadb57d70fab1157
Time: 2016-03-14
Author: benjyw@gmail.com
File Name: src/python/pants/backend/python/tasks/pytest_run.py
Class Name: PytestRun
Method Name: _maybe_shard
Project Name: pantsbuild/pants
Commit Name: c15e9b0930ea6ce6eef5be7c6c00b9ee2b706865
Time: 2020-02-21
Author: john.sirois@gmail.com
File Name: src/python/pants/backend/python/tasks/build_local_python_distributions.py
Class Name: BuildLocalPythonDistributions
Method Name: _create_dist
Project Name: pantsbuild/pants
Commit Name: 879df20df1df1b9cf16e29cb4a2836f4831f23d9
Time: 2019-12-08
Author: john.sirois@gmail.com
File Name: src/python/pants/backend/python/tasks/build_local_python_distributions.py
Class Name: BuildLocalPythonDistributions
Method Name: _create_dist