host-meta-test/features/environment.py

47 lines
1.1 KiB
Python
Raw Normal View History

2023-10-02 17:44:39 +05:30
# SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
#
# SPDX-License-Identifier: AGPL-3.0-or-later
from behave import *
from ftest_common.logger import upload_logs_to_ftest
def before_all(context):
context.success = []
context.failure = {}
def after_all(context):
max_score = 9
score = 0
score = len(context.success)
print("\n\n===============")
if score == max_score:
print("All tests passed")
elif score > 0:
print(f"Partial success. {score} out of {max_score} tests passed")
print("Summary:\n")
logs = ""
if context.success:
print(f"Successful tests:\n")
for s in context.success:
log = f"[OK] {s}\n"
print(log)
logs += log
2023-10-02 18:07:51 +05:30
success = True
2023-10-02 17:44:39 +05:30
if context.failure:
2023-10-02 18:07:51 +05:30
success = False
2023-10-02 17:44:39 +05:30
print(f"\n\nFailed tests:\n")
for _, (test, error) in enumerate(context.failure.items()):
log = f"[FAIL] {test} failed with error:\n{error}\n-----\n"
print(log)
logs += log
2023-10-02 18:07:51 +05:30
upload_logs_to_ftest(success, logs)