]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
scripts/yoct_testresults_query: manage base/target revision not found
authorAlexis Lothoré <alexis.lothore@bootlin.com>
Mon, 27 Feb 2023 19:42:22 +0000 (20:42 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 27 Feb 2023 22:54:25 +0000 (22:54 +0000)
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>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
scripts/yocto_testresults_query.py

index 3b478822dc0d5a1fb7abbce5ad94a3100a91b101..3df9d6015fe969065cc3094825682e966b6ab4d3 100755 (executable)
@@ -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)