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

« back to all changes in this revision

Viewing changes to mozilla/testing/mozbase/test.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
#!/usr/bin/env python
 
2
 
 
3
# This Source Code Form is subject to the terms of the Mozilla Public
 
4
# License, v. 2.0. If a copy of the MPL was not distributed with this
 
5
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
6
 
 
7
"""
 
8
run mozbase tests from a manifest,
 
9
by default https://github.com/mozilla/mozbase/blob/master/test-manifest.ini
 
10
"""
 
11
 
 
12
import imp
 
13
import manifestparser
 
14
import os
 
15
import sys
 
16
import unittest
 
17
 
 
18
here = os.path.dirname(os.path.abspath(__file__))
 
19
 
 
20
def unittests(path):
 
21
    """return the unittests in a .py file"""
 
22
 
 
23
    path = os.path.abspath(path)
 
24
    unittests = []
 
25
    assert os.path.exists(path)
 
26
    directory = os.path.dirname(path)
 
27
    sys.path.insert(0, directory) # insert directory into path for top-level imports
 
28
    modname = os.path.splitext(os.path.basename(path))[0]
 
29
    module = imp.load_source(modname, path)
 
30
    sys.path.pop(0) # remove directory from global path
 
31
    loader = unittest.TestLoader()
 
32
    suite = loader.loadTestsFromModule(module)
 
33
    for test in suite:
 
34
        unittests.append(test)
 
35
    return unittests
 
36
 
 
37
def main(args=sys.argv[1:]):
 
38
 
 
39
    # read the manifest
 
40
    if args:
 
41
        manifests = args
 
42
    else:
 
43
        manifests = [os.path.join(here, 'test-manifest.ini')]
 
44
    missing = []
 
45
    for manifest in manifests:
 
46
        # ensure manifests exist
 
47
        if not os.path.exists(manifest):
 
48
            missing.append(manifest)
 
49
    assert not missing, 'manifest%s not found: %s' % ((len(manifests) == 1 and '' or 's'), ', '.join(missing))
 
50
    manifest = manifestparser.TestManifest(manifests=manifests)
 
51
 
 
52
    # gather the tests
 
53
    tests = manifest.active_tests()
 
54
    unittestlist = []
 
55
    for test in tests:
 
56
        unittestlist.extend(unittests(test['path']))
 
57
 
 
58
    # run the tests
 
59
    suite = unittest.TestSuite(unittestlist)
 
60
    runner = unittest.TextTestRunner()
 
61
    results = runner.run(suite)
 
62
 
 
63
    # exit according to results
 
64
    sys.exit((results.failures or results.errors) and 1 or 0)
 
65
 
 
66
if __name__ == '__main__':
 
67
    main()