-
Notifications
You must be signed in to change notification settings - Fork 526
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
31805b4
commit 2e355bc
Showing
5 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
*.swp | ||
*.swo | ||
*.pyc | ||
*.profraw | ||
.mypy_cache/ | ||
|
||
target/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") | ||
# sys.stderr.write(str(soup) + "\n") | ||
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(): | ||
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() |