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
14 # The Original Code is Mozilla build system.
16 # The Initial Developer of the Original Code is
18 # Portions created by the Initial Developer are Copyright (C) 2011
19 # the Initial Developer. All Rights Reserved.
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> ...]
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
)
60 def getIniTests(testdir
):
61 mp
= manifestparser
.ManifestParser(strict
=False)
62 mp
.read(os
.path
.join(testdir
, 'xpcshell.ini'))
65 def verifyDirectory(initests
, directory
):
66 files
= glob(os
.path
.join(os
.path
.abspath(directory
), "test_*"))
68 if (not os
.path
.isfile(f
)):
71 name
= os
.path
.basename(f
)
72 if name
.endswith('.in'):
75 if not name
.endswith('.js'):
80 if os
.path
.join(os
.path
.abspath(directory
), name
) == test
['path']:
85 print >>sys
.stderr
, "TEST-UNEXPECTED-FAIL | xpccheck | test %s is missing from test manifest %s!" % (name
, os
.path
.join(directory
, 'xpcshell.ini'))
88 def verifyIniFile(initests
, directory
):
89 files
= glob(os
.path
.join(os
.path
.abspath(directory
), "test_*"))
91 name
= test
['path'].split('/')[-1]
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']:
105 print >>sys
.stderr
, "TEST-UNEXPECTED-FAIL | xpccheck | found %s in xpcshell.ini and not in directory '%s'" % (name
, directory
)
108 def verifyMasterIni(mastername
, topsrcdir
, directory
):
109 mp
= srcManifestParser(strict
=False, testroot
=topsrcdir
)
115 if test
['manifest'] == os
.path
.abspath(os
.path
.join(directory
, 'xpcshell.ini')):
120 print >>sys
.stderr
, "TEST-UNEXPECTED-FAIL | xpccheck | directory %s is missing from master xpcshell.ini file %s" % (directory
, mastername
)
124 if __name__
== '__main__':
125 if len(sys
.argv
) < 4:
126 print >>sys
.stderr
, "Usage: xpccheck.py <topsrcdir> <path/master.ini> <directory> [<directory> ...]"
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'):
136 initests
= getIniTests(d
)
137 verifyDirectory(initests
, d
)
138 verifyIniFile(initests
, d
)
139 verifyMasterIni(sys
.argv
[2], topsrcdir
, d
)