@@ -130,11 +130,18 @@ def fetchUrl(self, plainUrl, transformedUrl, fetcherPlain, fetcherRewriting, rul
130130 logging .debug ("Fetching plain page %s" , plainUrl )
131131 # If we get an exception (e.g. connection refused,
132132 # connection timeout) on the plain page, don't treat
133- # that as a failure.
133+ # that as a failure (except DNS resolution errors)
134134 plainRcode , plainPage = None , None
135135 try :
136136 plainRcode , plainPage = fetcherPlain .fetchHtml (plainUrl )
137137 except Exception , e :
138+ errno , message = e
139+ if errno == 6 :
140+ message = "Fetch error: %s => %s: %s" % (
141+ plainUrl , transformedUrl , e )
142+ self .queue_result ("error" , "fetch-error %s" % e , ruleFname , plainUrl , https_url = transformedUrl )
143+ return message
144+
138145 logging .debug ("Non-fatal fetch error for plain page %s: %s" % (plainUrl , e ))
139146
140147 # Compare HTTP return codes - if original page returned 2xx,
@@ -290,6 +297,9 @@ def cli():
290297 checkCoverage = False
291298 if config .has_option ("rulesets" , "check_coverage" ):
292299 checkCoverage = config .getboolean ("rulesets" , "check_coverage" )
300+ checkTargetValidity = False
301+ if config .has_option ("rulesets" , "check_target_validity" ):
302+ checkTargetValidity = config .getboolean ("rulesets" , "check_target_validity" )
293303 checkNonmatchGroups = False
294304 if config .has_option ("rulesets" , "check_nonmatch_groups" ):
295305 checkNonmatchGroups = config .getboolean ("rulesets" , "check_nonmatch_groups" )
@@ -341,6 +351,7 @@ def cli():
341351
342352 rulesets = []
343353 coverageProblemsExist = False
354+ targetValidityProblemExist = False
344355 nonmatchGroupProblemsExist = False
345356 testFormattingProblemsExist = False
346357 for xmlFname in xmlFnames :
@@ -363,6 +374,12 @@ def cli():
363374 for problem in problems :
364375 coverageProblemsExist = True
365376 logging .error (problem )
377+ if checkTargetValidity :
378+ logging .debug ("Checking target validity for '%s'." % ruleset .name )
379+ problems = ruleset .getTargetValidityProblems ()
380+ for problem in problems :
381+ targetValidityProblemExist = True
382+ logging .error (problem )
366383 if checkNonmatchGroups :
367384 logging .debug ("Checking non-match groups for '%s'." % ruleset .name )
368385 problems = ruleset .getNonmatchGroupProblems ()
@@ -445,6 +462,9 @@ def cli():
445462 if checkCoverage :
446463 if coverageProblemsExist :
447464 return 1 # exit with error code
465+ if checkTargetValidity :
466+ if targetValidityProblemExist :
467+ return 1 # exit with error code
448468 if checkNonmatchGroups :
449469 if nonmatchGroupProblemsExist :
450470 return 1 # exit with error code
0 commit comments