Back to index

enigmail  1.4.3
Public Member Functions | Public Attributes
unit-expandlibs.TestExpandArgsMore Class Reference
Inheritance diagram for unit-expandlibs.TestExpandArgsMore:
Inheritance graph
[legend]
Collaboration diagram for unit-expandlibs.TestExpandArgsMore:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def test_makelist
def test_extract
def init
def assertRelEqual
def cleanup
def touch
def tmpfile

Public Attributes

 libx_files
 liby_files
 arg_files
 files
 tmpdir

Detailed Description

Definition at line 194 of file unit-expandlibs.py.


Member Function Documentation

def unit-expandlibs.TestExpandInit.assertRelEqual (   self,
  args1,
  args2 
) [inherited]

Definition at line 172 of file unit-expandlibs.py.

00172 
00173     def assertRelEqual(self, args1, args2):
00174         self.assertEqual(args1, [relativize(a) for a in args2])

Here is the call graph for this function:

Here is the caller graph for this function:

def unit-expandlibs.TestCaseWithTmpDir.cleanup (   self) [inherited]

Definition at line 126 of file unit-expandlibs.py.

00126 
00127     def cleanup(self):
00128         rmtree(self.tmpdir)

def unit-expandlibs.TestExpandInit.init (   self) [inherited]
Initializes test environment for library expansion tests

Reimplemented from unit-expandlibs.TestCaseWithTmpDir.

Definition at line 149 of file unit-expandlibs.py.

00149 
00150     def init(self):
00151         ''' Initializes test environment for library expansion tests'''
00152         super(TestExpandInit, self).init()
00153         # Create 2 fake libraries, each containing 3 objects, and the second
00154         # including the first one and another library.
00155         os.mkdir(self.tmpfile('libx'))
00156         os.mkdir(self.tmpfile('liby'))
00157         self.libx_files = [self.tmpfile('libx', Obj(f)) for f in ['g', 'h', 'i']]
00158         self.liby_files = [self.tmpfile('liby', Obj(f)) for f in ['j', 'k', 'l']] + [self.tmpfile('liby', Lib('z'))]
00159         self.touch(self.libx_files + self.liby_files)
00160         with open(self.tmpfile('libx', Lib('x') + config.LIBS_DESC_SUFFIX), 'w') as f:
00161             f.write(str(generate(self.libx_files)))
00162         with open(self.tmpfile('liby', Lib('y') + config.LIBS_DESC_SUFFIX), 'w') as f:
00163             f.write(str(generate(self.liby_files + [self.tmpfile('libx', Lib('x'))])))
00164 
00165         # Create various objects and libraries 
00166         self.arg_files = [self.tmpfile(f) for f in [Lib('a'), Obj('b'), Obj('c'), Lib('d'), Obj('e')]]
00167         # We always give library names (LIB_PREFIX/SUFFIX), even for
00168         # dynamic/import libraries
00169         self.files = self.arg_files + [self.tmpfile(ImportLib('f'))]
00170         self.arg_files += [self.tmpfile(Lib('f'))]
00171         self.touch(self.files)

Here is the call graph for this function:

def unit-expandlibs.TestExpandArgsMore.test_extract (   self)
Test library extraction

Definition at line 226 of file unit-expandlibs.py.

00226 
00227     def test_extract(self):
00228         '''Test library extraction'''
00229         # Divert subprocess.call
00230         subprocess_call = subprocess.call
00231         extracted = {}
00232         def call(args, **kargs):
00233             # The command called is always AR_EXTRACT
00234             ar_extract = config.AR_EXTRACT.split()
00235             self.assertRelEqual(args[:len(ar_extract)], ar_extract)
00236             # Remaining argument is always one library
00237             self.assertRelEqual([os.path.splitext(arg)[1] for arg in args[len(ar_extract):]], [config.LIB_SUFFIX])
00238             # Simulate AR_EXTRACT extracting one object file for the library
00239             lib = os.path.splitext(os.path.basename(args[len(ar_extract)]))[0]
00240             extracted[lib] = os.path.join(kargs['cwd'], "%s" % Obj(lib))
00241             self.touch([extracted[lib]])
00242         subprocess.call = call
00243 
00244         # ExpandArgsMore does the same as ExpandArgs
00245         self.touch([self.tmpfile('liby', Lib('y'))])
00246         with ExpandArgsMore(['foo', '-bar'] + self.arg_files + [self.tmpfile('liby', Lib('y'))]) as args:
00247             self.assertRelEqual(args, ['foo', '-bar'] + self.files + [self.tmpfile('liby', Lib('y'))])
00248 
00249             # ExpandArgsMore also has an extra method extracting static libraries
00250             # when possible
00251             args.extract()
00252 
00253             files = self.files + self.liby_files + self.libx_files
00254             if not len(config.AR_EXTRACT):
00255                 # If we don't have an AR_EXTRACT, extract() expands libraries with a
00256                 # descriptor when the corresponding library exists (which ExpandArgs
00257                 # alone doesn't)
00258                 self.assertRelEqual(args, ['foo', '-bar'] + files)
00259             else:
00260                 # With AR_EXTRACT, it uses the descriptors when there are, and actually
00261                 # extracts the remaining libraries
00262                 self.assertRelEqual(args, ['foo', '-bar'] + [extracted[os.path.splitext(os.path.basename(f))[0]] if f.endswith(config.LIB_SUFFIX) else f for f in files])
00263 
00264             tmp = args.tmp
00265         # Check that all temporary files are properly removed
00266         self.assertEqual(True, all([not os.path.exists(f) for f in tmp]))
00267 
00268         # Restore subprocess.call
00269         subprocess.call = subprocess_call

