From 3bb0a8aded07c462d3ff8fc5f46f1ab7fd4bc4e9 Mon Sep 17 00:00:00 2001 From: Qinghao Shi Date: Sat, 18 May 2019 23:57:23 +0100 Subject: [PATCH] fix a bug when STDOUT has less than 5 lines --- tools/test/examples/examples_lib.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/test/examples/examples_lib.py b/tools/test/examples/examples_lib.py index e927a23579..cf0e0bb1fb 100644 --- a/tools/test/examples/examples_lib.py +++ b/tools/test/examples/examples_lib.py @@ -486,7 +486,8 @@ def update_mbedos_version(config, tag, examples): def fetch_output_image(output): """Find the build image from the last 5 lines of a given log""" lines = output.splitlines() - for index in range(-1,-6,-1): + last_index = -6 if len(lines)>4 else (-1 - len(lines)) + for index in range(-1,last_index,-1): if lines[index].startswith("Image:"): image = lines[index][7:] if os.path.isfile(image):