#!/usr/bin/env python
#
# Copyright (C) 2004, 2005, 2006 Nathaniel Smith
# Copyright (C) 2007 Holger Hans Peter Freyther
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
# its contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# HTML output inspired by the output of lcov as found on the GStreamer
# site. I assume this is not copyrightable.
#
#
# Read all CSV files and
# Create an overview file
#
#
import sys
import csv
import glob
import time
import os
import os.path
import datetime
import shutil
os.environ["TTFPATH"] = ":".join(["/usr/share/fonts/truetype/" + d
for d in "ttf-bitstream-vera",
"freefont",
"msttcorefonts"])
import matplotlib
matplotlib.use("Agg")
import matplotlib.pylab as m
level_LOW = 10
level_MEDIUM = 70
def copy_files(dest_dir):
"""
Copy the CSS and the png's to the destination directory
"""
images = ["amber.png", "emerald.png", "glass.png", "ruby.png", "snow.png"]
css = "gcov.css"
(base_path, name) = os.path.split(__file__)
base_path = os.path.abspath(base_path)
shutil.copyfile(os.path.join(base_path,css), os.path.join(dest_dir,css))
map(lambda x: shutil.copyfile(os.path.join(base_path,x), os.path.join(dest_dir,x)), images)
def sumcov(cov):
return "%.2f%% (%s/%s)" % (cov[1] * 100.0 / (cov[0] or 1), cov[1], cov[0])
def create_page(dest_dir, name):
index = open(os.path.join(dest_dir, name), "w")
index.write("""
WebKit test coverage information
""")
return index
def generate_header(file, last_time, total_lines, total_executed, path, image):
product = "WebKit"
date = time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(last_time))
covered_lines = sumcov((total_lines, total_executed))
file.write("""