Here is the call graph for this function:

def unit-expandlibs.TestExpandArgsMore.test_makelist (   self)
Test grouping object files in lists

Definition at line 195 of file unit-expandlibs.py.

00195 
00196     def test_makelist(self):
00197         '''Test grouping object files in lists'''
00198         # ExpandArgsMore does the same as ExpandArgs
00199         with ExpandArgsMore(['foo', '-bar'] + self.arg_files + [self.tmpfile('liby', Lib('y'))]) as args:
00200             self.assertRelEqual(args, ['foo', '-bar'] + self.files + self.liby_files + self.libx_files) 
00201 
00202             # But also has an extra method replacing object files with a list
00203             args.makelist()
00204             # self.files has objects at #1, #2, #4
00205             self.assertRelEqual(args[:3], ['foo', '-bar'] + self.files[:1])
00206             self.assertRelEqual(args[4:], [self.files[3]] + self.files[5:] + [self.tmpfile('liby', Lib('z'))])
00207 
00208             # Check the list file content
00209             objs = [f for f in self.files + self.liby_files + self.libx_files if f.endswith(config.OBJ_SUFFIX)]
00210             if config.EXPAND_LIBS_LIST_STYLE == "linkerscript":
00211                 self.assertNotEqual(args[3][0], '@')
00212                 filename = args[3]
00213                 content = ["INPUT(%s)" % relativize(f) for f in objs]
00214                 with open(filename, 'r') as f:
00215                     self.assertEqual([l.strip() for l in f.readlines() if len(l.strip())], content)
00216             elif config.EXPAND_LIBS_LIST_STYLE == "list":
00217                 self.assertEqual(args[3][0], '@')
00218                 filename = args[3][1:]
00219                 content = objs
00220                 with open(filename, 'r') as f:
00221                     self.assertRelEqual([l.strip() for l in f.readlines() if len(l.strip())], content)
00222 
00223             tmp = args.tmp
00224         # Check that all temporary files are properly removed
00225         self.assertEqual(True, all([not os.path.exists(f) for f in tmp]))

Here is the call graph for this function:

def unit-expandlibs.TestCaseWithTmpDir.tmpfile (   self,
  args 
) [inherited]

Definition at line 133 of file unit-expandlibs.py.

00133 
00134     def tmpfile(self, *args):
00135         return os.path.join(self.tmpdir, *args)

Here is the caller graph for this function:

def unit-expandlibs.TestCaseWithTmpDir.touch (   self,
  files 
) [inherited]

Definition at line 129 of file unit-expandlibs.py.

00129 
00130     def touch(self, files):
00131         for f in files:
00132             open(f, 'w').close()

Here is the caller graph for this function:


Member Data Documentation

unit-expandlibs.TestExpandInit.arg_files [inherited]

Definition at line 165 of file unit-expandlibs.py.

unit-expandlibs.TestExpandInit.files [inherited]

Definition at line 168 of file unit-expandlibs.py.

unit-expandlibs.TestExpandInit.libx_files [inherited]

Definition at line 156 of file unit-expandlibs.py.

unit-expandlibs.TestExpandInit.liby_files [inherited]

Definition at line 157 of file unit-expandlibs.py.

unit-expandlibs.TestCaseWithTmpDir.tmpdir [inherited]

Definition at line 124 of file unit-expandlibs.py.


The documentation for this class was generated from the following file: