split-testinfo-data.py
author L. David Baron <dbaron@dbaron.org>
Fri, 01 Oct 2010 15:16:23 -0700
changeset 21 54c5cb2545c8
parent 17 40170cdf5d56
child 40 7c8a3e473c42
permissions -rwxr-xr-x
Add results of running 20100917 noninteractive tests on 4.0b6 Linux.
#!/usr/bin/python

# L. David Baron <dbaron@dbaron.org>, 2010-09-23

# Split the testinfo.data file in the CSS 2.1 test suite up into three
# lists, one containing reftests, one containing noninteractive tests,
# and one containing interactive tests.

# Copyright (c) 2010, The Mozilla Foundation
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
#     Redistributions of source code must retain the above copyright notice,
#     this list of conditions and the following disclaimer.
#     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.
#     Neither the name of The Mozilla Foundation 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT HOLDER OR 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.

import csv

# Note that this requires deleting the extra blank line at the end of
# the official testinfo.data file.
in_data = open("testinfo.data")

reftests_list = open("tests-reftests.list", "w")
noninteractive_list = open("tests-noninteractive.list", "w")
interactive_list = open("tests-interactive.html", "w")
tests = csv.DictReader(in_data, delimiter="\t", lineterminator="\n")
for test in tests:
    name = test["id"]
    ref = test["reference"]
    if ref.endswith(".xht"):
        ref = ref[0:len(ref)-4]
    flags = test["flags"].split(",")
    for fmt in [ { "extension": "xht", "xflag": "HTMLonly", "dir": "xhtml1" },
                 { "extension": "htm", "xflag": "nonHTML",  "dir": "html4" } ]:
        if fmt["xflag"] in flags:
            continue
        def fname(base):
            """Turn a base name into its filename in this format."""
            return "http://test.csswg.org/suites/css2.1/20100917/" + \
                   fmt["dir"] + "/" + base + "." + fmt["extension"]
        if ref != "":
            reftests_list.write("== " + fname(name) + " " + fname(ref) + "\n")
        # flag tests according to
        # http://lists.w3.org/Archives/Public/public-css-testsuite/2010Sep/0211
        elif "interact" in flags or \
             "animated" in flags or \
             "userstyle" in flags:
            interactive_list.write("<a href='" + fname(name) + "'>" + name +
                                   "</a><br>\n");
        else:
            # Use '==' so that it fails, which will make the harness
            # output the images in the log.
            noninteractive_list.write("== " + fname(name) + " about:blank\n")

in_data.close()
reftests_list.close()
noninteractive_list.close()
interactive_list.close()