diff --git a/testing/tests/l10n/lib/Mozilla/Parser.py b/testing/tests/l10n/lib/Mozilla/Parser.py index 56c3b2d6aa71..255210650f7f 100755 --- a/testing/tests/l10n/lib/Mozilla/Parser.py +++ b/testing/tests/l10n/lib/Mozilla/Parser.py @@ -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())] diff --git a/testing/tests/l10n/lib/Mozilla/Tests.py b/testing/tests/l10n/lib/Mozilla/Tests.py index fb8cade1a35d..4384264ac04a 100755 --- a/testing/tests/l10n/lib/Mozilla/Tests.py +++ b/testing/tests/l10n/lib/Mozilla/Tests.py @@ -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 diff --git a/testing/tests/l10n/scripts/test-locales b/testing/tests/l10n/scripts/test-locales index efb2960fdba9..b03cc992aa9c 100755 --- a/testing/tests/l10n/scripts/test-locales +++ b/testing/tests/l10n/scripts/test-locales @@ -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):