<s> __revision__ = "<STR_LIT>" <EOL> import os <EOL> import os . path <EOL> import sys <EOL> import unittest <EOL> import SCons . Scanner . Fortran <EOL> import SCons . Node . FS <EOL> import SCons . Warnings <EOL> import TestCmd <EOL> original = os . getcwd ( ) <EOL> test = TestCmd . TestCmd ( workdir = '<STR_LIT>' ) <EOL> os . chdir ( test . workpath ( '<STR_LIT>' ) ) <EOL> test . write ( '<STR_LIT>' , """<STR_LIT>""" ) <EOL> test . write ( '<STR_LIT>' , """<STR_LIT>""" ) <EOL> test . write ( '<STR_LIT>' , """<STR_LIT>""" ) <EOL> test . subdir ( '<STR_LIT>' , [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> headers = [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ] <EOL> for h in headers : <EOL> test . write ( h , "<STR_LIT:\n>" ) <EOL> test . subdir ( '<STR_LIT>' , '<STR_LIT>' , [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> test . write ( '<STR_LIT>' , """<STR_LIT>""" ) <EOL> test . write ( '<STR_LIT>' , "<STR_LIT:\n>" ) <EOL> test . write ( '<STR_LIT>' , "<STR_LIT:\n>" ) <EOL> test . write ( '<STR_LIT>' , """<STR_LIT>""" ) <EOL> test . write ( '<STR_LIT>' , "<STR_LIT:\n>" ) <EOL> test . subdir ( '<STR_LIT>' , [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> [ '<STR_LIT>' , '<STR_LIT:src>' ] ) <EOL> test . subdir ( '<STR_LIT>' , [ '<STR_LIT>' , '<STR_LIT:src>' ] ) <EOL> test . write ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , "<STR_LIT:\n>" ) <EOL> test . write ( [ '<STR_LIT>' , '<STR_LIT:src>' , '<STR_LIT>' ] , """<STR_LIT>""" ) <EOL> test . write ( [ '<STR_LIT>' , '<STR_LIT:src>' , '<STR_LIT>' ] , """<STR_LIT>""" ) <EOL> test . write ( [ '<STR_LIT>' , '<STR_LIT:src>' , '<STR_LIT>' ] , "<STR_LIT:\n>" ) <EOL> test . write ( [ '<STR_LIT>' , '<STR_LIT:src>' , '<STR_LIT>' ] , """<STR_LIT>""" ) <EOL> test . write ( [ '<STR_LIT>' , '<STR_LIT:src>' , '<STR_LIT>' ] , "<STR_LIT:\n>" ) <EOL> test . write ( '<STR_LIT>' , """<STR_LIT>""" ) <EOL> modules = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> for m in modules : <EOL> test . write ( m , "<STR_LIT:\n>" ) <EOL> test . subdir ( '<STR_LIT>' ) <EOL> test . write ( [ '<STR_LIT>' , '<STR_LIT>' ] , "<STR_LIT:\n>" ) <EOL> class DummyEnvironment : <EOL> def __init__ ( self , listCppPath ) : <EOL> self . path = listCppPath <EOL> self . fs = SCons . Node . FS . FS ( test . workpath ( '<STR_LIT>' ) ) <EOL> def Dictionary ( self , * args ) : <EOL> if not args : <EOL> return { '<STR_LIT>' : self . path , '<STR_LIT>' : "<STR_LIT>" } <EOL> elif len ( args ) == <NUM_LIT:1> and args [ <NUM_LIT:0> ] == '<STR_LIT>' : <EOL> return self . path <EOL> else : <EOL> raise KeyError , "<STR_LIT>" <EOL> def has_key ( self , key ) : <EOL> return self . Dictionary ( ) . has_key ( key ) <EOL> def __getitem__ ( self , key ) : <EOL> return self . Dictionary ( ) [ key ] <EOL> def __setitem__ ( self , key , value ) : <EOL> self . Dictionary ( ) [ key ] = value <EOL> def __delitem__ ( self , key ) : <EOL> del self . Dictionary ( ) [ key ] <EOL> def subst ( self , arg , target = None , source = None , conv = None ) : <EOL> if arg [ <NUM_LIT:0> ] == '<STR_LIT:$>' : <EOL> return self [ arg [ <NUM_LIT:1> : ] ] <EOL> return arg <EOL> def subst_path ( self , path , target = None , source = None , conv = None ) : <EOL> if type ( path ) != type ( [ ] ) : <EOL> path = [ path ] <EOL> return map ( self . subst , path ) <EOL> def get_calculator ( self ) : <EOL> return None <EOL> def get_factory ( self , factory ) : <EOL> return factory or self . fs . File <EOL> def Dir ( self , filename ) : <EOL> return self . fs . Dir ( filename ) <EOL> def File ( self , filename ) : <EOL> return self . fs . File ( filename ) <EOL> def deps_match ( self , deps , headers ) : <EOL> scanned = map ( os . path . normpath , map ( str , deps ) ) <EOL> expect = map ( os . path . normpath , headers ) <EOL> self . failUnless ( scanned == expect , "<STR_LIT>" % ( expect , scanned ) ) <EOL> class FortranScannerTestCase1 ( unittest . TestCase ) : <EOL> def runTest ( self ) : <EOL> test . write ( '<STR_LIT>' , "<STR_LIT:\n>" ) <EOL> test . write ( '<STR_LIT>' , "<STR_LIT>" ) <EOL> env = DummyEnvironment ( [ ] ) <EOL> s = SCons . Scanner . Fortran . FortranScan ( ) <EOL> path = s . path ( env ) <EOL> deps = s ( env . File ( '<STR_LIT>' ) , env , path ) <EOL> headers = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> deps_match ( self , deps , headers ) <EOL> test . unlink ( '<STR_LIT>' ) <EOL> test . unlink ( '<STR_LIT>' ) <EOL> class FortranScannerTestCase2 ( unittest . TestCase ) : <EOL> def runTest ( self ) : <EOL> test . write ( '<STR_LIT>' , "<STR_LIT:\n>" ) <EOL> test . write ( '<STR_LIT>' , "<STR_LIT>" ) <EOL> env = DummyEnvironment ( [ test . workpath ( "<STR_LIT>" ) ] ) <EOL> s = SCons . Scanner . Fortran . FortranScan ( ) <EOL> path = s . path ( env ) <EOL> deps = s ( env . File ( '<STR_LIT>' ) , env , path ) <EOL> headers = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> deps_match ( self , deps , headers ) <EOL> test . unlink ( '<STR_LIT>' ) <EOL> test . unlink ( '<STR_LIT>' ) <EOL> class FortranScannerTestCase3 ( unittest . TestCase ) : <EOL> def runTest ( self ) : <EOL> env = DummyEnvironment ( [ test . workpath ( "<STR_LIT>" ) ] ) <EOL> s = SCons . Scanner . Fortran . FortranScan ( ) <EOL> path = s . path ( env ) <EOL> deps = s ( env . File ( '<STR_LIT>' ) , env , path ) <EOL> headers = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> deps_match ( self , deps , headers ) <EOL> class FortranScannerTestCase4 ( unittest . TestCase ) : <EOL> def runTest ( self ) : <EOL> test . write ( [ '<STR_LIT>' , '<STR_LIT>' ] , "<STR_LIT>" ) <EOL> env = DummyEnvironment ( [ test . workpath ( "<STR_LIT>" ) ] ) <EOL> s = SCons . Scanner . Fortran . FortranScan ( ) <EOL> path = s . path ( env ) <EOL> deps = s ( env . File ( '<STR_LIT>' ) , env , path ) <EOL> headers = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> deps_match ( self , deps , headers ) <EOL> test . write ( [ '<STR_LIT>' , '<STR_LIT>' ] , "<STR_LIT:\n>" ) <EOL> class FortranScannerTestCase5 ( unittest . TestCase ) : <EOL> def runTest ( self ) : <EOL> env = DummyEnvironment ( [ test . workpath ( "<STR_LIT>" ) ] ) <EOL> s = SCons . Scanner . Fortran . FortranScan ( ) <EOL> path = s . path ( env ) <EOL> deps = s ( env . File ( '<STR_LIT>' ) , env , path ) <EOL> headers = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> deps_match ( self , deps , headers ) <EOL> class FortranScannerTestCase6 ( unittest . TestCase ) : <EOL> def runTest ( self ) : <EOL> test . write ( '<STR_LIT>' , "<STR_LIT:\n>" ) <EOL> env = DummyEnvironment ( [ test . workpath ( "<STR_LIT>" ) ] ) <EOL> s = SCons . Scanner . Fortran . FortranScan ( ) <EOL> path = s . path ( env ) <EOL> deps = s ( env . File ( '<STR_LIT>' ) , env , path ) <EOL> headers = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> deps_match ( self , deps , headers ) <EOL> test . unlink ( '<STR_LIT>' ) <EOL> class FortranScannerTestCase7 ( unittest . TestCase ) : <EOL> def runTest ( self ) : <EOL> env = DummyEnvironment ( [ test . workpath ( "<STR_LIT>" ) , test . workpath ( "<STR_LIT>" ) ] ) <EOL> s = SCons . Scanner . Fortran . FortranScan ( ) <EOL> path = s . path ( env ) <EOL> deps = s ( env . File ( '<STR_LIT>' ) , env , path ) <EOL> headers = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> deps_match ( self , deps , headers ) <EOL> class FortranScannerTestCase8 ( unittest . TestCase ) : <EOL> def runTest ( self ) : <EOL> test . write ( '<STR_LIT>' , "<STR_LIT:\n>" ) <EOL> env = DummyEnvironment ( [ test . workpath ( "<STR_LIT>" ) , test . workpath ( "<STR_LIT>" ) ] ) <EOL> s = SCons . Scanner . Fortran . FortranScan ( ) <EOL> path = s . path ( env ) <EOL> deps = s ( env . File ( '<STR_LIT>' ) , env , path ) <EOL> headers = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> deps_match ( self , deps , headers ) <EOL> test . unlink ( '<STR_LIT>' ) <EOL> class FortranScannerTestCase9 ( unittest . TestCase ) : <EOL> def runTest ( self ) : <EOL> test . write ( '<STR_LIT>' , "<STR_LIT:\n>" ) <EOL> env = DummyEnvironment ( [ ] ) <EOL> s = SCons . Scanner . Fortran . FortranScan ( ) <EOL> path = s . path ( env ) <EOL> n = env . File ( '<STR_LIT>' ) <EOL> def my_rexists ( s = n ) : <EOL> s . rexists_called = <NUM_LIT:1> <EOL> return s . old_rexists ( ) <EOL> setattr ( n , '<STR_LIT>' , n . rexists ) <EOL> setattr ( n , '<STR_LIT>' , my_rexists ) <EOL> deps = s ( n , env , path ) <EOL> assert n . rexists_called <EOL> headers = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> deps_match ( self , deps , headers ) <EOL> test . unlink ( '<STR_LIT>' ) <EOL> class FortranScannerTestCase10 ( unittest . TestCase ) : <EOL> def runTest ( self ) : <EOL> env = DummyEnvironment ( [ "<STR_LIT>" ] ) <EOL> s = SCons . Scanner . Fortran . FortranScan ( ) <EOL> path = s . path ( env ) <EOL> deps1 = s ( env . File ( '<STR_LIT>' ) , env , path ) <EOL> env . fs . chdir ( env . Dir ( '<STR_LIT>' ) ) <EOL> dir = env . fs . getcwd ( ) <EOL> env . fs . chdir ( env . Dir ( '<STR_LIT>' ) ) <EOL> path = s . path ( env , dir ) <EOL> deps2 = s ( env . File ( '<STR_LIT>' ) , env , path ) <EOL> headers1 = map ( test . workpath , [ '<STR_LIT>' ] ) <EOL> headers2 = [ '<STR_LIT>' ] <EOL> deps_match ( self , deps1 , headers1 ) <EOL> deps_match ( self , deps2 , headers2 ) <EOL> class FortranScannerTestCase11 ( unittest . TestCase ) : <EOL> def runTest ( self ) : <EOL> SCons . Warnings . enableWarningClass ( SCons . Warnings . DependencyWarning ) <EOL> class TestOut : <EOL> def __call__ ( self , x ) : <EOL> self . out = x <EOL> to = TestOut ( ) <EOL> to . out = None <EOL> SCons . Warnings . _warningOut = to <EOL> env = DummyEnvironment ( [ ] ) <EOL> s = SCons . Scanner . Fortran . FortranScan ( ) <EOL> path = s . path ( env ) <EOL> deps = s ( env . File ( '<STR_LIT>' ) , env , path ) <EOL> assert to . out <EOL> deps_match ( self , deps , [ '<STR_LIT>' ] ) <EOL> class FortranScannerTestCase12 ( unittest . TestCase ) : <EOL> def runTest ( self ) : <EOL> env = DummyEnvironment ( [ ] ) <EOL> env . fs . chdir ( env . Dir ( '<STR_LIT>' ) ) <EOL> s = SCons . Scanner . Fortran . FortranScan ( ) <EOL> path = s . path ( env ) <EOL> test . write ( '<STR_LIT>' , test . read ( '<STR_LIT>' ) ) <EOL> deps = s ( env . File ( '<STR_LIT>' ) , env , path ) <EOL> env . fs . chdir ( env . Dir ( '<STR_LIT>' ) ) <EOL> deps_match ( self , deps , [ '<STR_LIT>' ] ) <EOL> test . unlink ( '<STR_LIT>' ) <EOL> class FortranScannerTestCase13 ( unittest . TestCase ) : <EOL> def runTest ( self ) : <EOL> os . chdir ( test . workpath ( '<STR_LIT>' ) ) <EOL> fs = SCons . Node . FS . FS ( test . workpath ( '<STR_LIT>' ) ) <EOL> fs . Repository ( test . workpath ( '<STR_LIT>' ) ) <EOL> f1 = fs . File ( '<STR_LIT>' ) <EOL> f1 . builder = <NUM_LIT:1> <EOL> env = DummyEnvironment ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> env . fs = fs <EOL> s = SCons . Scanner . Fortran . FortranScan ( ) <EOL> path = s . path ( env ) <EOL> deps = s ( fs . File ( '<STR_LIT>' ) , env , path ) <EOL> deps_match ( self , deps , [ test . workpath ( '<STR_LIT>' ) , '<STR_LIT>' ] ) <EOL> os . chdir ( test . workpath ( '<STR_LIT>' ) ) <EOL> class FortranScannerTestCase14 ( unittest . TestCase ) : <EOL> def runTest ( self ) : <EOL> os . chdir ( test . workpath ( '<STR_LIT>' ) ) <EOL> fs = SCons . Node . FS . FS ( test . workpath ( '<STR_LIT>' ) ) <EOL> fs . VariantDir ( '<STR_LIT>' , '<STR_LIT:src>' , <NUM_LIT:1> ) <EOL> fs . VariantDir ( '<STR_LIT>' , '<STR_LIT:src>' , <NUM_LIT:0> ) <EOL> fs . Repository ( test . workpath ( '<STR_LIT>' ) ) <EOL> env = DummyEnvironment ( [ ] ) <EOL> env . fs = fs <EOL> s = SCons . Scanner . Fortran . FortranScan ( ) <EOL> path = s . path ( env ) <EOL> deps1 = s ( fs . File ( '<STR_LIT>' ) , env , path ) <EOL> deps_match ( self , deps1 , [ '<STR_LIT>' ] ) <EOL> deps2 = s ( fs . File ( '<STR_LIT>' ) , env , path ) <EOL> deps_match ( self , deps2 , [ '<STR_LIT>' ] ) <EOL> deps3 = s ( fs . File ( '<STR_LIT>' ) , env , path ) <EOL> deps_match ( self , deps3 , [ '<STR_LIT>' ] ) <EOL> deps4 = s ( fs . File ( '<STR_LIT>' ) , env , path ) <EOL> deps_match ( self , deps4 , [ test . workpath ( '<STR_LIT>' ) ] ) <EOL> os . chdir ( test . workpath ( '<STR_LIT>' ) ) <EOL> class FortranScannerTestCase15 ( unittest . TestCase ) : <EOL> def runTest ( self ) : <EOL> class SubstEnvironment ( DummyEnvironment ) : <EOL> def subst ( self , arg , target = None , source = None , conv = None , test = test ) : <EOL> if arg == "<STR_LIT>" : <EOL> return test . workpath ( "<STR_LIT>" ) <EOL> else : <EOL> return arg <EOL> test . write ( [ '<STR_LIT>' , '<STR_LIT>' ] , "<STR_LIT>" ) <EOL> env = SubstEnvironment ( [ "<STR_LIT>" ] ) <EOL> s = SCons . Scanner . Fortran . FortranScan ( ) <EOL> path = s . path ( env ) <EOL> deps = s ( env . File ( '<STR_LIT>' ) , env , path ) <EOL> headers = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> deps_match ( self , deps , headers ) <EOL> test . write ( [ '<STR_LIT>' , '<STR_LIT>' ] , "<STR_LIT:\n>" ) <EOL> class FortranScannerTestCase16 ( unittest . TestCase ) : <EOL> def runTest ( self ) : <EOL> test . write ( '<STR_LIT>' , "<STR_LIT:\n>" ) <EOL> test . write ( '<STR_LIT>' , "<STR_LIT:\n>" ) <EOL> test . write ( '<STR_LIT>' , "<STR_LIT:\n>" ) <EOL> test . write ( '<STR_LIT>' , "<STR_LIT:\n>" ) <EOL> test . write ( '<STR_LIT>' , "<STR_LIT:\n>" ) <EOL> test . write ( '<STR_LIT>' , "<STR_LIT:\n>" ) <EOL> test . write ( '<STR_LIT>' , "<STR_LIT:\n>" ) <EOL> test . write ( '<STR_LIT>' , "<STR_LIT:\n>" ) <EOL> test . write ( '<STR_LIT>' , "<STR_LIT:\n>" ) <EOL> test . write ( '<STR_LIT>' , "<STR_LIT:\n>" ) <EOL> env = DummyEnvironment ( [ test . workpath ( '<STR_LIT>' ) ] ) <EOL> s = SCons . Scanner . Fortran . FortranScan ( ) <EOL> path = s . path ( env ) <EOL> deps = s ( env . File ( '<STR_LIT>' ) , env , path ) <EOL> headers = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> modules = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> deps_expected = headers + modules <EOL> deps_match ( self , deps , deps_expected ) <EOL> test . unlink ( '<STR_LIT>' ) <EOL> test . unlink ( '<STR_LIT>' ) <EOL> test . unlink ( '<STR_LIT>' ) <EOL> test . unlink ( '<STR_LIT>' ) <EOL> test . unlink ( '<STR_LIT>' ) <EOL> test . unlink ( '<STR_LIT>' ) <EOL> test . unlink ( '<STR_LIT>' ) <EOL> test . unlink ( '<STR_LIT>' ) <EOL> test . unlink ( '<STR_LIT>' ) <EOL> test . unlink ( '<STR_LIT>' ) <EOL> def suite ( ) : <EOL> suite = unittest . TestSuite ( ) <EOL> suite . addTest ( FortranScannerTestCase1 ( ) ) <EOL> suite . addTest ( FortranScannerTestCase2 ( ) ) <EOL> suite . addTest ( FortranScannerTestCase3 ( ) ) <EOL> suite . addTest ( FortranScannerTestCase4 ( ) ) <EOL> suite . addTest ( FortranScannerTestCase5 ( ) ) <EOL> suite . addTest ( FortranScannerTestCase6 ( ) ) <EOL> suite . addTest ( FortranScannerTestCase7 ( ) ) <EOL> suite . addTest ( FortranScannerTestCase8 ( ) ) <EOL> suite . addTest ( FortranScannerTestCase9 ( ) ) <EOL> suite . addTest ( FortranScannerTestCase10 ( ) ) <EOL> suite . addTest ( FortranScannerTestCase11 ( ) ) <EOL> suite . addTest ( FortranScannerTestCase12 ( ) ) <EOL> suite . addTest ( FortranScannerTestCase13 ( ) ) <EOL> suite . addTest ( FortranScannerTestCase14 ( ) ) <EOL> suite . addTest ( FortranScannerTestCase15 ( ) ) <EOL> suite . addTest ( FortranScannerTestCase16 ( ) ) <EOL> return suite <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> runner = unittest . TextTestRunner ( ) <EOL> result = runner . run ( suite ( ) ) <EOL> if not result . wasSuccessful ( ) : <EOL> sys . exit ( <NUM_LIT:1> ) </s>
