~ubuntu-branches/ubuntu/quantal/enigmail/quantal-security

« back to all changes in this revision

Viewing changes to build/xpccheck.py

  • Committer: Package Import Robot
  • Author(s): Chris Coulson
  • Date: 2013-09-13 16:02:15 UTC
  • mfrom: (0.12.16)
  • Revision ID: package-import@ubuntu.com-20130913160215-u3g8nmwa0pdwagwc
Tags: 2:1.5.2-0ubuntu0.12.10.1
* New upstream release v1.5.2 for Thunderbird 24

* Build enigmail using a stripped down Thunderbird 17 build system, as it's
  now quite difficult to build the way we were doing previously, with the
  latest Firefox build system
* Add debian/patches/no_libxpcom.patch - Don't link against libxpcom, as it
  doesn't exist anymore (but exists in the build system)
* Add debian/patches/use_sdk.patch - Use the SDK version of xpt.py and
  friends
* Drop debian/patches/ipc-pipe_rename.diff (not needed anymore)
* Drop debian/patches/makefile_depth.diff (not needed anymore)

Show diffs side-by-side

added added

removed removed

Lines of Context:
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/.
4
 
 
5
 
'''A generic script to verify all test files are in the 
6
 
corresponding .ini file.
7
 
 
8
 
Usage: xpccheck.py <directory> [<directory> ...]
9
 
'''
10
 
 
11
 
import sys
12
 
import os
13
 
from glob import glob
14
 
import manifestparser
15
 
 
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)
20
 
 
21
 
  def getRelativeRoot(self, here):
22
 
    if self.testroot is None:
23
 
        return manifestparser.ManifestParser.getRelativeRoot(self, self.rootdir)
24
 
    return self.testroot
25
 
 
26
 
 
27
 
def getIniTests(testdir):
28
 
  mp = manifestparser.ManifestParser(strict=False)
29
 
  mp.read(os.path.join(testdir, 'xpcshell.ini'))
30
 
  return mp.tests
31
 
 
32
 
def verifyDirectory(initests, directory):
33
 
  files = glob(os.path.join(os.path.abspath(directory), "test_*"))
34
 
  for f in files:
35
 
    if (not os.path.isfile(f)):
36
 
      continue
37
 
 
38
 
    name = os.path.basename(f)
39
 
    if name.endswith('.in'):
40
 
      name = name[:-3]
41
 
 
42
 
    if not name.endswith('.js'):
43
 
      continue
44
 
 
45
 
    found = False
46
 
    for test in initests:
47
 
      if os.path.join(os.path.abspath(directory), name) == test['path']:
48
 
        found = True
49
 
        break
50
 
   
51
 
    if not found:
52
 
      print >>sys.stderr, "TEST-UNEXPECTED-FAIL | xpccheck | test %s is missing from test manifest %s!" % (name, os.path.join(directory, 'xpcshell.ini'))
53
 
      sys.exit(1)
54
 
 
55
 
def verifyIniFile(initests, directory):
56
 
  files = glob(os.path.join(os.path.abspath(directory), "test_*"))
57
 
  for test in initests:
58
 
    name = test['path'].split('/')[-1]
59
 
 
60
 
    found = False
61
 
    for f in files:
62
 
 
63
 
      fname = f.split('/')[-1]
64
 
      if fname.endswith('.in'):
65
 
        fname = '.in'.join(fname.split('.in')[:-1])
66
 
 
67
 
      if os.path.join(os.path.abspath(directory), fname) == test['path']:
68
 
        found = True
69
 
        break
70
 
 
71
 
    if not found:
72
 
      print >>sys.stderr, "TEST-UNEXPECTED-FAIL | xpccheck | found %s in xpcshell.ini and not in directory '%s'" % (name, directory)
73
 
      sys.exit(1)
74
 
 
75
 
def verifyMasterIni(mastername, topsrcdir, directory):
76
 
  mp = srcManifestParser(strict=False, testroot=topsrcdir)
77
 
  mp.read(mastername)
78
 
  tests = mp.tests
79
 
 
80
 
  found = False
81
 
  for test in tests:
82
 
    if test['manifest'] == os.path.abspath(os.path.join(directory, 'xpcshell.ini')):
83
 
      found = True
84
 
      break
85
 
 
86
 
  if not found:
87
 
    print >>sys.stderr, "TEST-UNEXPECTED-FAIL | xpccheck | directory %s is missing from master xpcshell.ini file %s" % (directory, mastername)
88
 
    sys.exit(1)
89
 
 
90
 
 
91
 
if __name__ == '__main__':
92
 
  if len(sys.argv) < 4:
93
 
    print >>sys.stderr, "Usage: xpccheck.py <topsrcdir> <path/master.ini> <directory> [<directory> ...]"
94
 
    sys.exit(1)
95
 
 
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'):
101
 
      continue
102
 
 
103
 
    initests = getIniTests(d)
104
 
    verifyDirectory(initests, d)
105
 
    verifyIniFile(initests, d)
106
 
    verifyMasterIni(sys.argv[2], topsrcdir, d)
107
 
 
108