Bug 1383996 - Make most calls to `mach artifact toolchain` output a manifest. r=gps
[gecko.git] / testing / mozharness / test / test_mozilla_buildbot.py
blobafc71502675f0d4f648f7f913b9e192716901aac
1 import gc
2 import unittest
5 import mozharness.base.log as log
6 from mozharness.base.log import ERROR
7 import mozharness.base.script as script
8 from mozharness.mozilla.buildbot import BuildbotMixin, TBPL_SUCCESS, \
9 TBPL_FAILURE, EXIT_STATUS_DICT
12 class CleanupObj(script.ScriptMixin, log.LogMixin):
13 def __init__(self):
14 super(CleanupObj, self).__init__()
15 self.log_obj = None
16 self.config = {'log_level': ERROR}
19 def cleanup():
20 gc.collect()
21 c = CleanupObj()
22 for f in ('test_logs', 'test_dir', 'tmpfile_stdout', 'tmpfile_stderr'):
23 c.rmtree(f)
26 class BuildbotScript(BuildbotMixin, script.BaseScript):
27 def __init__(self, **kwargs):
28 super(BuildbotScript, self).__init__(**kwargs)
31 # TestBuildbotStatus {{{1
32 class TestBuildbotStatus(unittest.TestCase):
33 # I need a log watcher helper function, here and in test_log.
34 def setUp(self):
35 cleanup()
36 self.s = None
38 def tearDown(self):
39 # Close the logfile handles, or windows can't remove the logs
40 if hasattr(self, 's') and isinstance(self.s, object):
41 del(self.s)
42 cleanup()
44 def test_over_max_log_size(self):
45 self.s = BuildbotScript(config={'log_type': 'multi',
46 'buildbot_max_log_size': 200},
47 initial_config_file='test/test.json')
48 self.s.info("foo!")
49 self.s.buildbot_status(TBPL_SUCCESS)
50 self.assertEqual(self.s.return_code, EXIT_STATUS_DICT[TBPL_FAILURE])
52 def test_under_max_log_size(self):
53 self.s = BuildbotScript(config={'log_type': 'multi',
54 'buildbot_max_log_size': 20000},
55 initial_config_file='test/test.json')
56 self.s.info("foo!")
57 self.s.buildbot_status(TBPL_SUCCESS)
58 self.assertEqual(self.s.return_code, EXIT_STATUS_DICT[TBPL_SUCCESS])
60 # main {{{1
61 if __name__ == '__main__':
62 unittest.main()