예제 #1
0
def main_page(
    results, filename, images, captions, title="Test reports", directory=None
):
    filename = os.path.join(directory, filename)
    with open(filename, "w") as page:
        page.write(
            "<html><body>"
            "<h1>{title}</h1>"
            "<table>"
            "<thead><tr>"
            "<th>Date (timestamp)</th><th>SVN revision</th><th>Name</th>"
            "<th>Successful files</th><th>Successful tests</th>"
            "</tr></thead>"
            "<tbody>".format(title=title)
        )
        for result in reversed(results):
            # TODO: include name to summary file
            # now using location or test report directory as name
            if result.location != "unknown":
                name = result.location
            else:
                name = os.path.basename(result.report)
                if not name:
                    # Python basename returns '' for 'abc/'
                    for d in reversed(os.path.split(result.report)):
                        if d:
                            name = d
                            break
            per_test = success_to_html_percent(
                total=result.total, successes=result.successes
            )
            per_file = success_to_html_percent(
                total=result.files_total, successes=result.files_successes
            )
            report_path = os.path.relpath(path=result.report, start=directory)
            page.write(
                "<tr>"
                "<td><a href={report_path}/index.html>{result.timestamp}</a></td>"
                "<td>{result.svn_revision}</td>"
                "<td><a href={report_path}/index.html>{name}</a></td>"
                "<td>{pfiles}</td><td>{ptests}</td>"
                "</tr>".format(
                    result=result,
                    name=name,
                    report_path=report_path,
                    pfiles=per_file,
                    ptests=per_test,
                )
            )
        page.write("</tbody></table>")
        for image, caption in itertools.izip(images, captions):
            page.write(
                "<h3>{caption}<h3>"
                '<img src="{image}" alt="{caption}" title="{caption}">'.format(
                    image=image, caption=caption
                )
            )
        page.write("</body></html>")
예제 #2
0
def main_page(results, filename, images, captions, title='Test reports',
              directory=None):
    filename = os.path.join(directory, filename)
    with open(filename, 'w') as page:
        page.write(
            '<html><body>'
            '<h1>{title}</h1>'
            '<table>'
            '<thead><tr>'
            '<th>Date (timestamp)</th><th>SVN revision</th><th>Name</th>'
            '<th>Successful files</th><th>Successful tests</th>'
            '</tr></thead>'
            '<tbody>'
            .format(title=title)
            )
        for result in reversed(results):
            # TODO: include name to summary file
            # now using location or test report directory as name
            if result.location != 'unknown':
                name = result.location
            else:
                name = os.path.basename(result.report)
                if not name:
                    # Python basename returns '' for 'abc/'
                    for d in reversed(os.path.split(result.report)):
                        if d:
                            name = d
                            break
            per_test = success_to_html_percent(
                total=result.total, successes=result.successes)
            per_file = success_to_html_percent(
                total=result.files_total, successes=result.files_successes)
            report_path = os.path.relpath(path=result.report, start=directory)
            page.write(
                '<tr>'
                '<td><a href={report_path}/index.html>{result.timestamp}</a></td>'
                '<td>{result.svn_revision}</td>'
                '<td><a href={report_path}/index.html>{name}</a></td>'
                '<td>{pfiles}</td><td>{ptests}</td>'
                '</tr>'
                .format(result=result, name=name, report_path=report_path,
                        pfiles=per_file, ptests=per_test))
        page.write('</tbody></table>')
        for image, caption in itertools.izip(images, captions):
            page.write(
                '<h3>{caption}<h3>'
                '<img src="{image}" alt="{caption}" title="{caption}">'
                .format(image=image, caption=caption))
        page.write('</body></html>')
