Bug 888271 - Make test_AudioBufferSourceNodeOffset.html fuzzier.
[gecko.git] / build / xpccheck.py
blob7183439824ef2b739caf8f1d221831891453e27c
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> ...]
9 '''
11 import sys
12 import os
13 from glob import glob
14 import manifestparser
16 def getIniTests(testdir):
17 mp = manifestparser.ManifestParser(strict=False)
18 mp.read(os.path.join(testdir, 'xpcshell.ini'))
19 return mp.tests
21 def verifyDirectory(initests, directory):
22 files = glob(os.path.join(os.path.abspath(directory), "test_*"))
23 for f in files:
24 if (not os.path.isfile(f)):
25 continue
27 name = os.path.basename(f)
28 if name.endswith('.in'):
29 name = name[:-3]
31 if not name.endswith('.js'):
32 continue
34 found = False
35 for test in initests:
36 if os.path.join(os.path.abspath(directory), name) == test['path']:
37 found = True
38 break
40 if not found:
41 print >>sys.stderr, "TEST-UNEXPECTED-FAIL | xpccheck | test %s is missing from test manifest %s!" % (name, os.path.join(directory, 'xpcshell.ini'))
42 sys.exit(1)
44 def verifyIniFile(initests, directory):
45 files = glob(os.path.join(os.path.abspath(directory), "test_*"))
46 for test in initests:
47 name = test['path'].split('/')[-1]
49 found = False
50 for f in files:
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']:
57 found = True
58 break
60 if not found:
61 print >>sys.stderr, "TEST-UNEXPECTED-FAIL | xpccheck | found %s in xpcshell.ini and not in directory '%s'" % (name, directory)
62 sys.exit(1)
64 if __name__ == '__main__':
65 if len(sys.argv) < 3:
66 print >>sys.stderr, "Usage: xpccheck.py <topsrcdir> <directory> [<directory> ...]"
67 sys.exit(1)
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'):
74 continue
76 initests = getIniTests(d)
77 verifyDirectory(initests, d)
78 verifyIniFile(initests, d)