http://scons.tigris.org/issues/show_bug.cgi?id=2345
[scons.git] / src / engine / SCons / Scanner / FortranTests.py
index 141f375c7852a3759600d9da25cd02ec24f2b92b..9ebe2e673450146885fa8bb844074f4733dc49be 100644 (file)
@@ -218,10 +218,10 @@ class DummyEnvironment:
         elif len(args) == 1 and args[0] == 'FORTRANPATH':
             return self.path
         else:
-            raise KeyError, "Dummy environment only has FORTRANPATH attribute."
+            raise KeyError("Dummy environment only has FORTRANPATH attribute.")
 
     def has_key(self, key):
-        return self.Dictionary().has_key(key)
+        return key in self.Dictionary()
 
     def __getitem__(self,key):
         return self.Dictionary()[key]
@@ -232,15 +232,15 @@ class DummyEnvironment:
     def __delitem__(self,key):
         del self.Dictionary()[key]
 
-    def subst(self, arg):
+    def subst(self, arg, target=None, source=None, conv=None):
         if arg[0] == '$':
             return self[arg[1:]]
         return arg
 
-    def subst_path(self, path, target=None, source=None):
-        if type(path) != type([]):
+    def subst_path(self, path, target=None, source=None, conv=None):
+        if not isinstance(path, list):
             path = [path]
-        return map(self.subst, path)
+        return list(map(self.subst, path))
 
     def get_calculator(self):
         return None
@@ -249,14 +249,14 @@ class DummyEnvironment:
         return factory or self.fs.File
 
     def Dir(self, filename):
-        return self.fs.Dir(test.workpath(filename))
+        return self.fs.Dir(filename)
 
     def File(self, filename):
-        return self.fs.File(test.workpath(filename))
+        return self.fs.File(filename)
 
 def deps_match(self, deps, headers):
-    scanned = map(os.path.normpath, map(str, deps))
-    expect = map(os.path.normpath, headers)
+    scanned = list(map(os.path.normpath, list(map(str, deps))))
+    expect = list(map(os.path.normpath, headers))
     self.failUnless(scanned == expect, "expect %s != scanned %s" % (expect, scanned))
 
 # define some tests:
@@ -364,7 +364,7 @@ class FortranScannerTestCase9(unittest.TestCase):
         deps = s(n, env, path)
 
         # Make sure rexists() got called on the file node being
-        # scanned, essential for cooperation with BuildDir functionality.
+        # scanned, essential for cooperation with VariantDir functionality.
         assert n.rexists_called
 
         headers =  ['d1/f3.f', 'f3.f']
@@ -382,8 +382,8 @@ class FortranScannerTestCase10(unittest.TestCase):
         env.fs.chdir(env.Dir(''))
         path = s.path(env, dir)
         deps2 = s(env.File('#fff4.f'), env, path)
-        headers1 =  ['include/f4.f']
-        headers2 =  ['subdir/include/f4.f']
+        headers1 =  list(map(test.workpath, ['include/f4.f']))
+        headers2 =  ['include/f4.f']
         deps_match(self, deps1, headers1)
         deps_match(self, deps2, headers2)
 
@@ -416,7 +416,7 @@ class FortranScannerTestCase12(unittest.TestCase):
         test.write('include/fff4.f', test.read('fff4.f'))
         deps = s(env.File('#include/fff4.f'), env, path)
         env.fs.chdir(env.Dir(''))
-        deps_match(self, deps, ['include/f4.f'])
+        deps_match(self, deps, ['f4.f'])
         test.unlink('include/fff4.f')
 
 class FortranScannerTestCase13(unittest.TestCase):
@@ -441,8 +441,8 @@ class FortranScannerTestCase14(unittest.TestCase):
     def runTest(self):
         os.chdir(test.workpath('work'))
         fs = SCons.Node.FS.FS(test.workpath('work'))
-        fs.BuildDir('build1', 'src', 1)
-        fs.BuildDir('build2', 'src', 0)
+        fs.VariantDir('build1', 'src', 1)
+        fs.VariantDir('build2', 'src', 0)
         fs.Repository(test.workpath('repository'))
         env = DummyEnvironment([])
         env.fs = fs
@@ -461,10 +461,13 @@ class FortranScannerTestCase14(unittest.TestCase):
 class FortranScannerTestCase15(unittest.TestCase):
     def runTest(self):
         class SubstEnvironment(DummyEnvironment):
-            def subst(self, arg, test=test):
-                return test.workpath("d1")
+            def subst(self, arg, target=None, source=None, conv=None, test=test):
+                if arg == "$junk":
+                    return test.workpath("d1")
+                else:
+                    return arg
         test.write(['d1', 'f2.f'], "      INCLUDE 'fi.f'\n")
-        env = SubstEnvironment(["junk"])
+        env = SubstEnvironment(["$junk"])
         s = SCons.Scanner.Fortran.FortranScan()
         path = s.path(env)
         deps = s(env.File('fff1.f'), env, path)
@@ -532,3 +535,9 @@ if __name__ == "__main__":
     result = runner.run(suite())
     if not result.wasSuccessful():
         sys.exit(1)
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4: