Skip to content

Commit e7a13bf

Browse files
committed
* Adding 3 generic chunks, which will ignore the A-hat diffs and the
'produced by' diffs. * Updating ietf/tests.py to handle diff chunks right - Legacy-Id: 316
1 parent 8e8c3ff commit e7a13bf

4 files changed

Lines changed: 46 additions & 16 deletions

File tree

ietf/tests.py

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -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

test/diff/generic-diff_A-hat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@@ -16,1 +16,1 @@
2+
-request makes it into the ID tracker.)� A document in this state has
3+
+request makes it into the ID tracker.) A document in this state has
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@@ -12,0 +12,5 @@
2+
+Did you find a bug? Let us know .
3+
+
4+
+Any question or suggestion ?
5+
+
6+
+This page produced by the IETF Secretariat for the IESG
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@@ -27,0 +23,1 @@
2+
+Did you find a bug? Let us know .
3+
@@ -28,0 +25,5 @@
4+
+Any question or suggestion ?
5+
+
6+
+This page produced by the IETF Secretariat for the IESG
7+
+
8+
+

0 commit comments

Comments
 (0)