summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAl Semjonovs <asemjonovs@google.com>2022-11-15 14:40:39 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-11-16 15:45:21 +0000
commitd42bcfdb3b2da8041d4a648664be710c41412e53 (patch)
tree776a644fa7ad356b5abef8b5270a96702a7d9bb2
parent427adac454da3718fda4de7532c599504bdc3924 (diff)
downloadchrome-ec-d42bcfdb3b2da8041d4a648664be710c41412e53.tar.gz
zephyr: Add check for twister.json before using it
Check if twister.json exists before parsing for test results and skipped tests BUG=None BRANCH=NONE TEST=./twister -T zephyr/test/math ./twister -T zephyr/test/math_not_exist Signed-off-by: Al Semjonovs <asemjonovs@google.com> Change-Id: Ifc3983d4ceb085d76dd0a5c7ee1937508caaa2b7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4025838 Reviewed-by: Tristan Honscheid <honscheid@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
-rwxr-xr-xutil/twister_launcher.py71
1 files changed, 38 insertions, 33 deletions
diff --git a/util/twister_launcher.py b/util/twister_launcher.py
index 023ffbd2fa..c67d15d97d 100755
--- a/util/twister_launcher.py
+++ b/util/twister_launcher.py
@@ -176,28 +176,32 @@ def upload_results(ec_base, outdir):
if is_rdb_login():
json_path = pathlib.Path(outdir) / "twister.json"
- cmd = [
- "rdb",
- "stream",
- "-new",
- "-realm",
- "chromium:public",
- "--",
- str(ec_base / "util/zephyr_to_resultdb.py"),
- "--result=" + str(json_path),
- "--upload=True",
- ]
-
- start_time = time.time()
- ret = subprocess.run(cmd, capture_output=True, text=True, check=True)
- end_time = time.time()
-
- # Extract URL to test report from captured output
- rdb_url = re.search(
- r"(?P<url>https?://[^\s]+)", ret.stderr.split("\n")[0]
- ).group("url")
- print(f"\nTEST RESULTS ({end_time - start_time:.3f}s): {rdb_url}\n")
- flag = ret.returncode == 0
+
+ if json_path.exists():
+ cmd = [
+ "rdb",
+ "stream",
+ "-new",
+ "-realm",
+ "chromium:public",
+ "--",
+ str(ec_base / "util/zephyr_to_resultdb.py"),
+ "--result=" + str(json_path),
+ "--upload=True",
+ ]
+
+ start_time = time.time()
+ ret = subprocess.run(
+ cmd, capture_output=True, text=True, check=True
+ )
+ end_time = time.time()
+
+ # Extract URL to test report from captured output
+ rdb_url = re.search(
+ r"(?P<url>https?://[^\s]+)", ret.stderr.split("\n")[0]
+ ).group("url")
+ print(f"\nTEST RESULTS ({end_time - start_time:.3f}s): {rdb_url}\n")
+ flag = ret.returncode == 0
else:
print("Unable to upload test results, please run 'rdb auth-login'\n")
@@ -208,17 +212,18 @@ def check_for_skipped_tests(outdir):
"""Checks Twister json test report for skipped tests"""
found_skipped = False
json_path = pathlib.Path(outdir) / "twister.json"
- with open(json_path) as file:
- data = json.load(file)
-
- for testsuite in data["testsuites"]:
- for testcase in testsuite["testcases"]:
- if testcase["status"] == "skipped":
- tc_name = testcase["identifier"]
- print(f"TEST SKIPPED: {tc_name}")
- found_skipped = True
-
- file.close()
+ if json_path.exists():
+ with open(json_path) as file:
+ data = json.load(file)
+
+ for testsuite in data["testsuites"]:
+ for testcase in testsuite["testcases"]:
+ if testcase["status"] == "skipped":
+ tc_name = testcase["identifier"]
+ print(f"TEST SKIPPED: {tc_name}")
+ found_skipped = True
+
+ file.close()
return found_skipped