diff mbox series

[1/2] scripts/yoct_testresults_query: manage base/target revision not found

Message ID 20230227194223.24304-2-alexis.lothore@bootlin.com
State Accepted, archived
Commit 758ac050ffd91524d400c196865b1ed27ece8776
Headers show
Series scripts: yocto_testresults_query fixes and resulttool missing tests | expand

Commit Message

Alexis Lothoré Feb. 27, 2023, 7:42 p.m. UTC
From: Alexis Lothoré <alexis.lothore@bootlin.com>

If yocto_testresults_query.py is run from oe-core instead of poky, the
script will very likely fail since poky tags do no exist in oe-core. If
one or both revisions are not found, log the error and a suggestion
about the reason (the script being run in oe-core instead of poky)

Signed-off-by: Alexis Lothoré <alexis.lothore@bootlin.com>
---
 scripts/yocto_testresults_query.py | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/scripts/yocto_testresults_query.py b/scripts/yocto_testresults_query.py
index 3b478822dc..3df9d6015f 100755
--- a/scripts/yocto_testresults_query.py
+++ b/scripts/yocto_testresults_query.py
@@ -30,9 +30,13 @@  def create_workdir():
     return workdir
 
 def get_sha1(pokydir, revision):
-    rev = subprocess.check_output(["git", "rev-list", "-n", "1", revision], cwd=pokydir).decode('utf-8').strip()
-    logger.info(f"SHA-1 revision for {revision} in {pokydir} is {rev}")
-    return rev
+    try:
+        rev = subprocess.check_output(["git", "rev-list", "-n", "1", revision], cwd=pokydir).decode('utf-8').strip()
+        logger.info(f"SHA-1 revision for {revision} in {pokydir} is {rev}")
+        return rev
+    except subprocess.CalledProcessError:
+        logger.error(f"Can not find SHA-1 for {revision} in {pokydir}")
+        return None
 
 def fetch_testresults(workdir, sha1):
     logger.info(f"Fetching test results for {sha1} in {workdir}")
@@ -65,6 +69,11 @@  def regression(args):
     try:
         baserevision = get_sha1(poky_path, args.base)
         targetrevision = get_sha1(poky_path, args.target)
+        if not baserevision or not targetrevision:
+            logger.error("One or more revision(s) missing. You might be targeting nonexistant tags/branches, or are in wrong repository (you must use Poky and not oe-core)")
+            if not args.testresultsdir:
+                subprocess.check_call(["rm", "-rf",  workdir])
+            sys.exit(1)
         fetch_testresults(workdir, baserevision)
         fetch_testresults(workdir, targetrevision)
         report = compute_regression_report(workdir, baserevision, targetrevision)