* 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
This commit is contained in:
parent
8e8c3ff5e2
commit
e7a13bff68
|
@ -97,7 +97,13 @@ class UrlTestCase(TestCase):
|
||||||
for item in os.listdir(testdir):
|
for item in os.listdir(testdir):
|
||||||
path = testdir + "/" + item
|
path = testdir + "/" + item
|
||||||
if item.startswith("generic-") and os.path.isfile(path):
|
if item.startswith("generic-") and os.path.isfile(path):
|
||||||
self.diffchunks.append(filetext(path))
|
chunk = filetext(path)
|
||||||
|
chunk = re.sub(r"([\[\]().|+*?])", r"\\\1", chunk)
|
||||||
|
# @@ -27,0 \+23,1 @@
|
||||||
|
chunk = re.sub(r"(?m)^@@ -\d+,(\d+) \\\+\d+,(\d+) @@$", r"@@ -\d+,\1 \+\d+,\2 @@", chunk)
|
||||||
|
#print "*** Installing diff chunk:"
|
||||||
|
#print chunk
|
||||||
|
self.diffchunks.append(chunk)
|
||||||
|
|
||||||
# extract application urls:
|
# extract application urls:
|
||||||
self.patterns = get_patterns(ietf.urls)
|
self.patterns = get_patterns(ietf.urls)
|
||||||
|
@ -165,21 +171,28 @@ class UrlTestCase(TestCase):
|
||||||
contextlines = 0
|
contextlines = 0
|
||||||
diff = "\n".join(unified_diff(goodtext, testtext, master, url, "", "", contextlines, lineterm=""))
|
diff = "\n".join(unified_diff(goodtext, testtext, master, url, "", "", contextlines, lineterm=""))
|
||||||
for chunk in self.diffchunks:
|
for chunk in self.diffchunks:
|
||||||
if chunk in diff:
|
#print "*** Checking for chunk:", chunk[:24]
|
||||||
diff = diff.replace(chunk, "")
|
while re.search(chunk, diff):
|
||||||
dfile = "%s/../test/diff/%s" % (settings.BASE_DIR, url.replace("/", "_"))
|
#print "*** Removing chunk of %s lines" % (len(chunk.split("\n")))
|
||||||
if os.path.exists(dfile):
|
diff = re.sub(chunk, "", diff)
|
||||||
dfile = open(dfile)
|
if len(diff.strip().split()) == 2:
|
||||||
#print "Reading OK diff file:", dfile.name
|
# only the initial 2 lines of the diff remains --
|
||||||
okdiff = dfile.read()
|
# discard them too
|
||||||
dfile.close()
|
diff = ""
|
||||||
else:
|
if diff:
|
||||||
okdiff = ""
|
dfile = "%s/../test/diff/%s" % (settings.BASE_DIR, url.replace("/", "_"))
|
||||||
if diff.strip() == okdiff.strip():
|
if os.path.exists(dfile):
|
||||||
print "OK diff %s" % (url)
|
dfile = open(dfile)
|
||||||
else:
|
#print "Reading OK diff file:", dfile.name
|
||||||
print "Diff: %s" % (url)
|
okdiff = dfile.read()
|
||||||
print diff
|
dfile.close()
|
||||||
|
else:
|
||||||
|
okdiff = ""
|
||||||
|
if diff.strip() == okdiff.strip():
|
||||||
|
print "OK diff %s" % (url)
|
||||||
|
else:
|
||||||
|
print "Diff: %s" % (url)
|
||||||
|
print diff
|
||||||
except:
|
except:
|
||||||
print "Exception occurred for url %s" % (url)
|
print "Exception occurred for url %s" % (url)
|
||||||
raise
|
raise
|
||||||
|
|
3
test/diff/generic-diff_A-hat
Normal file
3
test/diff/generic-diff_A-hat
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
@@ -16,1 +16,1 @@
|
||||||
|
-request makes it into the ID tracker.) A document in this state has
|
||||||
|
+request makes it into the ID tracker.) A document in this state has
|
6
test/diff/generic-diff_produced-by-1
Normal file
6
test/diff/generic-diff_produced-by-1
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
@@ -12,0 +12,5 @@
|
||||||
|
+Did you find a bug? Let us know .
|
||||||
|
+
|
||||||
|
+Any question or suggestion ?
|
||||||
|
+
|
||||||
|
+This page produced by the IETF Secretariat for the IESG
|
8
test/diff/generic-diff_produced-by-2
Normal file
8
test/diff/generic-diff_produced-by-2
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
@@ -27,0 +23,1 @@
|
||||||
|
+Did you find a bug? Let us know .
|
||||||
|
@@ -28,0 +25,5 @@
|
||||||
|
+Any question or suggestion ?
|
||||||
|
+
|
||||||
|
+This page produced by the IETF Secretariat for the IESG
|
||||||
|
+
|
||||||
|
+
|
Loading…
Reference in a new issue