@@ -0,0 +1,2254 @@
+#!/usr/bin/env python3%0A#%0A# Copyright 2022 Miklos Vajna. All rights reserved.%0A# Use of this source code is governed by a BSD-style license that can be%0A# found in the LICENSE file.%0A#%0A# Takes a HTML output from llvm-cov and shows uncovered lines.%0A%0Afrom html.parser import HTMLParser%0Aimport os%0Aimport sys%0A%0Aclass Parser(HTMLParser):%0A    def __init__(self):%0A        HTMLParser.__init__(self)%0A        self.in_line_number = False%0A        self.line_number = %22%22%0A        self.in_uncovered_line = False%0A        self.uncovered_line = %22%22%0A        self.uncovered_lines = %5B%5D%0A%0A    def handle_starttag(self, tag, attrs):%0A        if tag == %22td%22:%0A            for k, v in attrs:%0A                if k == %22class%22 and v == %22line-number%22:%0A                    self.in_line_number = True%0A                    self.line_number = %22%22%0A                elif k == %22class%22 and v == %22uncovered-line%22:%0A                    self.in_uncovered_line = True%0A                    self.uncovered_line = %22%22%0A%0A    def handle_endtag(self, tag):%0A        if self.in_line_number:%0A            self.in_line_number = False%0A        elif self.in_uncovered_line:%0A            self.in_uncovered_line = False%0A            if self.uncovered_line == %220%22:%0A                self.uncovered_lines.append(self.line_number)%0A%0A    def handle_data(self, data):%0A        if self.in_line_number:%0A            self.line_number += data%0A        elif self.in_uncovered_line:%0A            self.uncovered_line += data%0A%0Adef show_missing_for_path(path) -%3E None:%0A    relpath = path%0A    relpath = relpath.replace(os.getcwd(), %22%22)%0A    relpath = relpath.replace(%22target/llvm-cov/html/coverage/%22, %22%22)%0A    relpath = relpath.replace(%22.rs.html%22, %22.rs%22)%0A    with open(path) as stream:%0A        parser = Parser()%0A        parser.feed(stream.read())%0A        for uncovered_line in sorted(set(parser.uncovered_lines)):%0A            print(%22%7B%7D:%7B%7D%22.format(relpath, uncovered_line))%0A%0A%0Aif __name__ == %22__main__%22:%0A    root = %22target/llvm-cov/html/coverage/%22%0A    if len(sys.argv) %3E 1:%0A        paths = sys.argv%5B1:%5D%0A    else:%0A        paths = sorted(set(%5Bos.path.join(dp, f) for dp, dn, filenames in os.walk(root) for f in filenames if f.endswith(%22.rs.html%22)%5D))%0A    for path in paths:%0A        show_missing_for_path(path)%0A%0A# vim:set shiftwidth=4 softtabstop=4 expandtab:%0A

add coverage_show_missing.py