[Fuego] [PATCH 1/2] ftc: gen_report: should check run_list is not null, earlier

Tim.Bird at sony.com Tim.Bird at sony.com
Tue Feb 27 18:49:04 UTC 2018


Sorry this took so long to get to.

See comments inline below.

> -----Original Message-----
> From: Hoang Van Tuyen
> In the future, We will support several other report formats (like html,
> pdf, ...).
> We should check the run_list is null or not in do_gen_report function,
> not in the
> gen_text_report function.
> 
> Signed-off-by: Hoang Van Tuyen <tuyen.hoangvan at toshiba-tsdv.com>
> ---
>   engine/scripts/ftc | 8 +++-----
>   1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/engine/scripts/ftc b/engine/scripts/ftc
> index bde3694..44e4da7 100755
> --- a/engine/scripts/ftc
> +++ b/engine/scripts/ftc
> @@ -1857,11 +1857,6 @@ def gen_text_report(run_list, run_map,
> header_fields, fields):
>       report += "           **** %s ****\n" % title
>       report_date = time.strftime("%Y-%m-%d_%H:%M:%S")
> 
> -    if not run_list:
> -        report += "  *** No runs to report, based on requested/filtered
> runs ***\n"
> -        report += ddash_line
> -        return report
> -
>       for field in header_fields:
>           if field=="report_date":
>               val_str = time.strftime("%Y-%m-%d_%H:%M:%S")
> @@ -1969,6 +1964,9 @@ def do_gen_report(conf, options):
>       else:
>           run_list = run_map.keys()
> 
> +    if not run_list:
> +        error_out ('No runs to report, based on requested/filtered runs')
> +

This ends up changing the look of report in the "No runs" case.
Also, the call to error_out() ends up putting the message on
stderr instead of stdout, and causing ftc to return a non-zero
exit code. 
Both of those are bigger changes than I think I'd like.

At some point we'll add support for
specifying an output file, and viewing the report in the
Jenkins interface.  We might create jenkins jobs
that produce reports automatically after a run.

I'm not sure what is better in this case:
1) producing a report that has no data
2) returning  an error, and producing no report

Let's try it with the error_out() for now, but I reserve
the right to switch back to the other method, if it looks
like it will suit our intended usage of ftc gen-report
better in the future.

If we do that, we should have the wording be the same
for this "empty report" condition, between different 
output format types.  So the string should probably be
shared.  But we can make that so if we ever decide
to switch back.

>       run_list.sort()
> 
>       fmt="txt"
> --
> 2.1.4

This patch is accepted.
 -- Tim



More information about the Fuego mailing list