Bug 1270446 - Automatically add --target argument when unit test class has a TARGET attribute. r?chmanchester draft
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 22 Apr 2016 16:30:09 +0900
changeset 363770 a3026d748faffab35e076dbd2f110d97aea12409
parent 363769 4683e524cf4b9afca71f47679be8c3b443fd0f36
child 520118 440583834bf892f8657b5ace33d012479da5d2eb
push id17288
push userbmo:mh+mozilla@glandium.org
push dateThu, 05 May 2016 11:06:21 +0000
reviewerschmanchester
bugs1270446
milestone49.0a1
Bug 1270446 - Automatically add --target argument when unit test class has a TARGET attribute. r?chmanchester
python/mozbuild/mozbuild/test/configure/common.py
python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py
--- a/python/mozbuild/mozbuild/test/configure/common.py
+++ b/python/mozbuild/mozbuild/test/configure/common.py
@@ -171,16 +171,21 @@ class BaseConfigureTest(unittest.TestCas
         if logger:
             kwargs['logger'] = logger
         else:
             if not out:
                 out = StringIO()
             kwargs['stdout'] = out
             kwargs['stderr'] = out
 
+        if hasattr(self, 'TARGET'):
+            target = ['--target=%s' % self.TARGET]
+        else:
+            target = []
+
         if mozconfig:
             fh, mozconfig_path = tempfile.mkstemp()
             os.write(fh, mozconfig)
             os.close(fh)
         else:
             mozconfig_path = os.path.join(os.path.dirname(__file__), 'data',
                                           'empty_mozconfig')
 
@@ -192,15 +197,16 @@ class BaseConfigureTest(unittest.TestCas
 
             paths = dict(paths)
             autoconf_dir = mozpath.join(topsrcdir, 'build', 'autoconf')
             paths[mozpath.join(autoconf_dir,
                                'config.guess')] = self.config_guess
             paths[mozpath.join(autoconf_dir, 'config.sub')] = self.config_sub
 
             sandbox = ConfigureTestSandbox(paths, config, environ,
-                                           ['configure'] + args, **kwargs)
+                                           ['configure'] + target + args,
+                                           **kwargs)
             sandbox.include_file(os.path.join(topsrcdir, 'moz.configure'))
 
             return sandbox
         finally:
             if mozconfig:
                 os.remove(mozconfig_path)
--- a/python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py
+++ b/python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py
@@ -659,16 +659,17 @@ class WindowsToolchainTest(BaseToolchain
             'cxx_compiler': self.CLANGXX_3_3_RESULT,
         }, environ={
             'CC': 'clang-3.3',
             'CXX': 'clang++-3.3',
         })
 
 
 class CrossCompileToolchainTest(BaseToolchainTest):
+    TARGET = 'arm-unknown-linux-gnu'
     PATHS = {
         '/usr/bin/arm-linux-gnu-gcc': GCC_4_9,
         '/usr/bin/arm-linux-gnu-g++': GXX_4_9,
         '/usr/bin/arm-linux-gnu-gcc-4.7': GCC_4_7,
         '/usr/bin/arm-linux-gnu-g++-4.7': GXX_4_7,
         '/usr/bin/arm-linux-gnu-gcc-5': GCC_5,
         '/usr/bin/arm-linux-gnu-g++-5': GXX_5,
     }
@@ -690,64 +691,64 @@ class CrossCompileToolchainTest(BaseTool
             'c_compiler': self.GCC_4_9_RESULT + {
                 'compiler': '/usr/bin/arm-linux-gnu-gcc',
             },
             'cxx_compiler': self.GXX_4_9_RESULT + {
                 'compiler': '/usr/bin/arm-linux-gnu-g++',
             },
             'host_c_compiler': self.GCC_4_9_RESULT,
             'host_cxx_compiler': self.GXX_4_9_RESULT,
-        }, args=['--target=arm-unknown-linux-gnu'])
+        })
 
     def test_overridden_cross_gcc(self):
         self.do_toolchain_test(self.PATHS, {
             'c_compiler': self.ARM_GCC_5_RESULT,
             'cxx_compiler': self.ARM_GXX_5_RESULT,
             'host_c_compiler': self.GCC_4_9_RESULT,
             'host_cxx_compiler': self.GXX_4_9_RESULT,
-        }, args=['--target=arm-unknown-linux-gnu'], environ={
+        }, environ={
             'CC': 'arm-linux-gnu-gcc-5',
             'CXX': 'arm-linux-gnu-g++-5',
         })
 
     def test_overridden_unsupported_cross_gcc(self):
         self.do_toolchain_test(self.PATHS, {
             'c_compiler': self.ARM_GCC_4_7_RESULT,
-        }, args=['--target=arm-unknown-linux-gnu'], environ={
+        }, environ={
             'CC': 'arm-linux-gnu-gcc-4.7',
             'CXX': 'arm-linux-gnu-g++-4.7',
         })
 
     def test_guess_cross_cxx(self):
         # When CXX is not set, we guess it from CC.
         self.do_toolchain_test(self.PATHS, {
             'c_compiler': self.ARM_GCC_5_RESULT,
             'cxx_compiler': self.ARM_GXX_5_RESULT,
             'host_c_compiler': self.GCC_4_9_RESULT,
             'host_cxx_compiler': self.GXX_4_9_RESULT,
-        }, args=['--target=arm-unknown-linux-gnu'], environ={
+        }, environ={
             'CC': 'arm-linux-gnu-gcc-5',
         })
 
         self.do_toolchain_test(self.PATHS, {
             'c_compiler': self.ARM_GCC_5_RESULT,
             'cxx_compiler': self.ARM_GXX_5_RESULT,
             'host_c_compiler': self.CLANG_3_6_RESULT,
             'host_cxx_compiler': self.CLANGXX_3_6_RESULT,
-        }, args=['--target=arm-unknown-linux-gnu'], environ={
+        }, environ={
             'CC': 'arm-linux-gnu-gcc-5',
             'HOST_CC': 'clang',
         })
 
         self.do_toolchain_test(self.PATHS, {
             'c_compiler': self.ARM_GCC_5_RESULT,
             'cxx_compiler': self.ARM_GXX_5_RESULT,
             'host_c_compiler': self.CLANG_3_6_RESULT,
             'host_cxx_compiler': self.CLANGXX_3_6_RESULT,
-        }, args=['--target=arm-unknown-linux-gnu'], environ={
+        }, environ={
             'CC': 'arm-linux-gnu-gcc-5',
             'CXX': 'arm-linux-gnu-g++-5',
             'HOST_CC': 'clang',
         })
 
 
 if __name__ == '__main__':
     main()