1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 '''A generic script to verify all test files are in the
6 corresponding .ini file.
8 Usage: xpccheck.py <directory> [<directory> ...]
16 def getIniTests(testdir
):
17 mp
= manifestparser
.ManifestParser(strict
=False)
18 mp
.read(os
.path
.join(testdir
, 'xpcshell.ini'))
21 def verifyDirectory(initests
, directory
):
22 files
= glob(os
.path
.join(os
.path
.abspath(directory
), "test_*"))
24 if (not os
.path
.isfile(f
)):
27 name
= os
.path
.basename(f
)
28 if name
.endswith('.in'):
31 if not name
.endswith('.js'):
36 if os
.path
.join(os
.path
.abspath(directory
), name
) == test
['path']:
41 print >>sys
.stderr
, "TEST-UNEXPECTED-FAIL | xpccheck | test %s is missing from test manifest %s!" % (name
, os
.path
.join(directory
, 'xpcshell.ini'))
44 def verifyIniFile(initests
, directory
):
45 files
= glob(os
.path
.join(os
.path
.abspath(directory
), "test_*"))
47 name
= test
['path'].split('/')[-1]
52 fname
= f
.split('/')[-1]
53 if fname
.endswith('.in'):
54 fname
= '.in'.join(fname
.split('.in')[:-1])
56 if os
.path
.join(os
.path
.abspath(directory
), fname
) == test
['path']:
61 print >>sys
.stderr
, "TEST-UNEXPECTED-FAIL | xpccheck | found %s in xpcshell.ini and not in directory '%s'" % (name
, directory
)
64 if __name__
== '__main__':
66 print >>sys
.stderr
, "Usage: xpccheck.py <topsrcdir> <directory> [<directory> ...]"
69 topsrcdir
= sys
.argv
[1]
70 for d
in sys
.argv
[2:]:
71 # xpcshell-unpack is a copy of xpcshell sibling directory and in the Makefile
72 # we copy all files (including xpcshell.ini from the sibling directory.
73 if d
.endswith('toolkit/mozapps/extensions/test/xpcshell-unpack'):
76 initests
= getIniTests(d
)
77 verifyDirectory(initests
, d
)
78 verifyIniFile(initests
, d
)