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 class srcManifestParser(manifestparser
.ManifestParser
):
17 def __init__(self
, manifests
=(), defaults
=None, strict
=True, testroot
=None):
18 self
.testroot
= testroot
19 manifestparser
.ManifestParser
.__init
__(self
, manifests
, defaults
, strict
)
21 def getRelativeRoot(self
, here
):
22 if self
.testroot
is None:
23 return manifestparser
.ManifestParser
.getRelativeRoot(self
, self
.rootdir
)
27 def getIniTests(testdir
):
28 mp
= manifestparser
.ManifestParser(strict
=False)
29 mp
.read(os
.path
.join(testdir
, 'xpcshell.ini'))
32 def verifyDirectory(initests
, directory
):
33 files
= glob(os
.path
.join(os
.path
.abspath(directory
), "test_*"))
35 if (not os
.path
.isfile(f
)):
38 name
= os
.path
.basename(f
)
39 if name
.endswith('.in'):
42 if not name
.endswith('.js'):
47 if os
.path
.join(os
.path
.abspath(directory
), name
) == test
['path']:
52 print >>sys
.stderr
, "TEST-UNEXPECTED-FAIL | xpccheck | test %s is missing from test manifest %s!" % (name
, os
.path
.join(directory
, 'xpcshell.ini'))
55 def verifyIniFile(initests
, directory
):
56 files
= glob(os
.path
.join(os
.path
.abspath(directory
), "test_*"))
58 name
= test
['path'].split('/')[-1]
63 fname
= f
.split('/')[-1]
64 if fname
.endswith('.in'):
65 fname
= '.in'.join(fname
.split('.in')[:-1])
67 if os
.path
.join(os
.path
.abspath(directory
), fname
) == test
['path']:
72 print >>sys
.stderr
, "TEST-UNEXPECTED-FAIL | xpccheck | found %s in xpcshell.ini and not in directory '%s'" % (name
, directory
)
75 def verifyMasterIni(mastername
, topsrcdir
, directory
):
76 mp
= srcManifestParser(strict
=False, testroot
=topsrcdir
)
82 if test
['manifest'] == os
.path
.abspath(os
.path
.join(directory
, 'xpcshell.ini')):
87 print >>sys
.stderr
, "TEST-UNEXPECTED-FAIL | xpccheck | directory %s is missing from master xpcshell.ini file %s" % (directory
, mastername
)
91 if __name__
== '__main__':
93 print >>sys
.stderr
, "Usage: xpccheck.py <topsrcdir> <path/master.ini> <directory> [<directory> ...]"
96 topsrcdir
= sys
.argv
[1]
97 for d
in sys
.argv
[3:]:
98 # xpcshell-unpack is a copy of xpcshell sibling directory and in the Makefile
99 # we copy all files (including xpcshell.ini from the sibling directory.
100 if d
.endswith('toolkit/mozapps/extensions/test/xpcshell-unpack'):
103 initests
= getIniTests(d
)
104 verifyDirectory(initests
, d
)
105 verifyIniFile(initests
, d
)
106 verifyMasterIni(sys
.argv
[2], topsrcdir
, d
)