in modules/testrail_integration.py [0:0]
def reportable(platform_to_test=None):
"""Return true if we should report to TestRail"""
import platform
if not os.environ.get("TESTRAIL_REPORT"):
logging.warning("TESTRAIL_REPORT not set, session not reportable.")
return False
# If we ask for reporting, we can force a report
if os.environ.get("REPORTABLE"):
logging.warning("REPORTABLE=true; we will report this session.")
return True
# Find the correct test plan
sys_platform = platform_to_test or platform.system()
if platform_to_test:
os.environ["FX_PLATFORM"] = platform_to_test
version = (
subprocess.check_output([sys.executable, "./collect_executables.py", "-n"])
.strip()
.decode()
)
logging.warning(f"Got version from collect_executable.py! {version}")
tr_session = testrail_init()
major_number, second_half = version.split(".")
if "-" in second_half:
minor_num, _ = second_half.split("-")
else:
minor_num = second_half
channel = os.environ.get("FX_CHANNEL") or "beta"
channel = channel.title()
if not channel:
if "b" in minor_num:
channel = "Beta"
else:
channel = "Release"
major_version = f"Firefox {major_number}"
major_milestone = tr_session.matching_milestone(TESTRAIL_FX_DESK_PRJ, major_version)
if not major_milestone:
logging.warning(
f"Not reporting: Could not find matching milestone: Firefox {major_version}"
)
return False
channel_milestone = tr_session.matching_submilestone(
major_milestone, f"{channel} {major_number}"
)
if not channel_milestone:
if channel == "Devedition":
channel_milestone = tr_session.matching_submilestone(
major_milestone, f"Beta {major_number}"
)
if not channel_milestone:
logging.warning(
f"Not reporting: Could not find matching submilestone for {channel} {major_number}"
)
return False
plan_title = get_plan_title(version, channel)
logging.warning(f"Plan title: {plan_title}")
this_plan = tr_session.matching_plan_in_milestone(
TESTRAIL_FX_DESK_PRJ, channel_milestone.get("id"), plan_title
)
if not this_plan:
logging.warning(
f"Session reportable: could not find {plan_title} (milestone: {channel_milestone.get('id')})"
)
return True
if platform_to_test:
sys_platform = platform_to_test
platform = "MacOS" if sys_platform == "Darwin" else sys_platform
plan_entries = this_plan.get("entries")
covered_suites = 0
for entry in plan_entries:
for run_ in entry.get("runs"):
if run_.get("config") and platform in run_.get("config"):
covered_suites += 1
num_suites = 0
for test_dir_name in os.listdir("tests"):
test_dir = os.path.join("tests", test_dir_name)
if os.path.isdir(test_dir) and not os.path.exists(
os.path.join(test_dir, "skip_reporting")
):
num_suites += 1
logging.warning(
f"Potentially matching run found for {platform}, may be reportable. ({covered_suites} out of {num_suites} suites already reported.)"
)
return covered_suites < num_suites