reporting.py revision cf22150eaeeb72431bf1cf65c309a431454fb22b
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# -*- coding: utf-8 -*-
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncTest Result Report Writer.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncThis takes a processed test result tree and creates a HTML, re-structured text,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncor normal text report from it.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncCopyright (C) 2010-2014 Oracle Corporation
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncThis file is part of VirtualBox Open Source Edition (OSE), as
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncavailable from http://www.virtualbox.org. This file is free software;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncyou can redistribute it and/or modify it under the terms of the GNU
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncGeneral Public License (GPL) as published by the Free Software
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncFoundation, in version 2 as it comes in the "COPYING" file of the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncVirtualBox OSE distribution. VirtualBox OSE is distributed in the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsynchope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncThe contents of this file may alternatively be used under the terms
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncof the Common Development and Distribution License Version 1.0
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync(CDDL) only, as it comes in the "COPYING.CDDL" file of the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncVirtualBox OSE distribution, in which case the provisions of the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncCDDL are applicable instead of those of the GPL.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncYou may elect to license modified versions of this file under the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncterms and conditions of either the GPL or the CDDL or both.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync__all__ = ['HtmlReport', 'RstReport', 'TextReport'];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """ Apparently, python 3.0(/3.1) has(/will have) support for this..."""
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Try convert the string/value to a long.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Convert it back to a string (paranoia) and build up the new string.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync A table as a header as well as data rows, thus this class.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """Adds a row."""
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Split cells into multiple rows on '|'. Omit the first column.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Readability hack: Add an extra row if there are diffs.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """ Checks if the test values has the same heading."""
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """ Checks if the other table has the same heading."""
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """ Append the rows in oTable. oTable has the same heading as us. """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # manipulation and stuff
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """ Turns bytes into KB, MB or GB. """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """ Adds thousand separators to make numbers more readable. """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync asValues[i] = tryAddThousandSeparators(asValues[i]);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """Figure out the column withs."""
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Header is first.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Check out all cells.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Break the test results down into a list of tables containing the values.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync TODO: Handle passed / failed stuff too. Not important for benchmarks.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # depth first
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # values -> row
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if len(aoTables) > 0 and aoTables[len(aoTables) - 1].hasTheSameHeadingAsTest(oCurTest):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync aoTables[len(aoTables) - 1].addRow(oCurTest, fSplitDiff);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Pass 2 - Combine tables with the same heading.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oTable is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Produce an HTML report on stdout (via print).
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Produce a ReStructured text report on stdout (via print).
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Produce a text report on stdout (via print).
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Report header.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ## @todo later
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Tabelize the the results and display the tables.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ## @todo do max/min on the columns where we can do [GMK]B(/s).
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # The header.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # This is a bit tedious and the solution isn't entirely elegant due
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # to the pick-it-up-as-you-go-along python skills.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif len(s) + 1 + len(aasHeader[iLine][iColumn]) <= acchColumns[iColumn]:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if iLine >= len(aasHeader): # There must be a better way to do this...
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Separator line.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # The rows.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;