예제 #3
0
def main():

    parser = argparse.ArgumentParser(
        description="Create overall report from several individual test reports"
    )
    parser.add_argument(
        "reports",
        metavar="report_directory",
        type=str,
        nargs="+",
        help="Directories with reports",
    )
    parser.add_argument(
        "--output",
        dest="output",
        action="store",
        default="testreports_summary",
        help="Output directory",
    )
    parser.add_argument(
        "--timestamps",
        dest="timestamps",
        action="store_true",
        help="Use file timestamp instead of date in test summary",
    )

    args = parser.parse_args()
    output = args.output
    reports = args.reports
    use_timestamps = args.timestamps

    ensure_dir(output)

    all_results = []
    results_in_locations = defaultdict(list)

    for report in reports:
        try:
            summary_file = os.path.join(report, "test_keyvalue_result.txt")
            if not os.path.exists(summary_file):
                sys.stderr.write("WARNING: Key-value summary not available in"
                                 " report <%s>, skipping.\n" % summary_file)
                # skipping incomplete reports
                # use only results list for further processing
                continue
            summary = text_to_keyvalue(open(summary_file).read(), sep="=")
            if use_timestamps:
                test_timestamp = datetime.datetime.fromtimestamp(
                    os.path.getmtime(summary_file))
            else:
                test_timestamp = datetime.datetime.strptime(
                    summary["timestamp"], "%Y-%m-%d %H:%M:%S")

            result = TestResultSummary()
            result.timestamp = test_timestamp
            result.total = summary["total"]
            result.successes = summary["successes"]
            result.failures = summary["failures"]
            result.errors = summary["errors"]

            result.files_total = summary["files_total"]
            result.files_successes = summary["files_successes"]
            result.files_failures = summary["files_failures"]

            result.svn_revision = str(summary["svn_revision"])
            result.tested_modules = summary["tested_modules"]
            result.names = summary["names"]
            result.test_files_authors = summary["test_files_authors"]
            result.tested_dirs = summary["tested_dirs"]
            result.report = report

            # let's consider no location as valid state and use 'unknown'
            result.location = summary.get("location", "unknown")
            result.location_type = summary.get("location_type", "unknown")
            # grouping according to location types
            # this can cause that two actual locations tested at the same time
            # will end up together, this is not ideal but testing with
            # one location type and different actual locations is not standard
            # and although it will not break anything it will not give a nice
            # report
            results_in_locations[result.location_type].append(result)

            all_results.append(result)
            del result
        except KeyError as e:
            print("File %s does not have right values (%s)" %
                  (report, e.message))

    locations_main_page = open(os.path.join(output, "index.html"), "w")
    locations_main_page.write(
        "<html><body>"
        "<h1>Test reports grouped by location type</h1>"
        "<table>"
        "<thead><tr>"
        "<th>Location</th>"
        "<th>Successful files</th><th>Successful tests</th>"
        "</tr></thead>"
        "<tbody>")

    PlotStyle = namedtuple(
        "PlotStyle",
        [
            "linestyle", "linewidth", "success_color", "fail_color",
            "total_color"
        ],
    )
    plot_style = PlotStyle(linestyle="-",
                           linewidth=4.0,
                           success_color="g",
                           fail_color="r",
                           total_color="b")

    for location_type, results in results_in_locations.items():
        results = sorted(results, key=operator.attrgetter("timestamp"))
        # TODO: document: location type must be a valid dir name
        directory = os.path.join(output, location_type)
        ensure_dir(directory)

        if location_type == "unknown":
            title = "Test reports"
        else:
            title = "Test reports for &lt;{type}&gt; location type".format(
                type=location_type)

        x = [date2num(result.timestamp) for result in results]
        # the following would be an alternative but it does not work with
        # labels and automatic axis limits even after removing another date fun
        # x = [result.svn_revision for result in results]
        xlabels = [
            result.timestamp.strftime("%Y-%m-%d") + " (r" +
            result.svn_revision + ")" for result in results
        ]
        step = len(x) / 10
        xticks = x[step::step]
        xlabels = xlabels[step::step]
        tests_successful_plot(
            x=x,
            xticks=xticks,
            xlabels=xlabels,
            results=results,
            filename=os.path.join(directory, "tests_successful_plot.png"),
            style=plot_style,
        )
        files_successful_plot(
            x=x,
            xticks=xticks,
            xlabels=xlabels,
            results=results,
            filename=os.path.join(directory, "files_successful_plot.png"),
            style=plot_style,
        )
        tests_plot(
            x=x,
            xticks=xticks,
            xlabels=xlabels,
            results=results,
            filename=os.path.join(directory, "tests_plot.png"),
            style=plot_style,
        )
        tests_percent_plot(
            x=x,
            xticks=xticks,
            xlabels=xlabels,
            results=results,
            filename=os.path.join(directory, "tests_percent_plot.png"),
            style=plot_style,
        )
        files_plot(
            x=x,
            xticks=xticks,
            xlabels=xlabels,
            results=results,
            filename=os.path.join(directory, "files_plot.png"),
            style=plot_style,
        )
        files_percent_plot(
            x=x,
            xticks=xticks,
            xlabels=xlabels,
            results=results,
            filename=os.path.join(directory, "files_percent_plot.png"),
            style=plot_style,
        )
        info_plot(
            x=x,
            xticks=xticks,
            xlabels=xlabels,
            results=results,
            filename=os.path.join(directory, "info_plot.png"),
            style=plot_style,
        )

        main_page(
            results=results,
            filename="index.html",
            images=[
                "tests_successful_plot.png",
                "files_successful_plot.png",
                "tests_plot.png",
                "files_plot.png",
                "tests_percent_plot.png",
                "files_percent_plot.png",
                "info_plot.png",
            ],
            captions=[
                "Success of individual tests in percents",
                "Success of test files in percents",
                "Successes, failures and number of individual tests",
                "Successes, failures and number of test files",
                "Successes and failures of individual tests in percent",
                "Successes and failures of test files in percents",
                "Additional information",
            ],
            directory=directory,
            title=title,
        )

        files_successes = sum(result.files_successes for result in results)
        files_total = sum(result.files_total for result in results)
        successes = sum(result.successes for result in results)
        total = sum(result.total for result in results)
        per_test = success_to_html_percent(total=total, successes=successes)
        per_file = success_to_html_percent(total=files_total,
                                           successes=files_successes)
        locations_main_page.write(
            "<tr>"
            "<td><a href={location}/index.html>{location}</a></td>"
            "<td>{pfiles}</td><td>{ptests}</td>"
            "</tr>".format(location=location_type,
                           pfiles=per_file,
                           ptests=per_test))
    locations_main_page.write("</tbody></table>")
    locations_main_page.write("</body></html>")
    locations_main_page.close()
    return 0
