2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
6 """Runs all tests in all unit test modules in this directory."""
13 SRC
= os
.path
.join(os
.path
.dirname(__file__
), os
.path
.pardir
, os
.path
.pardir
)
17 if 'full-log' in sys
.argv
:
18 # Configure logging to show line numbers and logging level
19 fmt
= '%(module)s:%(lineno)d - %(levelname)s: %(message)s'
20 logging
.basicConfig(level
=logging
.DEBUG
, stream
=sys
.stdout
, format
=fmt
)
21 elif 'no-log' in sys
.argv
:
22 # Only WARN and above are shown, to standard error. (This is the logging
23 # module default config, hence we do nothing here)
26 # Behave as before. Make logging.info mimic print behavior
28 logging
.basicConfig(level
=logging
.INFO
, stream
=sys
.stdout
, format
=fmt
)
30 # Running the tests depends on having the below modules in PYTHONPATH.
31 sys
.path
.append(os
.path
.join(SRC
, 'tools', 'telemetry'))
32 sys
.path
.append(os
.path
.join(SRC
, 'third_party', 'pymock'))
34 suite
= unittest
.TestSuite()
35 loader
= unittest
.TestLoader()
36 script_dir
= os
.path
.dirname(__file__
)
37 suite
.addTests(loader
.discover(start_dir
=script_dir
, pattern
='*_test.py'))
39 print 'Running unit tests in %s...' % os
.path
.abspath(script_dir
)
40 result
= unittest
.TextTestRunner(verbosity
=1).run(suite
)
41 return 0 if result
.wasSuccessful() else 1
44 if __name__
== '__main__':