bug 348731, add bookmarks parser to tests, use regexp for finding parser, fix end date in waterfall

This commit is contained in:
axel%pike.org 2006-09-04 12:58:20 +00:00
parent c4e87c2b67
commit 3c84332ab2
3 changed files with 53 additions and 14 deletions

View File

@ -39,8 +39,7 @@ import re
import codecs
import logging
__statics = {}
__constructors = {}
__constructors = []
class Parser:
def __init__(self):
@ -80,13 +79,10 @@ class Parser:
return (m.group(1), self.postProcessValue(m.group(2)))
def getParser(path):
ext = path.rsplit('.',1)[1]
if __statics.has_key(ext):
return __statics[ext]
if not __constructors.has_key(ext):
raise UserWarning, "Cannot find Parser"
__statics[ext] = __constructors[ext]()
return __statics[ext]
for item in __constructors:
if re.search(item[0], path):
return item[1]
raise UserWarning, "Cannot find Parser"
class DTDParser(Parser):
def __init__(self):
@ -183,6 +179,7 @@ class BookmarksParser(Parser):
return f
__constructors = {'dtd': DTDParser,
'properties': PropertiesParser,
'inc': DefinesParser}
__constructors = [('\\.dtd', DTDParser()),
('\\.properties', PropertiesParser()),
('\\.inc', DefinesParser()),
('bookmarks\\.html', BookmarksParser())]

View File

@ -356,3 +356,42 @@ class RSSReaderTest(Base):
l.error('RSS Readers are badly set up')
res[loc] = [(titles[o], uris[o]) for o in ind]
return res
class BookmarksTest(Base):
"""Test class to collect information about bookmarks and check their
structure.
"""
def __init__(self):
'''Set up the test class with a good leaf name'''
self.leafName = 'bookmarks-results.json'
pass
def run(self):
'''Collect the data from bookmarks.html for all locales
'''
locales = [loc.strip() for loc in open('mozilla/browser/locales/all-locales')]
bm = Parser.BookmarksParser()
res = {}
for loc in locales:
try:
bm.read('l10n/%s/browser/profile/bookmarks.html'%loc)
res[loc] = bm.getDetails()
except Exception, e:
logging.getLogger('locale.%s'%loc).error('Bookmarks are busted, %s'%e)
return res
def failureTest(self, myResult, failureResult):
'''signal pass/warn/failure for each locale
Just signaling errors for now.
'''
locales = [loc.strip() for loc in open('mozilla/browser/locales/all-locales')]
bm = Parser.BookmarksParser()
bm.read('mozilla/browser/locales/en-US/profile/bookmarks.html')
enUSDetails = bm.getDetails()
for loc in locales:
if not myResult.has_key(loc):
if not failureResult.has_key(loc):
failureResult[loc] = 2
else:
failureResult[loc] |= 2

View File

@ -186,7 +186,10 @@ if not os.path.isdir(basePath):
os.mkdir(basePath)
tests = [Tests.CompareTest(), Tests.SearchTest(), Tests.RSSReaderTest()]
tests = [Tests.CompareTest(),
Tests.SearchTest(),
Tests.RSSReaderTest(),
Tests.BookmarksTest()]
drop = {}
for test in tests:
res = test.run()
@ -202,7 +205,7 @@ if not opts.waterfall:
if opts.enddate:
endtime = time.mktime(time.strptime(opts.enddate, '%Y-%m-%d %H:%M:%S')) + time.altzone
else:
endtime = time.mktime(datetime.utcnow().timetuple())
endtime = time.mktime(datetime.now().timetuple())
f = None
w = Wrapper(opts.target, 'waterfall.json')
if os.path.isfile(w.p):