예제 #4
0
def main():

    parser = argparse.ArgumentParser(
        description='Create overall report from several individual test reports'
    )
    parser.add_argument('reports',
                        metavar='report_directory',
                        type=str,
                        nargs='+',
                        help='Directories with reports')
    parser.add_argument('--output',
                        dest='output',
                        action='store',
                        default='testreports_summary',
                        help='Output directory')
    parser.add_argument(
        '--timestamps',
        dest='timestamps',
        action='store_true',
        help='Use file timestamp instead of date in test summary')

    args = parser.parse_args()
    output = args.output
    reports = args.reports
    use_timestamps = args.timestamps

    ensure_dir(output)

    all_results = []
    results_in_locations = defaultdict(list)

    for report in reports:
        try:
            summary_file = os.path.join(report, 'test_keyvalue_result.txt')
            if not os.path.exists(summary_file):
                sys.stderr.write('WARNING: Key-value summary not available in'
                                 ' report <%s>, skipping.\n' % summary_file)
                # skipping incomplete reports
                # use only results list for further processing
                continue
            summary = text_to_keyvalue(open(summary_file).read(), sep='=')
            if use_timestamps:
                test_timestamp = datetime.datetime.fromtimestamp(
                    os.path.getmtime(summary_file))
            else:
                test_timestamp = datetime.datetime.strptime(
                    summary['timestamp'], "%Y-%m-%d %H:%M:%S")

            result = TestResultSummary()
            result.timestamp = test_timestamp
            result.total = summary['total']
            result.successes = summary['successes']
            result.failures = summary['failures']
            result.errors = summary['errors']

            result.files_total = summary['files_total']
            result.files_successes = summary['files_successes']
            result.files_failures = summary['files_failures']

            result.svn_revision = str(summary['svn_revision'])
            result.tested_modules = summary['tested_modules']
            result.names = summary['names']
            result.test_files_authors = summary['test_files_authors']
            result.tested_dirs = summary['tested_dirs']
            result.report = report

            # let's consider no location as valid state and use 'unknown'
            result.location = summary.get('location', 'unknown')
            result.location_type = summary.get('location_type', 'unknown')
            # grouping according to location types
            # this can cause that two actual locations tested at the same time
            # will end up together, this is not ideal but testing with
            # one location type and different actual locations is not standard
            # and although it will not break anything it will not give a nice
            # report
            results_in_locations[result.location_type].append(result)

            all_results.append(result)
            del result
        except KeyError as e:
            print('File %s does not have right values (%s)' %
                  (report, e.message))

    locations_main_page = open(os.path.join(output, 'index.html'), 'w')
    locations_main_page.write(
        '<html><body>'
        '<h1>Test reports grouped by location type</h1>'
        '<table>'
        '<thead><tr>'
        '<th>Location</th>'
        '<th>Successful files</th><th>Successful tests</th>'
        '</tr></thead>'
        '<tbody>')

    PlotStyle = namedtuple('PlotStyle', [
        'linestyle', 'linewidth', 'success_color', 'fail_color', 'total_color'
    ])
    plot_style = PlotStyle(linestyle='-',
                           linewidth=4.0,
                           success_color='g',
                           fail_color='r',
                           total_color='b')

    for location_type, results in results_in_locations.items():
        results = sorted(results, key=operator.attrgetter('timestamp'))
        # TODO: document: location type must be a valid dir name
        directory = os.path.join(output, location_type)
        ensure_dir(directory)

        if location_type == 'unknown':
            title = 'Test reports'
        else:
            title = ('Test reports for &lt;{type}&gt; location type'.format(
                type=location_type))

        x = [date2num(result.timestamp) for result in results]
        # the following would be an alternative but it does not work with
        # labels and automatic axis limits even after removing another date fun
        # x = [result.svn_revision for result in results]
        xlabels = [
            result.timestamp.strftime("%Y-%m-%d") + ' (r' +
            result.svn_revision + ')' for result in results
        ]
        step = len(x) / 10
        xticks = x[step::step]
        xlabels = xlabels[step::step]
        tests_successful_plot(x=x,
                              xticks=xticks,
                              xlabels=xlabels,
                              results=results,
                              filename=os.path.join(
                                  directory, 'tests_successful_plot.png'),
                              style=plot_style)
        files_successful_plot(x=x,
                              xticks=xticks,
                              xlabels=xlabels,
                              results=results,
                              filename=os.path.join(
                                  directory, 'files_successful_plot.png'),
                              style=plot_style)
        tests_plot(x=x,
                   xticks=xticks,
                   xlabels=xlabels,
                   results=results,
                   filename=os.path.join(directory, 'tests_plot.png'),
                   style=plot_style)
        tests_percent_plot(x=x,
                           xticks=xticks,
                           xlabels=xlabels,
                           results=results,
                           filename=os.path.join(directory,
                                                 'tests_percent_plot.png'),
                           style=plot_style)
        files_plot(x=x,
                   xticks=xticks,
                   xlabels=xlabels,
                   results=results,
                   filename=os.path.join(directory, 'files_plot.png'),
                   style=plot_style)
        files_percent_plot(x=x,
                           xticks=xticks,
                           xlabels=xlabels,
                           results=results,
                           filename=os.path.join(directory,
                                                 'files_percent_plot.png'),
                           style=plot_style)
        info_plot(x=x,
                  xticks=xticks,
                  xlabels=xlabels,
                  results=results,
                  filename=os.path.join(directory, 'info_plot.png'),
                  style=plot_style)

        main_page(results=results,
                  filename='index.html',
                  images=[
                      'tests_successful_plot.png', 'files_successful_plot.png',
                      'tests_plot.png', 'files_plot.png',
                      'tests_percent_plot.png', 'files_percent_plot.png',
                      'info_plot.png'
                  ],
                  captions=[
                      'Success of individual tests in percents',
                      'Success of test files in percents',
                      'Successes, failures and number of individual tests',
                      'Successes, failures and number of test files',
                      'Successes and failures of individual tests in percent',
                      'Successes and failures of test files in percents',
                      'Additional information'
                  ],
                  directory=directory,
                  title=title)

        files_successes = sum(result.files_successes for result in results)
        files_total = sum(result.files_total for result in results)
        successes = sum(result.successes for result in results)
        total = sum(result.total for result in results)
        per_test = success_to_html_percent(total=total, successes=successes)
        per_file = success_to_html_percent(total=files_total,
                                           successes=files_successes)
        locations_main_page.write(
            '<tr>'
            '<td><a href={location}/index.html>{location}</a></td>'
            '<td>{pfiles}</td><td>{ptests}</td>'
            '</tr>'.format(location=location_type,
                           pfiles=per_file,
                           ptests=per_test))
    locations_main_page.write('</tbody></table>')
    locations_main_page.write('</body></html>')
    locations_main_page.close()
    return 0
