Skip to content

Commit 90e95e6

Browse files
committed
Repurpose the 'master' column in testurl.list files to point to a local
known-good master file, for comparisons. - Legacy-Id: 6433
1 parent 3903094 commit 90e95e6

1 file changed

Lines changed: 21 additions & 17 deletions

File tree

ietf/utils/test_utils.py

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,6 @@ def read_testurls(filename):
8787
goodurl = None
8888
elif len(urlspec) == 3:
8989
codes, testurl, goodurl = urlspec
90-
# strip protocol and host -- we're making that configurable
91-
goodurl = re.sub("^https?://[a-z0-9.]+", "", goodurl)
92-
if not goodurl.startswith("/"):
93-
goodurl = "/" + goodurl
9490
else:
9591
raise ValueError("Expected 'HTTP_CODE TESTURL [GOODURL]' in %s line, found '%s'." % (filename, line))
9692

@@ -187,34 +183,42 @@ def doCanonicalize(self, url, content):
187183
return content
188184

189185
def doDiff(self, tuple, response):
190-
if not self.ref_prefix:
191-
return
192186
(codes, url, master) = tuple
187+
if not self.ref_prefix and not master:
188+
return
193189
if "skipdiff" in codes:
194190
return
195-
refurl = self.ref_prefix+url
196-
print " Fetching "+refurl
197-
refhtml = None
198-
try:
199-
mfile = urllib.urlopen(refurl)
191+
if master:
192+
cwd = os.getcwd()
193+
master = os.path.join(cwd, master)
194+
mfile = open(master)
200195
refhtml = mfile.read()
201196
mfile.close()
202-
except Exception, e:
203-
print " Error retrieving %s: %s" % (refurl, e)
204-
return
205-
testhtml = self.doCanonicalize(url, response.content)
197+
else:
198+
refurl = self.ref_prefix+url
199+
print " Fetching "+refurl
200+
refhtml = None
201+
try:
202+
mfile = urllib.urlopen(refurl)
203+
refhtml = mfile.read()
204+
mfile.close()
205+
except Exception, e:
206+
print " Error retrieving %s: %s" % (refurl, e)
207+
return
206208
refhtml = self.doCanonicalize(url, refhtml)
209+
testhtml = self.doCanonicalize(url, response.content)
210+
207211
#print "REFERENCE:\n----------------------\n"+refhtml+"\n-------------\n"
208212
#print "TEST:\n----------------------\n"+testhtml+"\n-------------\n"
209213

210214
list0 = refhtml.split("\n")
211215
list1 = testhtml.split("\n")
212-
diff = "\n".join(unified_diff(list0, list1, refurl, url, "", "", 0, lineterm=""))
216+
diff = "\n".join(unified_diff(list0, list1, master or refurl, url, "", "", 0, lineterm=""))
213217
if diff:
214218
print " Differences found:"
215219
print diff
216220
else:
217-
print " No differences found"
221+
print " No differences found with %s" % master
218222

219223
def canonicalize_feed(s):
220224
# Django 0.96 handled time zone different -- ignore it for now

0 commit comments

Comments
 (0)