Add coverage check
This commit is contained in:
parent
4a94c882af
commit
ad39ccf6a5
|
|
@ -58,6 +58,10 @@ jobs:
|
||||||
if: always()
|
if: always()
|
||||||
run: bin/check/rust_version.py 7
|
run: bin/check/rust_version.py 7
|
||||||
|
|
||||||
|
- name: Coverage
|
||||||
|
if: always()
|
||||||
|
run: bin/check/coverage.sh
|
||||||
|
|
||||||
- name: Rustfmt
|
- name: Rustfmt
|
||||||
if: always()
|
if: always()
|
||||||
run: bin/check/rustfmt.sh
|
run: bin/check/rustfmt.sh
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
*.swp
|
*.swp
|
||||||
*.swo
|
*.swo
|
||||||
*.pyc
|
*.pyc
|
||||||
|
*.profraw
|
||||||
.mypy_cache/
|
.mypy_cache/
|
||||||
|
|
||||||
target/
|
target/
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -Eeuo pipefail
|
||||||
|
bin/install_prerequisites_ubuntu.sh
|
||||||
|
bin/install_grcov.sh
|
||||||
|
bin/test/test_prerequisites.sh
|
||||||
|
bin/coverage_run.sh
|
||||||
|
lines=$(bin/coverage_uncovered_lines.py packages/hurlfmt/src/format/json.rs)
|
||||||
|
if [ -n "$lines" ]; then
|
||||||
|
echo "$lines"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -Eeuo pipefail
|
||||||
|
|
||||||
|
rm -rf target/profile
|
||||||
|
rm -rf target/coverage
|
||||||
|
cargo clean
|
||||||
|
|
||||||
|
RUSTFLAGS="-Cinstrument-coverage"
|
||||||
|
export RUSTFLAGS
|
||||||
|
LLVM_PROFILE_FILE="$(pwd)/target/profile/test-integ-%p-%m.profraw"
|
||||||
|
export LLVM_PROFILE_FILE
|
||||||
|
|
||||||
|
cargo build
|
||||||
|
PATH=$(pwd)/target/debug:$PATH
|
||||||
|
export PATH
|
||||||
|
bin/test/test_integ.sh
|
||||||
|
grcov target/profile \
|
||||||
|
--binary-path target/debug \
|
||||||
|
--source-dir . \
|
||||||
|
--output-types html \
|
||||||
|
--branch \
|
||||||
|
--ignore-not-existing \
|
||||||
|
--output-path target/coverage
|
||||||
|
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
import sys
|
||||||
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
|
COVERAGE_DIR = "target/coverage"
|
||||||
|
|
||||||
|
|
||||||
|
def uncovered_lines(src_file):
|
||||||
|
html_file = COVERAGE_DIR + "/" + src_file + ".html"
|
||||||
|
sys.stderr.write(html_file + "\n")
|
||||||
|
html = open(html_file).read()
|
||||||
|
soup = BeautifulSoup(html, "html.parser")
|
||||||
|
elements = soup.select('div[role="row"]')
|
||||||
|
lines = []
|
||||||
|
for element in elements:
|
||||||
|
line = parse_row(element)
|
||||||
|
if line is not None:
|
||||||
|
lines.append(line)
|
||||||
|
return lines
|
||||||
|
|
||||||
|
|
||||||
|
def parse_row(element):
|
||||||
|
uncovered = element.select(".has-background-danger-light")
|
||||||
|
if len(uncovered) > 0:
|
||||||
|
line_number = element.select("div:first-child")[0]["id"]
|
||||||
|
line = uncovered[0].select("pre")[0].text
|
||||||
|
return line_number, line
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
sys.stderr.write("Extracting uncovered lines\n")
|
||||||
|
for src_file in sys.argv[1:]:
|
||||||
|
lines = uncovered_lines(src_file)
|
||||||
|
if len(lines) > 0:
|
||||||
|
print(src_file)
|
||||||
|
for line_number, line in lines:
|
||||||
|
print("%s %s" % (line_number, line))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Loading…
Reference in New Issue