예제 #5
0
def main():

    parser = argparse.ArgumentParser(
        description='Create overall report from several individual test reports')
    parser.add_argument('reports', metavar='report_directory',
                        type=str, nargs='+',
                        help='Directories with reports')
    parser.add_argument('--output', dest='output', action='store',
                        default='testreports_summary',
                        help='Output directory')
    parser.add_argument('--timestamps', dest='timestamps', action='store_true',
                        help='Use file timestamp instead of date in test summary')

    args = parser.parse_args()
    output = args.output
    reports = args.reports
    use_timestamps = args.timestamps

    ensure_dir(output)

    all_results = []
    results_in_locations = defaultdict(list)

    for report in reports:
        try:
            summary_file = os.path.join(report, 'test_keyvalue_result.txt')
            if not os.path.exists(summary_file):
                sys.stderr.write('WARNING: Key-value summary not available in'
                                 ' report <%s>, skipping.\n' % summary_file)
                # skipping incomplete reports
                # use only results list for further processing
                continue
            summary = text_to_keyvalue(open(summary_file).read(), sep='=')
            if use_timestamps:
                test_timestamp = datetime.datetime.fromtimestamp(os.path.getmtime(summary_file))
            else:
                test_timestamp = datetime.datetime.strptime(summary['timestamp'], "%Y-%m-%d %H:%M:%S")

            result = TestResultSummary()
            result.timestamp = test_timestamp
            result.total = summary['total']
            result.successes = summary['successes']
            result.failures = summary['failures']
            result.errors = summary['errors']

            result.files_total = summary['files_total']
            result.files_successes = summary['files_successes']
            result.files_failures = summary['files_failures']

            result.svn_revision = str(summary['svn_revision'])
            result.tested_modules = summary['tested_modules']
            result.names = summary['names']
            result.test_files_authors = summary['test_files_authors']
            result.tested_dirs = summary['tested_dirs']
            result.report = report

            # let's consider no location as valid state and use 'unknown'
            result.location = summary.get('location', 'unknown')
            result.location_type = summary.get('location_type', 'unknown')
            # grouping according to location types
            # this can cause that two actual locations tested at the same time
            # will end up together, this is not ideal but testing with
            # one location type and different actual locations is not standard
            # and although it will not break anything it will not give a nice
            # report
            results_in_locations[result.location_type].append(result)

            all_results.append(result)
            del result
        except KeyError as e:
            print 'File %s does not have right values (%s)' % (report, e.message) 

    locations_main_page = open(os.path.join(output, 'index.html'), 'w')
    locations_main_page.write(
        '<html><body>'
        '<h1>Test reports grouped by location type</h1>'
        '<table>'
        '<thead><tr>'
        '<th>Location</th>'
        '<th>Successful files</th><th>Successful tests</th>'
        '</tr></thead>'
        '<tbody>'
        )

    PlotStyle = namedtuple('PlotStyle',
                           ['linestyle', 'linewidth',
                           'success_color', 'fail_color', 'total_color'])
    plot_style = PlotStyle(linestyle='-', linewidth=4.0,
                           success_color='g', fail_color='r', total_color='b')

    for location_type, results in results_in_locations.iteritems():
        results = sorted(results, key=operator.attrgetter('timestamp'))
        # TODO: document: location type must be a valid dir name
        directory = os.path.join(output, location_type)
        ensure_dir(directory)

        if location_type == 'unknown':
            title = 'Test reports'
        else:
            title = ('Test reports for &lt;{type}&gt; location type'
                     .format(type=location_type))
        
        x = [date2num(result.timestamp) for result in results]
        # the following would be an alternative but it does not work with
        # labels and automatic axis limits even after removing another date fun
        # x = [result.svn_revision for result in results]
        xlabels = [result.timestamp.strftime("%Y-%m-%d") + ' (r' + result.svn_revision + ')' for result in results]
        step = len(x) / 10
        xticks = x[step::step]
        xlabels = xlabels[step::step]
        tests_successful_plot(x=x, xticks=xticks, xlabels=xlabels, results=results,
                              filename=os.path.join(directory, 'tests_successful_plot.png'),
                              style=plot_style)
        files_successful_plot(x=x, xticks=xticks, xlabels=xlabels, results=results,
                              filename=os.path.join(directory, 'files_successful_plot.png'),
                              style=plot_style)
        tests_plot(x=x, xticks=xticks, xlabels=xlabels, results=results,
                   filename=os.path.join(directory, 'tests_plot.png'),
                   style=plot_style)
        tests_percent_plot(x=x, xticks=xticks, xlabels=xlabels, results=results,
                           filename=os.path.join(directory, 'tests_percent_plot.png'),
                           style=plot_style)
        files_plot(x=x, xticks=xticks, xlabels=xlabels, results=results,
                   filename=os.path.join(directory, 'files_plot.png'),
                   style=plot_style)
        files_percent_plot(x=x, xticks=xticks, xlabels=xlabels, results=results,
                           filename=os.path.join(directory, 'files_percent_plot.png'),
                           style=plot_style)
        info_plot(x=x, xticks=xticks, xlabels=xlabels, results=results,
                  filename=os.path.join(directory, 'info_plot.png'),
                   style=plot_style)

        main_page(results=results, filename='index.html',
                  images=['tests_successful_plot.png',
                          'files_successful_plot.png',
                          'tests_plot.png',
                          'files_plot.png',
                          'tests_percent_plot.png',
                          'files_percent_plot.png',
                          'info_plot.png'],
                  captions=['Success of individual tests in percents',
                            'Success of test files in percents',
                            'Successes, failures and number of individual tests',
                            'Successes, failures and number of test files',
                            'Successes and failures of individual tests in percent',
                            'Successes and failures of test files in percents',
                            'Additional information'],
                  directory=directory,
                  title=title)

        files_successes = sum(result.files_successes for result in results)
        files_total = sum(result.files_total for result in results)
        successes = sum(result.successes for result in results)
        total = sum(result.total for result in results)
        per_test = success_to_html_percent(
            total=total, successes=successes)
        per_file = success_to_html_percent(
            total=files_total, successes=files_successes)
        locations_main_page.write(
            '<tr>'
            '<td><a href={location}/index.html>{location}</a></td>'
            '<td>{pfiles}</td><td>{ptests}</td>'
            '</tr>'
            .format(location=location_type,
                    pfiles=per_file, ptests=per_test))
    locations_main_page.write('</tbody></table>')
    locations_main_page.write('</body></html>')
    locations_main_page.close()
    return 0
