Anonymous avatar Anonymous committed 4926cda

Refactor some common testing in the C Scanner tests.

Comments (0)

Files changed (1)

src/engine/SCons/Scanner/CTests.py

         else:
             raise KeyError, "Dummy environment only has CPPPATH attribute."
 
-def deps_match(deps, headers):
-    deps = map(str, deps)
-    headers = map(test.workpath, headers)
+def deps_match(self, deps, headers):
+    deps = map(os.path.normpath, map(str, deps))
+    headers = map(os.path.normpath, map(test.workpath, headers))
     deps.sort()
     headers.sort()
-    return map(os.path.normpath, deps) == \
-           map(os.path.normpath, headers)
+    self.failUnless(deps == headers, "expect %s != scanned %s" % (headers, deps))
 
 # define some tests:
 
         s = SCons.Scanner.C.CScan()
         deps = s.scan(test.workpath('f1.cpp'), env)
 	headers = ['f1.h', 'f2.h', 'fi.h']
-        self.failUnless(deps_match(deps, headers), map(str, deps))
+        deps_match(self, deps, headers)
 
 class CScannerTestCase2(unittest.TestCase):
     def runTest(self):
         s = SCons.Scanner.C.CScan()
         deps = s.scan(test.workpath('f1.cpp'), env)
         headers = ['f1.h', 'd1/f2.h']
-        self.failUnless(deps_match(deps, headers), map(str, deps))
+        deps_match(self, deps, headers)
 
 class CScannerTestCase3(unittest.TestCase):
     def runTest(self):
         s = SCons.Scanner.C.CScan()
         deps = s.scan(test.workpath('f2.cpp'), env)
         headers = ['f1.h', 'd1/f1.h', 'd1/d2/f1.h']
-        self.failUnless(deps_match(deps, headers), map(str, deps))
+        deps_match(self, deps, headers)
 
 class CScannerTestCase4(unittest.TestCase):
     def runTest(self):
         s = SCons.Scanner.C.CScan()
         deps = s.scan(test.workpath('f2.cpp'), env)
         headers =  ['f1.h', 'd1/f1.h', 'd1/d2/f1.h', 'd1/d2/f4.h']
-        self.failUnless(deps_match(deps, headers), map(str, deps))
+        deps_match(self, deps, headers)
         
 class CScannerTestCase5(unittest.TestCase):
     def runTest(self):
         deps = s.scan(test.workpath('f3.cpp'), env)
         headers =  ['f1.h', 'f2.h', 'f3.h', 'fi.h', 'fj.h',
                     'd1/f1.h', 'd1/f2.h', 'd1/f3.h']
-        self.failUnless(deps_match(deps, headers), map(str, deps))
+        deps_match(self, deps, headers)
 
 def suite():
     suite = unittest.TestSuite()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.