From 758ac050ffd91524d400c196865b1ed27ece8776 Mon Sep 17 00:00:00 2001 From: Alexis Lothoré Date: Mon, 27 Feb 2023 20:42:22 +0100 Subject: scripts/yoct_testresults_query: manage base/target revision not found MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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é Signed-off-by: Richard Purdie --- scripts/yocto_testresults_query.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) 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) -- cgit 1.2.3-korg