Bug 752461 - Hide click-to-play overlays when choosing "never activate plugins.....
[gecko.git] / build / xpccheck.py
blob66dc4bac2273c9a711ada9bc1a9130eb0bfcc903
1 # ***** BEGIN LICENSE BLOCK *****
2 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 # The contents of this file are subject to the Mozilla Public License Version
5 # 1.1 (the "License"); you may not use this file except in compliance with
6 # the License. You may obtain a copy of the License at
7 # http://www.mozilla.org/MPL/
9 # Software distributed under the License is distributed on an "AS IS" basis,
10 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 # for the specific language governing rights and limitations under the
12 # License.
14 # The Original Code is Mozilla build system.
16 # The Initial Developer of the Original Code is
17 # Mozilla Foundation.
18 # Portions created by the Initial Developer are Copyright (C) 2011
19 # the Initial Developer. All Rights Reserved.
21 # Contributor(s):
22 # Joel Maher <joel.maher@gmail.com>
24 # Alternatively, the contents of this file may be used under the terms of
25 # either the GNU General Public License Version 2 or later (the "GPL"), or
26 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 # in which case the provisions of the GPL or the LGPL are applicable instead
28 # of those above. If you wish to allow use of your version of this file only
29 # under the terms of either the GPL or the LGPL, and not to allow others to
30 # use your version of this file under the terms of the MPL, indicate your
31 # decision by deleting the provisiwons above and replace them with the notice
32 # and other provisions required by the GPL or the LGPL. If you do not delete
33 # the provisions above, a recipient may use your version of this file under
34 # the terms of any one of the MPL, the GPL or the LGPL.
36 # ***** END LICENSE BLOCK *****
38 '''A generic script to verify all test files are in the
39 corresponding .ini file.
41 Usage: xpccheck.py <directory> [<directory> ...]
42 '''
44 import sys
45 import os
46 from glob import glob
47 import manifestparser
49 class srcManifestParser(manifestparser.ManifestParser):
50 def __init__(self, manifests=(), defaults=None, strict=True, testroot=None):
51 self.testroot = testroot
52 manifestparser.ManifestParser.__init__(self, manifests, defaults, strict)
54 def getRelativeRoot(self, here):
55 if self.testroot is None:
56 return manifestparser.ManifestParser.getRelativeRoot(self, self.rootdir)
57 return self.testroot
60 def getIniTests(testdir):
61 mp = manifestparser.ManifestParser(strict=False)
62 mp.read(os.path.join(testdir, 'xpcshell.ini'))
63 return mp.tests
65 def verifyDirectory(initests, directory):
66 files = glob(os.path.join(os.path.abspath(directory), "test_*"))
67 for f in files:
68 if (not os.path.isfile(f)):
69 continue
71 name = os.path.basename(f)
72 if name.endswith('.in'):
73 name = name[:-3]
75 if not name.endswith('.js'):
76 continue
78 found = False
79 for test in initests:
80 if os.path.join(os.path.abspath(directory), name) == test['path']:
81 found = True
82 break
84 if not found:
85 print >>sys.stderr, "TEST-UNEXPECTED-FAIL | xpccheck | test %s is missing from test manifest %s!" % (name, os.path.join(directory, 'xpcshell.ini'))
86 sys.exit(1)
88 def verifyIniFile(initests, directory):
89 files = glob(os.path.join(os.path.abspath(directory), "test_*"))
90 for test in initests:
91 name = test['path'].split('/')[-1]
93 found = False
94 for f in files:
96 fname = f.split('/')[-1]
97 if fname.endswith('.in'):
98 fname = '.in'.join(fname.split('.in')[:-1])
100 if os.path.join(os.path.abspath(directory), fname) == test['path']:
101 found = True
102 break
104 if not found:
105 print >>sys.stderr, "TEST-UNEXPECTED-FAIL | xpccheck | found %s in xpcshell.ini and not in directory '%s'" % (name, directory)
106 sys.exit(1)
108 def verifyMasterIni(mastername, topsrcdir, directory):
109 mp = srcManifestParser(strict=False, testroot=topsrcdir)
110 mp.read(mastername)
111 tests = mp.tests
113 found = False
114 for test in tests:
115 if test['manifest'] == os.path.abspath(os.path.join(directory, 'xpcshell.ini')):
116 found = True
117 break
119 if not found:
120 print >>sys.stderr, "TEST-UNEXPECTED-FAIL | xpccheck | directory %s is missing from master xpcshell.ini file %s" % (directory, mastername)
121 sys.exit(1)
124 if __name__ == '__main__':
125 if len(sys.argv) < 4:
126 print >>sys.stderr, "Usage: xpccheck.py <topsrcdir> <path/master.ini> <directory> [<directory> ...]"
127 sys.exit(1)
129 topsrcdir = sys.argv[1]
130 for d in sys.argv[3:]:
131 # xpcshell-unpack is a copy of xpcshell sibling directory and in the Makefile
132 # we copy all files (including xpcshell.ini from the sibling directory.
133 if d.endswith('toolkit/mozapps/extensions/test/xpcshell-unpack'):
134 continue
136 initests = getIniTests(d)
137 verifyDirectory(initests, d)
138 verifyIniFile(initests, d)
139 verifyMasterIni(sys.argv[2], topsrcdir, d)