blob: f25f23b1ae72478e0e4eaa922b5bfd68d469fe45 [file] [log] [blame]
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001#!/usr/bin/env python3
Patrick Williamsc124f4f2015-09-15 14:41:29 -05002#
3# Copyright (C) 2012 Richard Purdie
4#
Brad Bishopc342db32019-05-15 21:57:59 -04005# SPDX-License-Identifier: GPL-2.0-only
Patrick Williamsc124f4f2015-09-15 14:41:29 -05006#
Patrick Williamsc124f4f2015-09-15 14:41:29 -05007
8import os
9import sys, logging
Andrew Geissler5199d832021-09-24 16:47:35 -050010import warnings
11warnings.simplefilter("default")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050012sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(__file__)), 'lib'))
13
14import unittest
15try:
16 import bb
Brad Bishop19323692019-04-05 15:28:33 -040017 import hashserv
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080018 import layerindexlib
Patrick Williamsc124f4f2015-09-15 14:41:29 -050019except RuntimeError as exc:
20 sys.exit(str(exc))
21
Patrick Williamsc0f7c042017-02-23 20:41:17 -060022tests = ["bb.tests.codeparser",
Andrew Geissler635e0e42020-08-21 15:58:33 -050023 "bb.tests.color",
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080024 "bb.tests.cooker",
Patrick Williamsc0f7c042017-02-23 20:41:17 -060025 "bb.tests.cow",
26 "bb.tests.data",
Brad Bishopd7bf8c12018-02-25 22:55:05 -050027 "bb.tests.event",
Patrick Williamsc0f7c042017-02-23 20:41:17 -060028 "bb.tests.fetch",
29 "bb.tests.parse",
Brad Bishop19323692019-04-05 15:28:33 -040030 "bb.tests.persist_data",
Brad Bishop96ff1982019-08-19 13:50:42 -040031 "bb.tests.runqueue",
Andrew Geisslerc3d88e42020-10-02 09:45:00 -050032 "bb.tests.siggen",
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080033 "bb.tests.utils",
Andrew Geissler5f350902021-07-23 13:09:54 -040034 "bb.tests.compression",
Brad Bishop19323692019-04-05 15:28:33 -040035 "hashserv.tests",
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080036 "layerindexlib.tests.layerindexobj",
37 "layerindexlib.tests.restapi",
38 "layerindexlib.tests.cooker"]
Patrick Williamsc124f4f2015-09-15 14:41:29 -050039
40for t in tests:
41 t = '.'.join(t.split('.')[:3])
42 __import__(t)
43
Patrick Williamsc124f4f2015-09-15 14:41:29 -050044
Patrick Williamsc0f7c042017-02-23 20:41:17 -060045# Set-up logging
46class StdoutStreamHandler(logging.StreamHandler):
47 """Special handler so that unittest is able to capture stdout"""
48 def __init__(self):
49 # Override __init__() because we don't want to set self.stream here
50 logging.Handler.__init__(self)
51
52 @property
53 def stream(self):
54 # We want to dynamically write wherever sys.stdout is pointing to
55 return sys.stdout
56
57
58handler = StdoutStreamHandler()
59bb.logger.addHandler(handler)
60bb.logger.setLevel(logging.DEBUG)
61
62
63ENV_HELP = """\
64Environment variables:
65 BB_SKIP_NETTESTS set to 'yes' in order to skip tests using network
66 connection
67 BB_TMPDIR_NOCLEAN set to 'yes' to preserve test tmp directories
68"""
69
70class main(unittest.main):
71 def _print_help(self, *args, **kwargs):
72 super(main, self)._print_help(*args, **kwargs)
73 print(ENV_HELP)
74
75
76if __name__ == '__main__':
77 main(defaultTest=tests, buffer=True)