@@ -97,7 +97,13 @@ def setUp(self):
9797 for item in os .listdir (testdir ):
9898 path = testdir + "/" + item
9999 if item .startswith ("generic-" ) and os .path .isfile (path ):
100- self .diffchunks .append (filetext (path ))
100+ chunk = filetext (path )
101+ chunk = re .sub (r"([\[\]().|+*?])" , r"\\\1" , chunk )
102+ # @@ -27,0 \+23,1 @@
103+ chunk = re .sub (r"(?m)^@@ -\d+,(\d+) \\\+\d+,(\d+) @@$" , r"@@ -\d+,\1 \+\d+,\2 @@" , chunk )
104+ #print "*** Installing diff chunk:"
105+ #print chunk
106+ self .diffchunks .append (chunk )
101107
102108 # extract application urls:
103109 self .patterns = get_patterns (ietf .urls )
@@ -165,21 +171,28 @@ def doUrlsTest(self, lst):
165171 contextlines = 0
166172 diff = "\n " .join (unified_diff (goodtext , testtext , master , url , "" , "" , contextlines , lineterm = "" ))
167173 for chunk in self .diffchunks :
168- if chunk in diff :
169- diff = diff .replace (chunk , "" )
170- dfile = "%s/../test/diff/%s" % (settings .BASE_DIR , url .replace ("/" , "_" ))
171- if os .path .exists (dfile ):
172- dfile = open (dfile )
173- #print "Reading OK diff file:", dfile.name
174- okdiff = dfile .read ()
175- dfile .close ()
176- else :
177- okdiff = ""
178- if diff .strip () == okdiff .strip ():
179- print "OK diff %s" % (url )
180- else :
181- print "Diff: %s" % (url )
182- print diff
174+ #print "*** Checking for chunk:", chunk[:24]
175+ while re .search (chunk , diff ):
176+ #print "*** Removing chunk of %s lines" % (len(chunk.split("\n")))
177+ diff = re .sub (chunk , "" , diff )
178+ if len (diff .strip ().split ()) == 2 :
179+ # only the initial 2 lines of the diff remains --
180+ # discard them too
181+ diff = ""
182+ if diff :
183+ dfile = "%s/../test/diff/%s" % (settings .BASE_DIR , url .replace ("/" , "_" ))
184+ if os .path .exists (dfile ):
185+ dfile = open (dfile )
186+ #print "Reading OK diff file:", dfile.name
187+ okdiff = dfile .read ()
188+ dfile .close ()
189+ else :
190+ okdiff = ""
191+ if diff .strip () == okdiff .strip ():
192+ print "OK diff %s" % (url )
193+ else :
194+ print "Diff: %s" % (url )
195+ print diff
183196 except :
184197 print "Exception occurred for url %s" % (url )
185198 raise
0 commit comments