From 696d8e1c293c02472acf3e540f5a56a7c119bb63 Mon Sep 17 00:00:00 2001 From: Gregory Szorc Date: Thu, 9 Jan 2014 11:20:41 -0800 Subject: [PATCH] Bug 909522 - Run mach's unit tests as part of make check; r=mshal test_entry_point.py is not enabled because the test fails. This is tracked by bug 958196. --HG-- extra : rebase_source : 1f326a9bbd7ee0e8e12ff33f49d8484cc244c42d --- python/Makefile.in | 1 + python/mach/mach/test/providers/__init__.py | 0 python/mach/mach/test/test_conditions.py | 10 +++++++--- python/mach/mach/test/test_config.py | 6 ++++++ python/mach/mach/test/test_entry_point.py | 8 ++++++++ python/mach/mach/test/test_error_output.py | 13 ++++++------- python/mach/mach/test/test_logger.py | 5 ++++- 7 files changed, 32 insertions(+), 11 deletions(-) create mode 100644 python/mach/mach/test/providers/__init__.py diff --git a/python/Makefile.in b/python/Makefile.in index 8ab358cddd5a..1ac2776e46a9 100644 --- a/python/Makefile.in +++ b/python/Makefile.in @@ -3,6 +3,7 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. test_dirs := \ + mach/mach/test \ mozbuild/mozbuild/test \ mozbuild/mozbuild/test/action \ mozbuild/mozbuild/test/backend \ diff --git a/python/mach/mach/test/providers/__init__.py b/python/mach/mach/test/providers/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/python/mach/mach/test/test_conditions.py b/python/mach/mach/test/test_conditions.py index c5126cd382a3..888537d2edbb 100644 --- a/python/mach/mach/test/test_conditions.py +++ b/python/mach/mach/test/test_conditions.py @@ -5,14 +5,14 @@ from __future__ import unicode_literals import os -import unittest - -from StringIO import StringIO from mach.base import MachError from mach.main import Mach from mach.test.common import TestBase +from mozunit import main + + def _populate_context(context): context.foo = True context.bar = False @@ -71,3 +71,7 @@ class TestConditions(TestBase): self.assertIn('cmd_foo_ctx', stdout) self.assertNotIn('cmd_bar_ctx', stdout) self.assertNotIn('cmd_foobar_ctx', stdout) + + +if __name__ == '__main__': + main() diff --git a/python/mach/mach/test/test_config.py b/python/mach/mach/test/test_config.py index ef89367f2fdb..cebd47a7d6c8 100644 --- a/python/mach/mach/test/test_config.py +++ b/python/mach/mach/test/test_config.py @@ -20,6 +20,8 @@ from mach.config import ( StringType, ) +from mozunit import main + if sys.version_info[0] == 3: str_type = str @@ -256,3 +258,7 @@ class TestConfigSettings(unittest.TestCase): temp = NamedTemporaryFile('wt') s.write_pot(temp) temp.flush() + + +if __name__ == '__main__': + main() diff --git a/python/mach/mach/test/test_entry_point.py b/python/mach/mach/test/test_entry_point.py index 803732e37fba..5bd2c279d45c 100644 --- a/python/mach/mach/test/test_entry_point.py +++ b/python/mach/mach/test/test_entry_point.py @@ -11,6 +11,9 @@ from mach.base import MachError from mach.test.common import TestBase from mock import patch +from mozunit import main + + here = os.path.abspath(os.path.dirname(__file__)) class Entry(): @@ -50,3 +53,8 @@ class TestEntryPoints(TestBase): result, stdout, stderr = self._run_mach() self.assertIsNone(result) self.assertIn('cmd_foo', stdout) + + +# Not enabled in automation because tests are failing. +#if __name__ == '__main__': +# main() diff --git a/python/mach/mach/test/test_error_output.py b/python/mach/mach/test/test_error_output.py index 01e3565e6931..25553f96bc41 100644 --- a/python/mach/mach/test/test_error_output.py +++ b/python/mach/mach/test/test_error_output.py @@ -4,19 +4,14 @@ from __future__ import unicode_literals -import imp -import os -import sys -import unittest - -from StringIO import StringIO - from mach.main import ( COMMAND_ERROR, MODULE_ERROR ) from mach.test.common import TestBase +from mozunit import main + class TestErrorOutput(TestBase): @@ -38,3 +33,7 @@ class TestErrorOutput(TestBase): self.assertEqual(result, 1) self.assertIn(MODULE_ERROR, stdout) + + +if __name__ == '__main__': + main() diff --git a/python/mach/mach/test/test_logger.py b/python/mach/mach/test/test_logger.py index 78dd9b91c6f7..05592845e7fa 100644 --- a/python/mach/mach/test/test_logger.py +++ b/python/mach/mach/test/test_logger.py @@ -10,6 +10,8 @@ import unittest from mach.logging import StructuredHumanFormatter +from mozunit import main + class DummyLogger(logging.Logger): def __init__(self, cb): @@ -41,4 +43,5 @@ class TestStructuredHumanFormatter(unittest.TestCase): extra={'action': 'action', 'params': {'utf': value}}) - +if __name__ == '__main__': + main()