Bug 818646 - Add mozbuild Python tests to |make check|; r=ted
authorGregory Szorc <gps@mozilla.com>
Fri, 21 Dec 2012 12:43:46 -0800
changeset 117936 d4f37aa65d0959eaca8860afbcb5f4d85106a7d0
parent 117935 fac2900af6a0758238779dec26da036159b657be
child 117937 dbde4d3de84d022543925b7984972ed03ca4bd96
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersted
bugs818646
milestone20.0a1
Bug 818646 - Add mozbuild Python tests to |make check|; r=ted
Makefile.in
allmakefiles.sh
build/virtualenv/packages.txt
python/Makefile.in
python/mozbuild/mozbuild/test/compilation/test_warnings.py
python/mozbuild/mozbuild/test/test_base.py
python/mozbuild/mozbuild/test/test_mozconfig.py
python/mozbuild/mozbuild/test/test_util.py
--- a/Makefile.in
+++ b/Makefile.in
@@ -26,16 +26,17 @@ TIERS += base
 #
 # tier "base" - basic setup
 #
 tier_base_dirs = \
   config \
   build \
   probes \
   mfbt \
+  python \
   $(NULL)
 
 ifndef LIBXUL_SDK
 ifeq (android,$(MOZ_WIDGET_TOOLKIT))
 tier_base_dirs += \
   other-licenses/android \
   $(NULL)
 endif
--- a/allmakefiles.sh
+++ b/allmakefiles.sh
@@ -33,16 +33,17 @@ build/pgo/blueprint/Makefile
 build/pgo/js-input/Makefile
 config/Makefile
 config/autoconf.mk
 config/nspr/Makefile
 config/doxygen.cfg
 config/expandlibs_config.py
 mfbt/Makefile
 probes/Makefile
+python/Makefile
 extensions/Makefile
 "
 
 if [ "$MOZ_WEBAPP_RUNTIME" ]; then
   add_makefiles "
 webapprt/Makefile
   "
 fi
--- a/build/virtualenv/packages.txt
+++ b/build/virtualenv/packages.txt
@@ -7,16 +7,17 @@ mozhttpd.pth:testing/mozbase/mozhttpd
 mozinfo.pth:testing/mozbase/mozinfo
 mozinstall.pth:testing/mozbase/mozinstall
 mozlog.pth:testing/mozbase/mozlog
 mozprocess.pth:testing/mozbase/mozprocess
 mozprofile.pth:testing/mozbase/mozprofile
 mozrunner.pth:testing/mozbase/mozrunner
 marionette.pth:testing/marionette/client
 blessings.pth:python/blessings
+mach.pth:python/mach
 mozbuild.pth:python/mozbuild
 pymake.pth:build/pymake
 optional:setup.py:python/psutil:build_ext:--inplace
 optional:psutil.pth:python/psutil
 which.pth:python/which
 mock.pth:python/mock-1.0.0
 mozilla.pth:build
 mozilla.pth:config
