fork/rust
git clone https://git.julia.blue/fork/rust
3bcad65fbf6
master
1#!/usr/bin/env python 2# -*- coding: utf-8 -*- 3 4r""" 5htmldocck.py is a custom checker script for Rustdoc HTML outputs. 6 7# How and why? 8 9The principle is simple: This script receives a path to generated HTML 10documentation and a "template" script, which has a series of check 11commands like `@has` or `@matches`. Each command is used to check if 12some pattern is present or not present in the particular file or in 13a particular node of the HTML tree. In many cases, the template script 14happens to be the source code given to rustdoc. 15 16While it indeed is possible to test in smaller portions, it has been 17hard to construct tests in this fashion and major rendering errors were 18discovered much later. This script is designed to make black-box and 19regression testing of Rustdoc easy. This does not preclude the needs for 20unit testing, but can be used to complement related tests by quickly 21showing the expected renderings. 22 23In order to avoid one-off dependencies for this task, this script uses 24a reasonably working HTML parser and the existing XPath implementation 25from Python's standard library. Hopefully, we won't render 26non-well-formed HTML. 27 28# Commands 29 30Commands start with an `@` followed by a command name (letters and 31hyphens), and zero or more arguments separated by one or more whitespace 32characters and optionally delimited with single or double quotes. The `@` 33mark cannot be preceded by a non-whitespace character. Other lines 34(including every text up to the first `@`) are ignored, but it is 35recommended to avoid the use of `@` in the template file. 36 37There are a number of supported commands: 38 39* `@has PATH` checks for the existence of the given file. 40 41 `PATH` is relative to the output directory. It can be given as `-` 42 which repeats the most recently used `PATH`. 43 44* `@hasraw PATH PATTERN` and `@matchesraw PATH PATTERN` checks 45 for the occurrence of the given pattern `PATTERN` in the specified file. 46 Only one occurrence of the pattern is enough. 47 48 For `@hasraw`, `PATTERN` is a whitespace-normalized (every consecutive 49 whitespace being replaced by one single space character) string. 50 The entire file is also whitespace-normalized including newlines. 51 52 For `@matchesraw`, `PATTERN` is a Python-supported regular expression. 53 The file remains intact but the regexp is matched without the `MULTILINE` 54 and `IGNORECASE` options. You can still use a prefix `(?m)` or `(?i)` 55 to override them, and `\A` and `\Z` for definitely matching 56 the beginning and end of the file. 57 58 (The same distinction goes to other variants of these commands.) 59 60* `@has PATH XPATH PATTERN` and `@matches PATH XPATH PATTERN` checks for 61 the presence of the given XPath `XPATH` in the specified HTML file, 62 and also the occurrence of the given pattern `PATTERN` in the matching 63 node or attribute. Only one occurrence of the pattern in the match 64 is enough. 65 66 `PATH` should be a valid and well-formed HTML file. It does *not* 67 accept arbitrary HTML5; it should have matching open and close tags 68 and correct entity references at least. 69 70 `XPATH` is an XPath expression to match. The XPath is fairly limited: 71 `tag`, `*`, `.`, `//`, `..`, `[@attr]`, `[@attr='value']`, `[tag]`, 72 `[POS]` (element located in given `POS`), `[last()-POS]`, `text()` 73 and `@attr` (both as the last segment) are supported. Some examples: 74 75 - `//pre` or `.//pre` matches any element with a name `pre`. 76 - `//a[@href]` matches any element with an `href` attribute. 77 - `//*[@class="impl"]//code` matches any element with a name `code`, 78 which is an ancestor of some element which `class` attr is `impl`. 79 - `//h1[@class="fqn"]/span[1]/a[last()]/@class` matches a value of 80 `class` attribute in the last `a` element (can be followed by more 81 elements that are not `a`) inside the first `span` in the `h1` with 82 a class of `fqn`. Note that there cannot be any additional elements 83 between them due to the use of `/` instead of `//`. 84 85 Do not try to use non-absolute paths, it won't work due to the flawed 86 ElementTree implementation. The script rejects them. 87 88 For the text matches (i.e. paths not ending with `@attr`), any 89 subelements are flattened into one string; this is handy for ignoring 90 highlights for example. If you want to simply check for the presence of 91 a given node or attribute, use an empty string (`""`) as a `PATTERN`. 92 93* `@count PATH XPATH COUNT` checks for the occurrence of the given XPath 94 in the specified file. The number of occurrences must match the given 95 count. 96 97* `@count PATH XPATH TEXT COUNT` checks for the occurrence of the given XPath 98 with the given text in the specified file. The number of occurrences must 99 match the given count. 100 101* `@snapshot NAME PATH XPATH` creates a snapshot test named NAME. 102 A snapshot test captures a subtree of the DOM, at the location 103 determined by the XPath, and compares it to a pre-recorded value 104 in a file. The file's name is the test's name with the `.rs` extension 105 replaced with `.NAME.html`, where NAME is the snapshot's name. 106 107 htmldocck supports the `--bless` option to accept the current subtree 108 as expected, saving it to the file determined by the snapshot's name. 109 compiletest's `--bless` flag is forwarded to htmldocck. 110 111* `@has-dir PATH` checks for the existence of the given directory. 112 113* `@files FOLDER_PATH [ENTRIES]`, checks that `FOLDER_PATH` contains exactly 114 `[ENTRIES]`. 115 116All conditions can be negated with `!`. `@!has foo/type.NoSuch.html` 117checks if the given file does not exist, for example. 118 119""" 120 121from __future__ import absolute_import, print_function, unicode_literals 122 123import codecs 124import io 125import sys 126import os.path 127import re 128import shlex 129from collections import namedtuple 130try: 131 from html.parser import HTMLParser 132except ImportError: 133 from HTMLParser import HTMLParser 134try: 135 from xml.etree import cElementTree as ET 136except ImportError: 137 from xml.etree import ElementTree as ET 138 139try: 140 from html.entities import name2codepoint 141except ImportError: 142 from htmlentitydefs import name2codepoint 143 144# "void elements" (no closing tag) from the HTML Standard section 12.1.2 145VOID_ELEMENTS = {'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen', 146 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr'} 147 148# Python 2 -> 3 compatibility 149try: 150 unichr # noqa: B018 FIXME: py2 151except NameError: 152 unichr = chr 153 154 155channel = os.environ["DOC_RUST_LANG_ORG_CHANNEL"] 156 157# Initialized in main 158rust_test_path = None 159bless = None 160 161class CustomHTMLParser(HTMLParser): 162 """simplified HTML parser. 163 164 this is possible because we are dealing with very regular HTML from 165 rustdoc; we only have to deal with i) void elements and ii) empty 166 attributes.""" 167 def __init__(self, target=None): 168 HTMLParser.__init__(self) 169 self.__builder = target or ET.TreeBuilder() 170 171 def handle_starttag(self, tag, attrs): 172 attrs = {k: v or '' for k, v in attrs} 173 self.__builder.start(tag, attrs) 174 if tag in VOID_ELEMENTS: 175 self.__builder.end(tag) 176 177 def handle_endtag(self, tag): 178 self.__builder.end(tag) 179 180 def handle_startendtag(self, tag, attrs): 181 attrs = {k: v or '' for k, v in attrs} 182 self.__builder.start(tag, attrs) 183 self.__builder.end(tag) 184 185 def handle_data(self, data): 186 self.__builder.data(data) 187 188 def handle_entityref(self, name): 189 self.__builder.data(unichr(name2codepoint[name])) 190 191 def handle_charref(self, name): 192 code = int(name[1:], 16) if name.startswith(('x', 'X')) else int(name, 10) 193 self.__builder.data(unichr(code)) 194 195 def close(self): 196 HTMLParser.close(self) 197 return self.__builder.close() 198 199 200Command = namedtuple('Command', 'negated cmd args lineno context') 201 202 203class FailedCheck(Exception): 204 pass 205 206 207class InvalidCheck(Exception): 208 pass 209 210 211def concat_multi_lines(f): 212 """returns a generator out of the file object, which 213 - removes `\\` then `\n` then a shared prefix with the previous line then 214 optional whitespace; 215 - keeps a line number (starting from 0) of the first line being 216 concatenated.""" 217 lastline = None # set to the last line when the last line has a backslash 218 firstlineno = None 219 catenated = '' 220 for lineno, line in enumerate(f): 221 line = line.rstrip('\r\n') 222 223 # strip the common prefix from the current line if needed 224 if lastline is not None: 225 common_prefix = os.path.commonprefix([line, lastline]) 226 line = line[len(common_prefix):].lstrip() 227 228 firstlineno = firstlineno or lineno 229 if line.endswith('\\'): 230 if lastline is None: 231 lastline = line[:-1] 232 catenated += line[:-1] 233 else: 234 yield firstlineno, catenated + line 235 lastline = None 236 firstlineno = None 237 catenated = '' 238 239 if lastline is not None: 240 print_err(lineno, line, 'Trailing backslash at the end of the file') 241 242 243LINE_PATTERN = re.compile(r''' 244 (?<=(?<!\S))(?P<invalid>!?)@(?P<negated>!?) 245 (?P<cmd>[A-Za-z]+(?:-[A-Za-z]+)*) 246 (?P<args>.*)$ 247''', re.X | re.UNICODE) 248 249 250def get_commands(template): 251 with io.open(template, encoding='utf-8') as f: 252 for lineno, line in concat_multi_lines(f): 253 m = LINE_PATTERN.search(line) 254 if not m: 255 continue 256 257 negated = (m.group('negated') == '!') 258 cmd = m.group('cmd') 259 if m.group('invalid') == '!': 260 print_err( 261 lineno, 262 line, 263 'Invalid command: `!@{0}{1}`, (help: try with `@!{1}`)'.format( 264 '!' if negated else '', 265 cmd, 266 ), 267 ) 268 continue 269 args = m.group('args') 270 if args and not args[:1].isspace(): 271 print_err(lineno, line, 'Invalid template syntax') 272 continue 273 try: 274 args = shlex.split(args) 275 except UnicodeEncodeError: 276 args = [arg.decode('utf-8') for arg in shlex.split(args.encode('utf-8'))] 277 except Exception as exc: 278 raise Exception("line {}: {}".format(lineno + 1, exc)) from None 279 yield Command(negated=negated, cmd=cmd, args=args, lineno=lineno+1, context=line) 280 281 282def _flatten(node, acc): 283 if node.text: 284 acc.append(node.text) 285 for e in node: 286 _flatten(e, acc) 287 if e.tail: 288 acc.append(e.tail) 289 290 291def flatten(node): 292 acc = [] 293 _flatten(node, acc) 294 return ''.join(acc) 295 296 297def make_xml(text): 298 xml = ET.XML('<xml>%s</xml>' % text) 299 return xml 300 301 302def normalize_xpath(path): 303 path = path.replace("{{channel}}", channel) 304 if path.startswith('//'): 305 return '.' + path # avoid warnings 306 elif path.startswith('.//'): 307 return path 308 else: 309 raise InvalidCheck('Non-absolute XPath is not supported due to implementation issues') 310 311 312class CachedFiles(object): 313 def __init__(self, root): 314 self.root = root 315 self.files = {} 316 self.trees = {} 317 self.last_path = None 318 319 def resolve_path(self, path): 320 if path != '-': 321 path = os.path.normpath(path) 322 self.last_path = path 323 return path 324 elif self.last_path is None: 325 raise InvalidCheck('Tried to use the previous path in the first command') 326 else: 327 return self.last_path 328 329 def get_absolute_path(self, path): 330 return os.path.join(self.root, path) 331 332 def get_file(self, path): 333 path = self.resolve_path(path) 334 if path in self.files: 335 return self.files[path] 336 337 abspath = self.get_absolute_path(path) 338 if not(os.path.exists(abspath) and os.path.isfile(abspath)): 339 raise FailedCheck('File does not exist {!r}'.format(path)) 340 341 with io.open(abspath, encoding='utf-8') as f: 342 data = f.read() 343 self.files[path] = data 344 return data 345 346 def get_tree(self, path): 347 path = self.resolve_path(path) 348 if path in self.trees: 349 return self.trees[path] 350 351 abspath = self.get_absolute_path(path) 352 if not(os.path.exists(abspath) and os.path.isfile(abspath)): 353 raise FailedCheck('File does not exist {!r}'.format(path)) 354 355 with io.open(abspath, encoding='utf-8') as f: 356 try: 357 tree = ET.fromstringlist(f.readlines(), CustomHTMLParser()) 358 except Exception as e: 359 raise RuntimeError( # noqa: B904 FIXME: py2 360 'Cannot parse an HTML file {!r}: {}'.format(path, e) 361 ) 362 self.trees[path] = tree 363 return self.trees[path] 364 365 def get_dir(self, path): 366 path = self.resolve_path(path) 367 abspath = self.get_absolute_path(path) 368 if not(os.path.exists(abspath) and os.path.isdir(abspath)): 369 raise FailedCheck('Directory does not exist {!r}'.format(path)) 370 371 372def check_string(data, pat, regexp): 373 pat = pat.replace("{{channel}}", channel) 374 if not pat: 375 return True # special case a presence testing 376 elif regexp: 377 return re.search(pat, data, flags=re.UNICODE) is not None 378 else: 379 data = ' '.join(data.split()) 380 pat = ' '.join(pat.split()) 381 return pat in data 382 383 384def check_tree_attr(tree, path, attr, pat, regexp): 385 path = normalize_xpath(path) 386 ret = False 387 for e in tree.findall(path): 388 if attr in e.attrib: 389 value = e.attrib[attr] 390 else: 391 continue 392 393 ret = check_string(value, pat, regexp) 394 if ret: 395 break 396 return ret 397 398 399# Returns the number of occurrences matching the regex (`regexp`) and the text (`pat`). 400def check_tree_text(tree, path, pat, regexp, stop_at_first): 401 path = normalize_xpath(path) 402 match_count = 0 403 try: 404 for e in tree.findall(path): 405 try: 406 value = flatten(e) 407 except KeyError: 408 continue 409 else: 410 if check_string(value, pat, regexp): 411 match_count += 1 412 if stop_at_first: 413 break 414 except Exception: 415 print('Failed to get path "{}"'.format(path)) 416 raise 417 return match_count 418 419 420def get_tree_count(tree, path): 421 path = normalize_xpath(path) 422 return len(tree.findall(path)) 423 424 425def check_snapshot(snapshot_name, actual_tree, normalize_to_text): 426 assert rust_test_path.endswith('.rs') 427 snapshot_path = '{}.{}.{}'.format(rust_test_path[:-3], snapshot_name, 'html') 428 try: 429 with open(snapshot_path, 'r') as snapshot_file: 430 expected_str = snapshot_file.read().replace("{{channel}}", channel) 431 except FileNotFoundError: 432 if bless: 433 expected_str = None 434 else: 435 raise FailedCheck('No saved snapshot value') # noqa: B904 FIXME: py2 436 437 if not normalize_to_text: 438 actual_str = ET.tostring(actual_tree).decode('utf-8') 439 else: 440 actual_str = flatten(actual_tree) 441 442 # Conditions: 443 # 1. Is --bless 444 # 2. Are actual and expected tree different 445 # 3. Are actual and expected text different 446 if not expected_str \ 447 or (not normalize_to_text and \ 448 not compare_tree(make_xml(actual_str), make_xml(expected_str), stderr)) \ 449 or (normalize_to_text and actual_str != expected_str): 450 451 if bless: 452 with open(snapshot_path, 'w') as snapshot_file: 453 actual_str = actual_str.replace(channel, "{{channel}}") 454 snapshot_file.write(actual_str) 455 else: 456 print('--- expected ---\n') 457 print(expected_str) 458 print('\n\n--- actual ---\n') 459 print(actual_str) 460 print() 461 raise FailedCheck('Actual snapshot value is different than expected') 462 463 464# Adapted from https://github.com/formencode/formencode/blob/3a1ba9de2fdd494dd945510a4568a3afeddb0b2e/formencode/doctest_xml_compare.py#L72-L120 465def compare_tree(x1, x2, reporter=None): 466 if x1.tag != x2.tag: 467 if reporter: 468 reporter('Tags do not match: %s and %s' % (x1.tag, x2.tag)) 469 return False 470 for name, value in x1.attrib.items(): 471 if x2.attrib.get(name) != value: 472 if reporter: 473 reporter('Attributes do not match: %s=%r, %s=%r' 474 % (name, value, name, x2.attrib.get(name))) 475 return False 476 for name in x2.attrib: 477 if name not in x1.attrib: 478 if reporter: 479 reporter('x2 has an attribute x1 is missing: %s' 480 % name) 481 return False 482 if not text_compare(x1.text, x2.text): 483 if reporter: 484 reporter('text: %r != %r' % (x1.text, x2.text)) 485 return False 486 if not text_compare(x1.tail, x2.tail): 487 if reporter: 488 reporter('tail: %r != %r' % (x1.tail, x2.tail)) 489 return False 490 cl1 = list(x1) 491 cl2 = list(x2) 492 if len(cl1) != len(cl2): 493 if reporter: 494 reporter('children length differs, %i != %i' 495 % (len(cl1), len(cl2))) 496 return False 497 i = 0 498 for c1, c2 in zip(cl1, cl2): 499 i += 1 500 if not compare_tree(c1, c2, reporter=reporter): 501 if reporter: 502 reporter('children %i do not match: %s' 503 % (i, c1.tag)) 504 return False 505 return True 506 507 508def text_compare(t1, t2): 509 if not t1 and not t2: 510 return True 511 if t1 == '*' or t2 == '*': 512 return True 513 return (t1 or '').strip() == (t2 or '').strip() 514 515 516def stderr(*args): 517 if sys.version_info.major < 3: 518 file = codecs.getwriter('utf-8')(sys.stderr) 519 else: 520 file = sys.stderr 521 522 print(*args, file=file) 523 524 525def print_err(lineno, context, err, message=None): 526 global ERR_COUNT 527 ERR_COUNT += 1 528 stderr("{}: {}".format(lineno, message or err)) 529 if message and err: 530 stderr("\t{}".format(err)) 531 532 if context: 533 stderr("\t{}".format(context)) 534 535 536def get_nb_matching_elements(cache, c, regexp, stop_at_first): 537 tree = cache.get_tree(c.args[0]) 538 pat, sep, attr = c.args[1].partition('/@') 539 if sep: # attribute 540 tree = cache.get_tree(c.args[0]) 541 return check_tree_attr(tree, pat, attr, c.args[2], False) 542 else: # normalized text 543 pat = c.args[1] 544 if pat.endswith('/text()'): 545 pat = pat[:-7] 546 return check_tree_text(cache.get_tree(c.args[0]), pat, c.args[2], regexp, stop_at_first) 547 548 549def check_files_in_folder(c, cache, folder, files): 550 files = files.strip() 551 if not files.startswith('[') or not files.endswith(']'): 552 raise InvalidCheck("Expected list as second argument of @{} (ie '[]')".format(c.cmd)) 553 554 folder = cache.get_absolute_path(folder) 555 556 # First we create a set of files to check if there are duplicates. 557 files = shlex.split(files[1:-1].replace(",", "")) 558 files_set = set() 559 for file in files: 560 if file in files_set: 561 raise InvalidCheck("Duplicated file `{}` in @{}".format(file, c.cmd)) 562 files_set.add(file) 563 folder_set = set([f for f in os.listdir(folder) if f != "." and f != ".."]) 564 565 # Then we remove entries from both sets (we clone `folder_set` so we can iterate it while 566 # removing its elements). 567 for entry in set(folder_set): 568 if entry in files_set: 569 files_set.remove(entry) 570 folder_set.remove(entry) 571 572 error = 0 573 if len(files_set) != 0: 574 print_err(c.lineno, c.context, "Entries not found in folder `{}`: `{}`".format( 575 folder, files_set)) 576 error += 1 577 if len(folder_set) != 0: 578 print_err(c.lineno, c.context, "Extra entries in folder `{}`: `{}`".format( 579 folder, folder_set)) 580 error += 1 581 return error == 0 582 583 584ERR_COUNT = 0 585 586 587def check_command(c, cache): 588 try: 589 cerr = "" 590 if c.cmd in ['has', 'hasraw', 'matches', 'matchesraw']: # string test 591 regexp = c.cmd.startswith('matches') 592 593 # @has <path> = file existence 594 if len(c.args) == 1 and not regexp and 'raw' not in c.cmd: 595 try: 596 cache.get_file(c.args[0]) 597 ret = True 598 except FailedCheck as err: 599 cerr = str(err) 600 ret = False 601 # @hasraw/matchesraw <path> <pat> = string test 602 elif len(c.args) == 2 and 'raw' in c.cmd: 603 cerr = "`PATTERN` did not match" 604 ret = check_string(cache.get_file(c.args[0]), c.args[1], regexp) 605 # @has/matches <path> <pat> <match> = XML tree test 606 elif len(c.args) == 3 and 'raw' not in c.cmd: 607 cerr = "`XPATH PATTERN` did not match" 608 ret = get_nb_matching_elements(cache, c, regexp, True) != 0 609 else: 610 raise InvalidCheck('Invalid number of @{} arguments'.format(c.cmd)) 611 612 elif c.cmd == 'files': # check files in given folder 613 if len(c.args) != 2: # @files <folder path> <file list> 614 raise InvalidCheck("Invalid number of @{} arguments".format(c.cmd)) 615 elif c.negated: 616 raise InvalidCheck("@{} doesn't support negative check".format(c.cmd)) 617 ret = check_files_in_folder(c, cache, c.args[0], c.args[1]) 618 619 elif c.cmd == 'count': # count test 620 if len(c.args) == 3: # @count <path> <pat> <count> = count test 621 expected = int(c.args[2]) 622 found = get_tree_count(cache.get_tree(c.args[0]), c.args[1]) 623 cerr = "Expected {} occurrences but found {}".format(expected, found) 624 ret = expected == found 625 elif len(c.args) == 4: # @count <path> <pat> <text> <count> = count test 626 expected = int(c.args[3]) 627 found = get_nb_matching_elements(cache, c, False, False) 628 cerr = "Expected {} occurrences but found {}".format(expected, found) 629 ret = found == expected 630 else: 631 raise InvalidCheck('Invalid number of @{} arguments'.format(c.cmd)) 632 633 elif c.cmd == 'snapshot': # snapshot test 634 if len(c.args) == 3: # @snapshot <snapshot-name> <html-path> <xpath> 635 [snapshot_name, html_path, pattern] = c.args 636 tree = cache.get_tree(html_path) 637 xpath = normalize_xpath(pattern) 638 normalize_to_text = False 639 if xpath.endswith('/text()'): 640 xpath = xpath[:-7] 641 normalize_to_text = True 642 643 subtrees = tree.findall(xpath) 644 if len(subtrees) == 1: 645 [subtree] = subtrees 646 try: 647 check_snapshot(snapshot_name, subtree, normalize_to_text) 648 ret = True 649 except FailedCheck as err: 650 cerr = str(err) 651 ret = False 652 elif len(subtrees) == 0: 653 raise FailedCheck('XPATH did not match') 654 else: 655 raise FailedCheck('Expected 1 match, but found {}'.format(len(subtrees))) 656 else: 657 raise InvalidCheck('Invalid number of @{} arguments'.format(c.cmd)) 658 659 elif c.cmd == 'has-dir': # has-dir test 660 if len(c.args) == 1: # @has-dir <path> = has-dir test 661 try: 662 cache.get_dir(c.args[0]) 663 ret = True 664 except FailedCheck as err: 665 cerr = str(err) 666 ret = False 667 else: 668 raise InvalidCheck('Invalid number of @{} arguments'.format(c.cmd)) 669 670 elif c.cmd == 'valid-html': 671 raise InvalidCheck('Unimplemented @valid-html') 672 673 elif c.cmd == 'valid-links': 674 raise InvalidCheck('Unimplemented @valid-links') 675 676 else: 677 raise InvalidCheck('Unrecognized @{}'.format(c.cmd)) 678 679 if ret == c.negated: 680 raise FailedCheck(cerr) 681 682 except FailedCheck as err: 683 message = '@{}{} check failed'.format('!' if c.negated else '', c.cmd) 684 print_err(c.lineno, c.context, str(err), message) 685 except InvalidCheck as err: 686 print_err(c.lineno, c.context, str(err)) 687 688 689def check(target, commands): 690 cache = CachedFiles(target) 691 for c in commands: 692 check_command(c, cache) 693 694 695if __name__ == '__main__': 696 if len(sys.argv) not in [3, 4]: 697 stderr('Usage: {} <doc dir> <template> [--bless]'.format(sys.argv[0])) 698 raise SystemExit(1) 699 700 rust_test_path = sys.argv[2] 701 if len(sys.argv) > 3 and sys.argv[3] == '--bless': 702 bless = True 703 else: 704 # We only support `--bless` at the end of the arguments. 705 # This assert is to prevent silent failures. 706 assert '--bless' not in sys.argv 707 bless = False 708 check(sys.argv[1], get_commands(rust_test_path)) 709 if ERR_COUNT: 710 stderr("\nEncountered {} errors".format(ERR_COUNT)) 711 raise SystemExit(1)