Commits

Ned Batchelder committed fb2c84e

Comparing files needs to be agnostic to line endings, or testing on Linux won't work. Now gold files are newline-only, and the comparison function ignores line endings.

Comments (0)

Files changed (10)

test/farm/annotate/gold/white.py,cover

-  # A test case sent to me by Steve White
-  
-> def f(self):
-!     if self==1:
-!         pass
-!     elif self.m('fred'):
-!         pass
-!     elif (g==1) and (b==2):
-!         pass
-!     elif self.m('fred')==True:
-!         pass
-!     elif ((g==1) and (b==2))==True:
-!         pass
-!     else:
-!         pass
-  
-> def g(x):
->     if x == 1:
->         a = 1
-!     else:
-!         a = 2
-  
-> g(1)
-  
-> def h(x):
--     if 0:   #pragma: no cover
--         pass
->     if x == 1:
-!         a = 1
->     else:
->         a = 2
-  
-> h(2)
+  # A test case sent to me by Steve White
+  
+> def f(self):
+!     if self==1:
+!         pass
+!     elif self.m('fred'):
+!         pass
+!     elif (g==1) and (b==2):
+!         pass
+!     elif self.m('fred')==True:
+!         pass
+!     elif ((g==1) and (b==2))==True:
+!         pass
+!     else:
+!         pass
+  
+> def g(x):
+>     if x == 1:
+>         a = 1
+!     else:
+!         a = 2
+  
+> g(1)
+  
+> def h(x):
+-     if 0:   #pragma: no cover
+-         pass
+>     if x == 1:
+!         a = 1
+>     else:
+>         a = 2
+  
+> h(2)

test/farm/annotate/gold_anno_dir/a_a.py,cover

-> def a(x):
->     if x == 1:
->         print "x is 1"
-!     else:
-!         print "x is not 1"
+> def a(x):
+>     if x == 1:
+>         print "x is 1"
+!     else:
+!         print "x is not 1"

test/farm/annotate/gold_anno_dir/b_b.py,cover

-> def b(x):
->     print "x is %s" % x
+> def b(x):
+>     print "x is %s" % x

test/farm/annotate/gold_anno_dir/multi.py,cover

-> import a.a
-> import b.b
-  
-> a.a.a(1)
-> b.b.b(2)
+> import a.a
+> import b.b
+  
+> a.a.a(1)
+> b.b.b(2)

test/farm/annotate/gold_multi/a/a.py,cover

-> def a(x):
->     if x == 1:
->         print "x is 1"
-!     else:
-!         print "x is not 1"
+> def a(x):
+>     if x == 1:
+>         print "x is 1"
+!     else:
+!         print "x is not 1"

test/farm/annotate/gold_multi/b/b.py,cover

-> def b(x):
->     print "x is %s" % x
+> def b(x):
+>     print "x is %s" % x

test/farm/annotate/gold_multi/multi.py,cover

-> import a.a
-> import b.b
-  
-> a.a.a(1)
-> b.b.b(2)
+> import a.a
+> import b.b
+  
+> a.a.a(1)
+> b.b.b(2)

test/farm/annotate/gold_v24/white.py,cover

-  # A test case sent to me by Steve White
-  
-> def f(self):
-!     if self==1:
-!         pass
-!     elif self.m('fred'):
-!         pass
-!     elif (g==1) and (b==2):
-!         pass
-!     elif self.m('fred')==True:
-!         pass
-!     elif ((g==1) and (b==2))==True:
-!         pass
->     else:
-!         pass
-  
-> def g(x):
->     if x == 1:
->         a = 1
-!     else:
-!         a = 2
-  
-> g(1)
-  
-> def h(x):
--     if 0:   #pragma: no cover
--         pass
->     if x == 1:
-!         a = 1
->     else:
->         a = 2
-  
-> h(2)
+  # A test case sent to me by Steve White
+  
+> def f(self):
+!     if self==1:
+!         pass
+!     elif self.m('fred'):
+!         pass
+!     elif (g==1) and (b==2):
+!         pass
+!     elif self.m('fred')==True:
+!         pass
+!     elif ((g==1) and (b==2))==True:
+!         pass
+>     else:
+!         pass
+  
+> def g(x):
+>     if x == 1:
+>         a = 1
+!     else:
+!         a = 2
+  
+> g(1)
+  
+> def h(x):
+-     if 0:   #pragma: no cover
+-         pass
+>     if x == 1:
+!         a = 1
+>     else:
+>         a = 2
+  
+> h(2)

test/farm/run/src/xxx

-# This is a python file though it doesn't look like it, like a main script.
-a = b = c = d = 0
-a = 3
-b = 4
-if not b:
-    c = 6
-d = 7
-print "xxx:", a, b, c, d
+# This is a python file though it doesn't look like it, like a main script.
+a = b = c = d = 0
+a = 3
+b = 4
+if not b:
+    c = 6
+d = 7
+print "xxx:", a, b, c, d
                     wrong_size.append(f)
             assert not wrong_size, "File sizes differ: %s" % wrong_size
         else:
-            assert not diff_files, "Files differ: %s" % diff_files
+            # filecmp only compares in binary mode, but we want text mode.  So
+            # look through the list of different files, and compare them
+            # ourselves.
+            text_diff = []
+            for f in diff_files:
+                left = open(os.path.join(dir1, f), "r").read()
+                right = open(os.path.join(dir2, f), "r").read()
+                if left != right:
+                    text_diff.append(f)
+            assert not text_diff, "Files differ: %s" % text_diff
 
         if not left_extra:
             assert not left_only, "Files in %s only: %s" % (dir1, left_only)