new file mode 100644
--- /dev/null
+++ b/python/Makefile.in
@@ -0,0 +1,21 @@
+# 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/.
+
+DEPTH := @DEPTH@
+topsrcdir := @top_srcdir@
+srcdir := @srcdir@
+VPATH = @srcdir@
+
+include $(DEPTH)/config/autoconf.mk
+
+test_dirs := \
+  mozbuild/mozbuild/test \
+  mozbuild/mozbuild/test/compilation \
+  $(NULL)
+
+PYTHON_UNIT_TESTS := $(foreach dir,$(test_dirs),$(wildcard $(srcdir)/$(dir)/*.py))
+
+include $(topsrcdir)/config/rules.mk
+
+
--- a/python/mozbuild/mozbuild/test/compilation/test_warnings.py
+++ b/python/mozbuild/mozbuild/test/compilation/test_warnings.py
@@ -6,16 +6,17 @@ import os
 import unittest
 
 from mozfile.mozfile import NamedTemporaryFile
 
 from mozbuild.compilation.warnings import CompilerWarning
 from mozbuild.compilation.warnings import WarningsCollector
 from mozbuild.compilation.warnings import WarningsDatabase
 
+from mozunit import main
 
 CLANG_TESTS = [
     ('foobar.cpp:123:10: warning: you messed up [-Wfoo]',
      'foobar.cpp', 123, 10, 'you messed up', '-Wfoo')
 ]
 
 MSVC_TESTS = [
     ("C:/mozilla-central/test/foo.cpp(793) : warning C4244: 'return' : "
@@ -133,17 +134,17 @@ class TestWarningsParsing(unittest.TestC
 
     def test_msvc_parsing(self):
         for source, filename, line, flag, message in MSVC_TESTS:
             collector = WarningsCollector(resolve_files=False)
             warning = collector.process_line(source)
 
             self.assertIsNotNone(warning)
 
-            self.assertEqual(warning['filename'], filename)
+            self.assertEqual(warning['filename'], os.path.normpath(filename))
             self.assertEqual(warning['line'], line)
             self.assertEqual(warning['flag'], flag)
             self.assertEqual(warning['message'], message)
 
 class TestWarningsDatabase(unittest.TestCase):
     def test_basic(self):
         db = WarningsDatabase()
 
@@ -226,8 +227,11 @@ class TestWarningsDatabase(unittest.Test
         old_filename = source_files[0].name
         del source_files[0]
 
         self.assertFalse(os.path.exists(old_filename))
 
         db.prune()
         self.assertEqual(len(db), 19)
 
+
+if __name__ == '__main__':
+    main()
--- a/python/mozbuild/mozbuild/test/test_base.py
+++ b/python/mozbuild/mozbuild/test/test_base.py
@@ -4,24 +4,27 @@
 
 from __future__ import unicode_literals
 
 import os
 import unittest
 
 from mozfile.mozfile import NamedTemporaryFile
 
+from mozunit import main
+
 from mach.logging import LoggingManager
 
 from mozbuild.base import (
     BuildConfig,
     MozbuildObject,
 )
 
 
+
 curdir = os.path.dirname(__file__)
 topsrcdir = os.path.normpath(os.path.join(curdir, '..', '..', '..', '..'))
 log_manager = LoggingManager()
 
 
 class TestMozbuildObject(unittest.TestCase):
     def get_base(self):
         return MozbuildObject(topsrcdir, None, log_manager)
@@ -42,8 +45,11 @@ class TestMozbuildObject(unittest.TestCa
         # It's difficult to test for exact values from the output of
         # config.guess because they vary depending on platform.
         base = self.get_base()
         result = base._config_guess
 
         self.assertIsNotNone(result)
         self.assertGreater(len(result), 0)
 
+
+if __name__ == '__main__':
+    main()
--- a/python/mozbuild/mozbuild/test/test_mozconfig.py
+++ b/python/mozbuild/mozbuild/test/test_mozconfig.py
@@ -11,16 +11,18 @@ from shutil import rmtree
 
 from tempfile import (
     gettempdir,
     mkdtemp,
 )
 
 from mozfile.mozfile import NamedTemporaryFile
 
+from mozunit import main
+
 from mozbuild.mozconfig import (
     MozconfigFindException,
     MozconfigLoadException,
     MozconfigLoader,
 )
 
 
 class TestMozconfigLoader(unittest.TestCase):
@@ -310,8 +312,11 @@ class TestMozconfigLoader(unittest.TestC
                 self.get_loader().read_mozconfig(mozconfig.name)
 
             self.assertTrue(e.exception.message.startswith(
                 'Evaluation of your mozconfig exited with an error'))
             self.assertEquals(e.exception.path,
                 mozconfig.name.replace(os.sep, '/'))
             self.assertEquals(e.exception.output, ['hello world'])
 
+
+if __name__ == '__main__':
+    main()
--- a/python/mozbuild/mozbuild/test/test_util.py
+++ b/python/mozbuild/mozbuild/test/test_util.py
@@ -3,16 +3,17 @@
 # You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from __future__ import unicode_literals
 
 import hashlib
 import unittest
 
 from mozfile.mozfile import NamedTemporaryFile
+from mozunit import main
 
 from mozbuild.util import hash_file
 
 
 class TestHashing(unittest.TestCase):
     def test_hash_file_known_hash(self):
         """Ensure a known hash value is recreated."""
         data = b'The quick brown fox jumps over the lazy cog'
@@ -37,8 +38,11 @@ class TestHashing(unittest.TestCase):
         temp = NamedTemporaryFile()
         temp.write(data)
         temp.flush()
 
         actual = hash_file(temp.name)
 
         self.assertEqual(actual, expected)
 
+
+if __name__ == '__main__':
+    main()