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
This commit is contained in:
Sorin Sbarnea 2020-10-21 14:15:25 +01:00 committed by Ian Wienand
parent ac6119dd94
commit d27c7ff9db

View File

@ -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