summaryrefslogtreecommitdiff
path: root/distutils2/tests/test_compiler.py
diff options
context:
space:
mode:
authorTarek Ziade <tarek@ziade.org>2010-11-11 17:51:58 +0100
committerTarek Ziade <tarek@ziade.org>2010-11-11 17:51:58 +0100
commit9b3dde4072db4356e4a08614e7b266f11a05554d (patch)
tree81e93154eddae10e4fcf481a62152701f6aae7cd /distutils2/tests/test_compiler.py
parentcb7b234fa42bb5f66c4c004c46fbf89ccee78791 (diff)
downloaddisutils2-9b3dde4072db4356e4a08614e7b266f11a05554d.tar.gz
moved general functions out of ccompiler
Diffstat (limited to 'distutils2/tests/test_compiler.py')
-rw-r--r--distutils2/tests/test_compiler.py62
1 files changed, 62 insertions, 0 deletions
diff --git a/distutils2/tests/test_compiler.py b/distutils2/tests/test_compiler.py
new file mode 100644
index 0000000..2ea9e13
--- /dev/null
+++ b/distutils2/tests/test_compiler.py
@@ -0,0 +1,62 @@
+"""Tests for distutils.compiler."""
+import os
+
+from distutils2.compiler import (get_default_compiler, customize_compiler,
+ gen_lib_options)
+from distutils2.tests import unittest, support
+
+
+class FakeCompiler(object):
+ def library_dir_option(self, dir):
+ return "-L" + dir
+
+ def runtime_library_dir_option(self, dir):
+ return ["-cool", "-R" + dir]
+
+ def find_library_file(self, dirs, lib, debug=0):
+ return 'found'
+
+ def library_option(self, lib):
+ return "-l" + lib
+
+
+class CompilerTestCase(support.EnvironGuard, unittest.TestCase):
+
+ def test_customize_compiler(self):
+
+ # not testing if default compiler is not unix
+ if get_default_compiler() != 'unix':
+ return
+
+ os.environ['AR'] = 'my_ar'
+ os.environ['ARFLAGS'] = '-arflags'
+
+ # make sure AR gets caught
+ class compiler:
+ compiler_type = 'unix'
+
+ def set_executables(self, **kw):
+ self.exes = kw
+
+ comp = compiler()
+ customize_compiler(comp)
+ self.assertEqual(comp.exes['archiver'], 'my_ar -arflags')
+
+ def test_gen_lib_options(self):
+ compiler = FakeCompiler()
+ libdirs = ['lib1', 'lib2']
+ runlibdirs = ['runlib1']
+ libs = [os.path.join('dir', 'name'), 'name2']
+
+ opts = gen_lib_options(compiler, libdirs, runlibdirs, libs)
+ wanted = ['-Llib1', '-Llib2', '-cool', '-Rrunlib1', 'found',
+ '-lname2']
+ self.assertEqual(opts, wanted)
+
+
+def test_suite():
+ return unittest.makeSuite(CompilerTestCase)
+
+
+if __name__ == "__main__":
+ unittest.main(defaultTest="test_suite")