--- a/layout/reftests/w3c-css/import-tests.py
+++ b/layout/reftests/w3c-css/import-tests.py
@@ -24,20 +24,18 @@ import re
# least for a subset of secs. And we probably want to organize the
# directory structure by spec to avoid constant file moves when files
# move in the W3C repository. And we probably also want to import each
# test only once, even if it covers more than one spec.)
# But for now, let's just import a few sets of tests.
gSubtrees = [
- os.path.join("approved", "css3-namespace", "src"),
- #os.path.join("approved", "css3-multicol", "src"),
- os.path.join("contributors", "opera", "submitted", "css3-conditional"),
- #os.path.join("contributors", "opera", "submitted", "multicol")
+ os.path.join("css-namespaces-3"),
+ os.path.join("css-conditional-3"),
]
gPrefixedProperties = [
"column-count",
"column-fill",
"column-gap",
"column-rule",
"column-rule-color",
@@ -106,16 +104,20 @@ def remove_existing_dirs():
def populate_test_files():
global gSubtrees, gTestfiles
for subtree in gSubtrees:
for dirpath, dirnames, filenames in os.walk(subtree, topdown=True):
if "support" in dirnames:
dirnames.remove("support")
if "reftest" in dirnames:
dirnames.remove("reftest")
+ if "reference" in dirnames:
+ dirnames.remove("reference")
+ if "reports" in dirnames:
+ dirnames.remove("reports")
for f in filenames:
if f == "README" or \
f.find("-ref.") != -1:
continue
gTestfiles.append(os.path.join(dirpath, f))
gTestfiles.sort()
@@ -155,63 +157,60 @@ def map_file(fn, spec):
filemap[fn] = destname
load_flags_for(fn, spec)
copy_file(destname, fn, destname, False)
copy_support_files(destname, os.path.dirname(fn), spec)
return destname
def load_flags_for(fn, spec):
global gTestFlags
- document = get_document_for(fn, spec)
+ document = get_document_for(fn)
destname = os.path.join(spec, os.path.basename(fn))
gTestFlags[destname] = []
for meta in document.getElementsByTagName("meta"):
name = meta.getAttribute("name")
if name == "flags":
gTestFlags[destname] = meta.getAttribute("content").split()
-def get_document_for(fn, spec):
+def get_document_for(fn):
document = None # an xml.dom.minidom document
if fn.endswith(".htm") or fn.endswith(".html"):
# An HTML file
f = open(fn, "r")
parser = html5lib.HTMLParser(tree=html5lib.treebuilders.getTreeBuilder("dom"))
document = parser.parse(f)
f.close()
else:
# An XML file
document = xml.dom.minidom.parse(fn)
return document
def add_test_items(fn, spec):
- document = get_document_for(fn, spec)
+ document = get_document_for(fn)
refs = []
notrefs = []
for link in document.getElementsByTagName("link"):
rel = link.getAttribute("rel")
- if rel == "help" and spec == None:
- specurl = link.getAttribute("href")
- startidx = specurl.find("/TR/")
- if startidx != -1:
- startidx = startidx + 4
- endidx = specurl.find("/", startidx)
- if endidx != -1:
- spec = str(specurl[startidx:endidx])
if rel == "match":
arr = refs
elif rel == "mismatch":
arr = notrefs
else:
continue
arr.append(os.path.join(os.path.dirname(fn), str(link.getAttribute("href"))))
if len(refs) > 1:
raise StandardError("Need to add code to specify which reference we want to match.")
if spec is None:
- raise StandardError("Could not associate test with specification")
+ for subtree in gSubtrees:
+ if fn.startswith(subtree):
+ spec = os.path.basename(subtree)
+ break
+ else:
+ raise StandardError("Could not associate test " + fn + " with specification")
for ref in refs:
tests.append(["==", map_file(fn, spec), map_file(ref, spec)])
for notref in notrefs:
tests.append(["!=", map_file(fn, spec), map_file(notref, spec)])
# Add chained references too
for ref in refs:
add_test_items(ref, spec=spec)
for notref in notrefs: