Bug 909522 - Run mach's unit tests as part of make check; r=mshal
authorGregory Szorc <gps@mozilla.com>
Thu, 09 Jan 2014 11:20:41 -0800
changeset 162966 656e14ae93635886e0ac22cd889d73a175ca3d12
parent 162965 803536e9aac225d129d6ab431d74a3ab73e40f78
child 162967 f6e3cd08cb6edf166047a03e65f9c6bd39930a63
push id25975
push userryanvm@gmail.com
push dateFri, 10 Jan 2014 19:46:47 +0000
treeherdermozilla-central@e89afc241513 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmshal
bugs909522, 958196
milestone29.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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.
python/Makefile.in
python/mach/mach/test/providers/__init__.py
python/mach/mach/test/test_conditions.py
python/mach/mach/test/test_config.py
python/mach/mach/test/test_entry_point.py
python/mach/mach/test/test_error_output.py
python/mach/mach/test/test_logger.py
--- a/python/Makefile.in
+++ b/python/Makefile.in
@@ -1,13 +1,14 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # 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 \
   mozbuild/mozbuild/test/controller \
   mozbuild/mozbuild/test/compilation \
   mozbuild/mozbuild/test/frontend \
   mozbuild/mozpack/test \
   mozbuild/dumbmake/test \
new file mode 100644
--- a/python/mach/mach/test/test_conditions.py
+++ b/python/mach/mach/test/test_conditions.py
@@ -1,23 +1,23 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 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
 
 class TestConditions(TestBase):
     """Tests for conditionally filtering commands."""
 
     def _run_mach(self, args, context_handler=None):
@@ -66,8 +66,12 @@ class TestConditions(TestBase):
 
         result, stdout, stderr = self._run_mach(['help'], _populate_context)
         self.assertIn('cmd_foo', stdout)
         self.assertNotIn('cmd_bar', stdout)
         self.assertNotIn('cmd_foobar', stdout)
         self.assertIn('cmd_foo_ctx', stdout)
         self.assertNotIn('cmd_bar_ctx', stdout)
         self.assertNotIn('cmd_foobar_ctx', stdout)
+
+
+if __name__ == '__main__':
+    main()
--- a/python/mach/mach/test/test_config.py
+++ b/python/mach/mach/test/test_config.py
@@ -15,16 +15,18 @@ from mach.config import (
     ConfigSettings,
     IntegerType,
     PathType,
     PositiveIntegerType,
     RelativePathType,
     StringType,
 )
 
+from mozunit import main
+
 
 if sys.version_info[0] == 3:
     str_type = str
 else:
     str_type = basestring
 
 CONFIG1 = r"""
 [foo]
@@ -251,8 +253,12 @@ class TestConfigSettings(unittest.TestCa
         s = ConfigSettings()
         s.register_provider(Provider1)
         s.register_provider(Provider2)
 
         # Just a basic sanity test.
         temp = NamedTemporaryFile('wt')
         s.write_pot(temp)
         temp.flush()
+
+
+if __name__ == '__main__':
+    main()
--- a/python/mach/mach/test/test_entry_point.py
+++ b/python/mach/mach/test/test_entry_point.py
@@ -6,16 +6,19 @@ from __future__ import unicode_literals
 import imp
 import os
 import sys
 
 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():
     """Stub replacement for pkg_resources.EntryPoint"""
     def __init__(self, providers):
         self.providers = providers
 
     def load(self):
@@ -45,8 +48,13 @@ class TestEntryPoints(TestBase):
 
     @patch('pkg_resources.iter_entry_points')
     def test_load_entry_point_from_file(self, mock):
         mock.return_value = [Entry([os.path.join('providers', 'basic.py')])]
 
         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()
--- a/python/mach/mach/test/test_error_output.py
+++ b/python/mach/mach/test/test_error_output.py
@@ -1,27 +1,22 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 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):
 
     def _run_mach(self, args):
         return TestBase._run_mach(self, args, 'throw.py')
 
     def test_command_error(self):
         result, stdout, stderr = self._run_mach(['throw', '--message',
@@ -33,8 +28,12 @@ class TestErrorOutput(TestBase):
 
     def test_invoked_error(self):
         result, stdout, stderr = self._run_mach(['throw_deep', '--message',
             'Deep stack'])
 
         self.assertEqual(result, 1)
 
         self.assertIn(MODULE_ERROR, stdout)
+
+
+if __name__ == '__main__':
+    main()
--- a/python/mach/mach/test/test_logger.py
+++ b/python/mach/mach/test/test_logger.py
@@ -5,16 +5,18 @@
 from __future__ import absolute_import, unicode_literals
 
 import logging
 import time
 import unittest
 
 from mach.logging import StructuredHumanFormatter
 
+from mozunit import main
+
 
 class DummyLogger(logging.Logger):
     def __init__(self, cb):
         logging.Logger.__init__(self, 'test')
 
         self._cb = cb
 
     def handle(self, record):
@@ -36,9 +38,10 @@ class TestStructuredHumanFormatter(unitt
         logger = DummyLogger(on_record)
 
         value = 's\xe9curit\xe9'
 
         logger.log(logging.INFO, 'Test: {utf}',
             extra={'action': 'action', 'params': {'utf': value}})
 
 
-
+if __name__ == '__main__':
+    main()