diff options
| author | Tarek Ziade <tarek@ziade.org> | 2010-11-11 17:51:58 +0100 |
|---|---|---|
| committer | Tarek Ziade <tarek@ziade.org> | 2010-11-11 17:51:58 +0100 |
| commit | 9b3dde4072db4356e4a08614e7b266f11a05554d (patch) | |
| tree | 81e93154eddae10e4fcf481a62152701f6aae7cd /distutils2/tests | |
| parent | cb7b234fa42bb5f66c4c004c46fbf89ccee78791 (diff) | |
| download | disutils2-9b3dde4072db4356e4a08614e7b266f11a05554d.tar.gz | |
moved general functions out of ccompiler
Diffstat (limited to 'distutils2/tests')
| -rw-r--r-- | distutils2/tests/test_ccompiler.py | 48 | ||||
| -rw-r--r-- | distutils2/tests/test_command_build_clib.py | 2 | ||||
| -rw-r--r-- | distutils2/tests/test_compiler.py | 62 |
3 files changed, 65 insertions, 47 deletions
diff --git a/distutils2/tests/test_ccompiler.py b/distutils2/tests/test_ccompiler.py index 3ca5217..c7454fb 100644 --- a/distutils2/tests/test_ccompiler.py +++ b/distutils2/tests/test_ccompiler.py @@ -1,56 +1,12 @@ """Tests for distutils.ccompiler.""" -import os -from distutils2.tests import captured_stdout - -from distutils2.compiler.ccompiler import (gen_lib_options, CCompiler, - get_default_compiler, customize_compiler) +from distutils2.compiler.ccompiler import CCompiler 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 CCompilerTestCase(support.EnvironGuard, unittest.TestCase): - 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_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 + pass # XXX need some tests on CCompiler - comp = compiler() - customize_compiler(comp) - self.assertEqual(comp.exes['archiver'], 'my_ar -arflags') def test_suite(): return unittest.makeSuite(CCompilerTestCase) diff --git a/distutils2/tests/test_command_build_clib.py b/distutils2/tests/test_command_build_clib.py index a8557f4..b71cf5e 100644 --- a/distutils2/tests/test_command_build_clib.py +++ b/distutils2/tests/test_command_build_clib.py @@ -119,7 +119,7 @@ class BuildCLibTestCase(support.TempdirManager, # before we run the command, we want to make sure # all commands are present on the system # by creating a compiler and checking its executables - from distutils2.compiler.ccompiler import new_compiler, customize_compiler + from distutils2.compiler import new_compiler, customize_compiler compiler = new_compiler() customize_compiler(compiler) 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") |
