[Fuego] [PATCH 2/3] ftc: gen-report: Make format for name of test report file

Tim.Bird at sony.com Tim.Bird at sony.com
Tue Mar 20 21:29:49 UTC 2018


OK - applied.

Thanks.
 -- Tim


> -----Original Message-----
> From: fuego-bounces at lists.linuxfoundation.org [mailto:fuego-
> bounces at lists.linuxfoundation.org] On Behalf Of Hoang Van Tuyen
> Sent: Tuesday, March 13, 2018 3:16 AM
> To: fuego at lists.linuxfoundation.org
> Subject: [Fuego] [PATCH 2/3] ftc: gen-report: Make format for name of test
> report file
> 
> The format for name of test report file is
> Test_report_${value_of_where_option}_${time}.${format_of_test_report}
> 
> Signed-off-by: Hoang Van Tuyen <tuyen.hoangvan at toshiba-tsdv.com>
> <mailto:tuyen.hoangvan at toshiba-tsdv.com>
> ---
>  engine/scripts/ftc | 32 ++++++++++++++++++++++----------
>  1 file changed, 22 insertions(+), 10 deletions(-)
> 
> diff --git a/engine/scripts/ftc b/engine/scripts/ftc
> index 7fa0333..c1a2887 100755
> --- a/engine/scripts/ftc
> +++ b/engine/scripts/ftc
> @@ -2071,14 +2071,14 @@ def add_page_number(canvas, doc):
>      text = "Page %s" % page_num
>      canvas.drawRightString(200*mm, 20*mm, text)
> 
> -def gen_pdf_report(header_data, report_data, report_dir):
> +def gen_pdf_report(header_data, report_data, report_file):
>      from reportlab.lib import colors
>      from reportlab.lib.pagesizes import A4
>      from reportlab.lib.styles import getSampleStyleSheet
>      from reportlab.platypus import SimpleDocTemplate, Table, TableStyle,
> Paragraph
> 
>      # create a pdf file
> -    doc = SimpleDocTemplate(report_dir + "report.pdf", pagesize=A4)
> +    doc = SimpleDocTemplate(report_file, pagesize=A4)
>      elements = []
> 
>      # generate header
> @@ -2125,7 +2125,7 @@ def excel_column_name(n):
>          name = chr(r + ord('A')) + name
>      return name
> 
> -def gen_excel_report(header_data, report_data, report_dir):
> +def gen_excel_report(header_data, report_data, report_file):
>      from openpyxl import Workbook
>      from openpyxl.style import Fill, Color
> 
> @@ -2164,14 +2164,13 @@ def gen_excel_report(header_data,
> report_data, report_dir):
>          workbook.remove_sheet(workbook.get_sheet_by_name("Sheet"))
> 
>      # save the report
> -    workbook.save(report_dir + "report.xlsx")
> +    workbook.save(report_file)
> 
> -def gen_csv_report(header_data, report_data, report_dir):
> +def gen_csv_report(header_data, report_data, report_file):
>      import csv
> 
> -    filename = report_dir + "report.csv"
>      # generate header
> -    with open(filename, "wb") as report:
> +    with open(report_file, "wb") as report:
>          writer = csv.writer(report)
>          writer.writerows(header_data)
> 
> @@ -2238,6 +2237,19 @@ def do_gen_report(conf, options):
>          # make we cannot create a directory.
>          error_out("Invalid report directory '%s'" % report_dir)
> 
> +    # create name of test report file with format Test_report_testname_time
> +    test_file_name = "Test_report_" + time.strftime("%Y-%m-%d_%H-%M-
> %S")
> +    if "--where" in options:
> +        test_file_name = "Test_report_" + options[options.index("--
> where")+1] + \
> +                         "_" + time.strftime("%Y-%m-%d_%H-%M-%S")
> +
> +    # report_file includes the report_dir, test_file_name and fmt
> +    # always include "/" to make sure the test_file_name into report_dir
> +    if fmt == "excel":
> +        report_file = report_dir + "/" + test_file_name + "." + "xlsx"
> +    else:
> +        report_file = report_dir + "/" + test_file_name + "." + fmt
> +
>      # get data for report
>      header_data = get_report_header_data(run_list, run_map,
> header_fields)
>      report_data = get_report_data(run_list, run_map, fields)
> @@ -2247,13 +2259,13 @@ def do_gen_report(conf, options):
>      if fmt=="html":
>          report = gen_html_report(header_data, report_data)
>      if fmt=="pdf":
> -        gen_pdf_report(header_data, report_data, report_dir)
> +        gen_pdf_report(header_data, report_data, report_file)
>          sys.exit(0)
>      if fmt=="excel":
> -        gen_excel_report(header_data, report_data, report_dir)
> +        gen_excel_report(header_data, report_data, report_file)
>          sys.exit(0)
>      if fmt=="csv":
> -        gen_csv_report(header_data, report_data, report_dir)
> +        gen_csv_report(header_data, report_data, report_file)
>          sys.exit(0)
> 
>      print report
> --
> 2.1.4
> 
> 
> 
> _______________________________________________
> Fuego mailing list
> Fuego at lists.linuxfoundation.org <mailto:Fuego at lists.linuxfoundation.org>
> https://lists.linuxfoundation.org/mailman/listinfo/fuego


More information about the Fuego mailing list