#!/usr/bin/env python # Copyright 2016 The Kubernetes Authors All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Creates an HTML report for all jobs starting with a given prefix. Reads the JSON from tests.json, and prints the HTML to stdout. This code is pretty nasty, but gets the job done. It would be really spiffy if this used an HTML template system, but for now we're old-fashioned. We could also generate these with JS, directly from the JSON. That would allow custom filtering and stuff like that. """ from __future__ import print_function import argparse import json import os import string import sys import time def gen_tests(data, prefix, exact_match): """Creates the HTML for all test cases. Args: data: Parsed JSON data that was created by gen_json.py. prefix: Considers Jenkins jobs that start with this. exact_match: Only match Jenkins jobs with name equal to prefix. Returns: The HTML as a list of elements along with a tuple of the number of passing, unstable, failing, and skipped tests. """ html = ['') return '\n'.join(html), (total_okay, total_unstable, total_failed, total_skipped) def html_header(): html = ['', ''] html.append('') html.append('') html.append('') html.append('') return html def gen_html(data, prefix, exact_match=False): """Creates the HTML for the entire page. Args: Same as gen_tests. Returns: Same as gen_tests. """ tests_html, (okay, unstable, failed, skipped) = gen_tests(data, prefix, exact_match) html = html_header() if exact_match: html.append('