Bug 1027215 - Rewrite print-manifest-dirs.py to use new manifest parser; r=roc

Now that we've established a slightly better Python reftest manifest
parser, switch the existing manifest parsing code in
print-manifest-dirs.py to use it.

--HG--
extra : rebase_source : 9559eb5aa47d08b9854a27ed012f2a795abc67f7
extra : histedit_source : 7a9a8942f9310c079a5ea4321a7f4f2ad17008d1
This commit is contained in:
Gregory Szorc 2014-06-17 17:37:09 -07:00
parent d440b01170
commit 0268c3225a

View File

@ -3,77 +3,27 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import sys, os.path, re
commentRE = re.compile(r"\s+#")
conditionsRE = re.compile(r"^(fails|needs-focus|random|skip|asserts|slow|require-or|silentfail|pref|test-pref|ref-pref|fuzzy)")
httpRE = re.compile(r"HTTP\((\.\.(\/\.\.)*)\)")
protocolRE = re.compile(r"^\w+:")
def parseManifest(manifest, dirs):
"""Parse the reftest manifest |manifest|, adding all directories containing
tests (and the dirs containing the manifests themselves) to the set |dirs|."""
manifestdir = os.path.dirname(os.path.abspath(manifest))
dirs.add(manifestdir)
f = file(manifest)
urlprefix = ''
for line in f:
if line[0] == '#':
continue # entire line was a comment
m = commentRE.search(line)
if m:
line = line[:m.start()]
line = line.strip()
if not line:
continue
items = line.split()
while conditionsRE.match(items[0]):
del items[0]
if items[0] == "HTTP":
del items[0]
m = httpRE.match(items[0])
if m:
# need to package the dir referenced here
d = os.path.normpath(os.path.join(manifestdir, m.group(1)))
dirs.add(d)
del items[0]
if items[0] == "url-prefix":
urlprefix = items[1]
continue
elif items[0] == "default-preferences":
continue
elif items[0] == "include":
parseManifest(os.path.join(manifestdir, items[1]), dirs)
continue
elif items[0] == "load" or items[0] == "script":
testURLs = [items[1]]
elif items[0] == "==" or items[0] == "!=":
testURLs = items[1:3]
for u in testURLs:
m = protocolRE.match(u)
if m:
# can't very well package about: or data: URIs
continue
d = os.path.dirname(os.path.normpath(os.path.join(manifestdir, urlprefix + u)))
dirs.add(d)
f.close()
import os
import sys
from reftest import ReftestManifest
def printTestDirs(topsrcdir, topmanifests):
"""Parse |topmanifests| and print a list of directories containing the tests
within (and the manifests including those tests), relative to |topsrcdir|."""
topsrcdir = os.path.abspath(topsrcdir)
dirs = set()
for manifest in topmanifests:
parseManifest(manifest, dirs)
for dir in sorted(dirs):
d = dir[len(topsrcdir):].replace('\\','/')
if d[0] == '/':
d = d[1:]
print d
"""Parse |topmanifests| and print a list of directories containing the tests
within (and the manifests including those tests), relative to |topsrcdir|.
"""
topsrcdir = os.path.abspath(topsrcdir)
dirs = set()
for path in topmanifests:
m = ReftestManifest()
m.load(path)
dirs |= m.dirs
for d in sorted(dirs):
d = d[len(topsrcdir):].replace('\\', '/').lstrip('/')
print(d)
if __name__ == '__main__':
if len(sys.argv) < 3:
print >>sys.stderr, "Usage: %s topsrcdir reftest.list [reftest.list]*" % sys.argv[0]
sys.exit(1)
printTestDirs(sys.argv[1], sys.argv[2:])
if len(sys.argv) < 3:
print >>sys.stderr, "Usage: %s topsrcdir reftest.list [reftest.list]*" % sys.argv[0]
sys.exit(1)
printTestDirs(sys.argv[1], sys.argv[2:])