예제 #6
0
def main():

    parser = argparse.ArgumentParser(description="Create overall report from several individual test reports")
    parser.add_argument("reports", metavar="report_directory", type=str, nargs="+", help="Directories with reports")
    parser.add_argument(
        "--output", dest="output", action="store", default="testreports_summary", help="Output directory"
    )
    parser.add_argument(
        "--timestamps",
        dest="timestamps",
        action="store_true",
        help="Use file timestamp instead of date in test summary",
    )

    args = parser.parse_args()
    output = args.output
    reports = args.reports
    use_timestamps = args.timestamps

    ensure_dir(output)

    all_results = []
    results_in_locations = defaultdict(list)

    for report in reports:
        try:
            summary_file = os.path.join(report, "test_keyvalue_result.txt")
            if not os.path.exists(summary_file):
                sys.stderr.write(
                    "WARNING: Key-value summary not available in" " report <%s>, skipping.\n" % summary_file
                )
                # skipping incomplete reports
                # use only results list for further processing
                continue
            summary = text_to_keyvalue(open(summary_file).read(), sep="=")
            if use_timestamps:
                test_timestamp = datetime.datetime.fromtimestamp(os.path.getmtime(summary_file))
            else:
                test_timestamp = datetime.datetime.strptime(summary["timestamp"], "%Y-%m-%d %H:%M:%S")

            result = TestResultSummary()
            result.timestamp = test_timestamp
            result.total = summary["total"]
            result.successes = summary["successes"]
            result.failures = summary["failures"]
            result.errors = summary["errors"]

            result.files_total = summary["files_total"]
            result.files_successes = summary["files_successes"]
            result.files_failures = summary["files_failures"]

            result.svn_revision = str(summary["svn_revision"])
            result.tested_modules = summary["tested_modules"]
            result.names = summary["names"]
            result.test_files_authors = summary["test_files_authors"]
            result.tested_dirs = summary["tested_dirs"]
            result.report = report

            # let's consider no location as valid state and use 'unknown'
            result.location = summary.get("location", "unknown")
            result.location_type = summary.get("location_type", "unknown")
            # grouping according to location types
            # this can cause that two actual locations tested at the same time
            # will end up together, this is not ideal but testing with
            # one location type and different actual locations is not standard
            # and although it will not break anything it will not give a nice
            # report
            results_in_locations[result.location_type].append(result)

            all_results.append(result)
            del result
        except KeyError as e:
            print("File %s does not have right values (%s)" % (report, e.message))

    locations_main_page = open(os.path.join(output, "index.html"), "w")
    locations_main_page.write(
        "<html><body>"
        "<h1>Test reports grouped by location type</h1>"
        "<table>"
        "<thead><tr>"
        "<th>Location</th>"
        "<th>Successful files</th><th>Successful tests</th>"
        "</tr></thead>"
        "<tbody>"
    )

    PlotStyle = namedtuple("PlotStyle", ["linestyle", "linewidth", "success_color", "fail_color", "total_color"])
    plot_style = PlotStyle(linestyle="-", linewidth=4.0, success_color="g", fail_color="r", total_color="b")

    for location_type, results in results_in_locations.items():
        results = sorted(results, key=operator.attrgetter("timestamp"))
        # TODO: document: location type must be a valid dir name
        directory = os.path.join(output, location_type)
        ensure_dir(directory)

        if location_type == "unknown":
            title = "Test reports"
        else:
            title = "Test reports for &lt;{type}&gt; location type".format(type=location_type)

        x = [date2num(result.timestamp) for result in results]
        # the following would be an alternative but it does not work with
        # labels and automatic axis limits even after removing another date fun
        # x = [result.svn_revision for result in results]
        xlabels = [result.timestamp.strftime("%Y-%m-%d") + " (r" + result.svn_revision + ")" for result in results]
        step = len(x) / 10
        xticks = x[step::step]
        xlabels = xlabels[step::step]
        tests_successful_plot(
            x=x,
            xticks=xticks,
            xlabels=xlabels,
            results=results,
            filename=os.path.join(directory, "tests_successful_plot.png"),
            style=plot_style,
        )
        files_successful_plot(
            x=x,
            xticks=xticks,
            xlabels=xlabels,
            results=results,
            filename=os.path.join(directory, "files_successful_plot.png"),
            style=plot_style,
        )
        tests_plot(
            x=x,
            xticks=xticks,
            xlabels=xlabels,
            results=results,
            filename=os.path.join(directory, "tests_plot.png"),
            style=plot_style,
        )
        tests_percent_plot(
            x=x,
            xticks=xticks,
            xlabels=xlabels,
            results=results,
            filename=os.path.join(directory, "tests_percent_plot.png"),
            style=plot_style,
        )
        files_plot(
            x=x,
            xticks=xticks,
            xlabels=xlabels,
            results=results,
            filename=os.path.join(directory, "files_plot.png"),
            style=plot_style,
        )
        files_percent_plot(
            x=x,
            xticks=xticks,
            xlabels=xlabels,
            results=results,
            filename=os.path.join(directory, "files_percent_plot.png"),
            style=plot_style,
        )
        info_plot(
            x=x,
            xticks=xticks,
            xlabels=xlabels,
            results=results,
            filename=os.path.join(directory, "info_plot.png"),
            style=plot_style,
        )

        main_page(
            results=results,
            filename="index.html",
            images=[
                "tests_successful_plot.png",
                "files_successful_plot.png",
                "tests_plot.png",
                "files_plot.png",
                "tests_percent_plot.png",
                "files_percent_plot.png",
                "info_plot.png",
            ],
            captions=[
                "Success of individual tests in percents",
                "Success of test files in percents",
                "Successes, failures and number of individual tests",
                "Successes, failures and number of test files",
                "Successes and failures of individual tests in percent",
                "Successes and failures of test files in percents",
                "Additional information",
            ],
            directory=directory,
            title=title,
        )

        files_successes = sum(result.files_successes for result in results)
        files_total = sum(result.files_total for result in results)
        successes = sum(result.successes for result in results)
        total = sum(result.total for result in results)
        per_test = success_to_html_percent(total=total, successes=successes)
        per_file = success_to_html_percent(total=files_total, successes=files_successes)
        locations_main_page.write(
            "<tr>"
            "<td><a href={location}/index.html>{location}</a></td>"
            "<td>{pfiles}</td><td>{ptests}</td>"
            "</tr>".format(location=location_type, pfiles=per_file, ptests=per_test)
        )
    locations_main_page.write("</tbody></table>")
    locations_main_page.write("</body></html>")
    locations_main_page.close()
    return 0