From d27c7ff9dbe05e2867c7317ded65865bde76840a Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Wed, 21 Oct 2020 14:15:25 +0100 Subject: [PATCH] Improve errors from update-test-platforms Instead of getting a confusing stacktrace when someone adds a new file that is missing the final project entry we now give a friendlier error that also recommends way to address the issue. Change-Id: I5a84d3a20e847eeb2d5d843ef970b5790532683c --- tools/update-test-platforms.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tools/update-test-platforms.py b/tools/update-test-platforms.py index 15fe913b1..cdb9207a7 100755 --- a/tools/update-test-platforms.py +++ b/tools/update-test-platforms.py @@ -20,6 +20,7 @@ # of the repo. import os +import sys from ruamel.yaml.comments import CommentedMap @@ -127,6 +128,18 @@ def handle_file(fn): outdata.append(obj) # We control the last project stanza outdata.extend(outprojects) + if not outprojects: + seed = """ +- project: + check: + jobs: [] + gate: + jobs: [] +""" + print( + f"FATAL: File {fn} last item is not a project definition. " + f"Try adding something like:\n{seed}") + sys.exit(1) project = outprojects[-1]['project'] project['check']['jobs'] = joblist_check # Use the same dictionary if there are no non-voting jobs