blob: e7562cb7971136c465e132b8c53b17104b892228 [file] [log] [blame]
Ben Murdoch097c5b22016-05-18 11:27:45 +01001#!/usr/bin/env python
2
3# Copyright (c) 2012 Google Inc. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7"""
8Runs small tests.
9"""
10
11import imp
12import os
13import sys
14import unittest
15
16import TestGyp
17
18
19test = TestGyp.TestGyp()
20
21# Add pylib to the import path (so tests can import their dependencies).
22# This is consistant with the path.append done in the top file "gyp".
23sys.path.insert(0, os.path.join(test._cwd, 'pylib'))
24
25# Add new test suites here.
26files_to_test = [
27 'pylib/gyp/MSVSSettings_test.py',
28 'pylib/gyp/easy_xml_test.py',
29 'pylib/gyp/generator/msvs_test.py',
30 'pylib/gyp/generator/ninja_test.py',
31 'pylib/gyp/generator/xcode_test.py',
32 'pylib/gyp/common_test.py',
33 'pylib/gyp/input_test.py',
34]
35
36# Collect all the suites from the above files.
37suites = []
38for filename in files_to_test:
39 # Carve the module name out of the path.
40 name = os.path.splitext(os.path.split(filename)[1])[0]
41 # Find the complete module path.
42 full_filename = os.path.join(test._cwd, filename)
43 # Load the module.
44 module = imp.load_source(name, full_filename)
45 # Add it to the list of test suites.
46 suites.append(unittest.defaultTestLoader.loadTestsFromModule(module))
47# Create combined suite.
48all_tests = unittest.TestSuite(suites)
49
50# Run all the tests.
51result = unittest.TextTestRunner(verbosity=2).run(all_tests)
52if result.failures or result.errors:
53 test.fail_test()
54
55test.pass_test()