2018-12-07 13:24:43 -05:00
|
|
|
"""Functions for working with resmoke task names."""
|
|
|
|
|
|
|
|
|
|
import math
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def name_generated_task(parent_name, task_index, total_tasks, variant=None):
|
|
|
|
|
"""
|
|
|
|
|
Create a zero-padded sub-task name.
|
|
|
|
|
|
|
|
|
|
:param parent_name: Name of the parent task.
|
|
|
|
|
:param task_index: Index of this sub-task.
|
|
|
|
|
:param total_tasks: Total number of sub-tasks being generated.
|
2019-07-20 10:27:29 -04:00
|
|
|
:param variant: Build variant to run task in.
|
2018-12-07 13:24:43 -05:00
|
|
|
:return: Zero-padded name of sub-task.
|
|
|
|
|
"""
|
|
|
|
|
suffix = ""
|
|
|
|
|
if variant:
|
2019-07-20 10:27:29 -04:00
|
|
|
suffix = f"_{variant}"
|
2018-12-07 13:24:43 -05:00
|
|
|
|
|
|
|
|
index_width = int(math.ceil(math.log10(total_tasks)))
|
2019-07-20 10:27:29 -04:00
|
|
|
return f"{parent_name}_{str(task_index).zfill(index_width)}{suffix}"
|