1 """Tests for distutils.unixccompiler."""
5 from distutils
import sysconfig
6 from distutils
.unixccompiler
import UnixCCompiler
8 class UnixCCompilerTestCase(unittest
.TestCase
):
11 self
._backup
_platform
= sys
.platform
12 self
._backup
_get
_config
_var
= sysconfig
.get_config_var
13 class CompilerWrapper(UnixCCompiler
):
15 return self
.runtime_library_dir_option('/foo')
16 self
.cc
= CompilerWrapper()
19 sys
.platform
= self
._backup
_platform
20 sysconfig
.get_config_var
= self
._backup
_get
_config
_var
22 def test_runtime_libdir_option(self
):
24 # not tested under windows
25 if sys
.platform
== 'win32':
30 # Ensure RUNPATH is added to extension modules with RPATH if
34 sys
.platform
= 'darwin'
35 self
.assertEqual(self
.cc
.rpath_foo(), '-L/foo')
38 sys
.platform
= 'hp-ux'
39 old_gcv
= sysconfig
.get_config_var
42 sysconfig
.get_config_var
= gcv
43 self
.assertEqual(self
.cc
.rpath_foo(), ['+s', '-L/foo'])
47 sysconfig
.get_config_var
= gcv
48 self
.assertEqual(self
.cc
.rpath_foo(), ['-Wl,+s', '-L/foo'])
52 sysconfig
.get_config_var
= gcv
53 self
.assertEqual(self
.cc
.rpath_foo(), ['-Wl,+s', '-L/foo'])
55 sysconfig
.get_config_var
= old_gcv
58 sys
.platform
= 'irix646'
59 self
.assertEqual(self
.cc
.rpath_foo(), ['-rpath', '/foo'])
62 sys
.platform
= 'osf1V5'
63 self
.assertEqual(self
.cc
.rpath_foo(), ['-rpath', '/foo'])
72 sysconfig
.get_config_var
= gcv
73 self
.assertEqual(self
.cc
.rpath_foo(), '-Wl,--enable-new-dtags,-R/foo')
82 sysconfig
.get_config_var
= gcv
83 self
.assertEqual(self
.cc
.rpath_foo(), '-Wl,-R/foo')
85 # GCC GNULD with fully qualified configuration prefix
90 return 'x86_64-pc-linux-gnu-gcc-4.4.2'
93 sysconfig
.get_config_var
= gcv
94 self
.assertEqual(self
.cc
.rpath_foo(), '-Wl,--enable-new-dtags,-R/foo')
104 sysconfig
.get_config_var
= gcv
105 self
.assertEqual(self
.cc
.rpath_foo(), '-R/foo')
114 sysconfig
.get_config_var
= gcv
115 self
.assertEqual(self
.cc
.rpath_foo(), '-R/foo')
121 sysconfig
.get_config_var
= gcv
122 self
.assertEqual(self
.cc
.rpath_foo(), '-blibpath:/foo')
126 return unittest
.makeSuite(UnixCCompilerTestCase
)
128 if __name__
== "__main__":
129 unittest
.main(defaultTest
="test_suite")