Skip to content

Commit 13a89d3

Browse files
authored
enforce 100% code/test coverage (#43)
* adding progress * trying this * more specific git ignore * fix command * there's some bug * print what I'm parsing * remove unuseful assert * revert rmq * trying fix * trying this fix * fix unused code warning * fix * fix compile error * another fix * removing ONLY TO TEST CI; WILL REVERT * fix * remove unused function for now * remove add_var from example * make not executable * revert * revert --------- Co-authored-by: Luke Videckis <lukevideckis@gmail.com>
1 parent b0dab47 commit 13a89d3

File tree

12 files changed

+30
-28
lines changed

12 files changed

+30
-28
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import sys, json
2+
3+
dt=json.load(sys.stdin)['data'][0]['totals']
4+
5+
print(json.dumps(dt, indent=4))
6+
7+
assert(dt['branches']['count'] == dt['branches']['covered'])
8+
assert(dt['functions']['count'] == dt['functions']['covered'])
9+
assert(dt['lines']['count'] == dt['lines']['covered'])
10+
assert(dt['regions']['count'] == dt['regions']['covered'])

.github/workflows/ci.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ on: [push, workflow_dispatch]
44

55
env:
66
CARGO_TERM_COLOR: always
7-
# `-D warnings` causes CI to fail on any warning
87
RUSTFLAGS: -D warnings -C instrument-coverage -C link-dead-code
9-
RUSTDOCFLAGS: -D warnings
8+
RUSTDOCFLAGS: -D warnings -D missing_docs
109

1110
jobs:
1211
cargo:
@@ -34,7 +33,7 @@ jobs:
3433
run: cargo test
3534

3635
- name: cargo doc
37-
run: RUSTDOCFLAGS="-D warnings -D missing_docs" cargo doc --all
36+
run: cargo doc --all
3837

3938
library_checker_aizu_tests:
4039
runs-on: ubuntu-latest
@@ -47,7 +46,7 @@ jobs:
4746
rustup install nightly
4847
rustup override set nightly
4948
rustup component add --toolchain nightly rustfmt clippy
50-
cargo install cargo-binutils
49+
cargo install cargo-binutils rustfilt
5150
rustup component add llvm-tools-preview
5251
5352
- name: install oj-verify submodule
@@ -76,8 +75,8 @@ jobs:
7675
run: oj-verify all --tle 20 --jobs 4 --timeout 21600
7776

7877
# https://doc.rust-lang.org/rustc/instrument-coverage.html
79-
# - name: code coverage
80-
# run: |
81-
# cargo profdata -- merge -sparse default_*.profraw -o json5format.profdata
82-
# cargo cov -- report --use-color --ignore-filename-regex='/.cargo/registry' --instr-profile=json5format.profdata $(find target/debug/examples -type f -executable)
83-
# cargo cov -- export --ignore-filename-regex='/.cargo/registry' --instr-profile=json5format.profdata $(find target/debug/examples -type f -executable) | python -c "import sys, json; l=json.load(sys.stdin)['data'][0]['totals']['lines']; assert(l['count'] == l['covered'])"
78+
- name: code coverage
79+
run: |
80+
cargo profdata -- merge -sparse default_*.profraw -o ptc_rust.profdata
81+
cargo cov -- show -Xdemangler=rustfilt --use-color --ignore-filename-regex='/.cargo/registry' --instr-profile=ptc_rust.profdata $(find target/debug/examples/ -type f -executable | sed 's/^/--object /')
82+
cargo cov -- export -Xdemangler=rustfilt --ignore-filename-regex='/.cargo/registry' --instr-profile=ptc_rust.profdata $(find target/debug/examples/ -type f -executable | sed 's/^/--object /') --summary-only | python .github/workflows/check_code_cov.py

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
/target
22
Cargo.lock
33
.verify-helper/
4+
default_*.profraw
5+
ptc_rust.profdata

examples/data_structures/binary_trie.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@ fn main() {
2626
trie.update(x, -1);
2727
}
2828
}
29-
2 => {
30-
println!("{}", trie.min_xor(x));
31-
}
32-
_ => unreachable!(),
29+
_ => println!("{}", trie.min_xor(x)),
3330
}
3431
}
3532
}

examples/data_structures/dsu_aizu.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ fn main() {
1515
0 => {
1616
dsu.unite(u, v);
1717
}
18-
1 => println!("{}", u8::from(dsu.same(u, v))),
19-
_ => unreachable!(),
18+
_ => println!("{}", u8::from(dsu.same(u, v))),
2019
}
2120
}
2221
}

examples/data_structures/dsu_yosupo.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ fn main() {
1515
0 => {
1616
dsu.unite(u, v);
1717
}
18-
1 => println!("{}", u8::from(dsu.same(u, v))),
19-
_ => unreachable!(),
18+
_ => println!("{}", u8::from(dsu.same(u, v))),
2019
}
2120
}
2221
}

examples/data_structures/fenwick_aizu.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,13 @@ fn main() {
2020
}
2121
fenwick.add(i - 1, x);
2222
}
23-
1 => {
23+
_ => {
2424
input! {
2525
le: usize,
2626
ri: usize,
2727
}
2828
println!("{}", fenwick.sum(le - 1..ri));
2929
}
30-
_ => unreachable!(),
3130
}
3231
}
3332
}

examples/data_structures/fenwick_yosupo.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,13 @@ fn main() {
2929
}
3030
fenwick.add(p, x);
3131
}
32-
1 => {
32+
_ => {
3333
input! {
3434
le: usize,
3535
ri: usize,
3636
}
3737
println!("{}", fenwick.sum(le..ri));
3838
}
39-
_ => unreachable!(),
4039
}
4140
}
4241
}

examples/data_structures/lazy_seg_tree.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,13 @@ fn main() {
2424
}
2525
seg_tree.update(le - 1, ri, delta);
2626
}
27-
1 => {
27+
_ => {
2828
input! {
2929
le: usize,
3030
ri: usize
3131
}
3232
println!("{}", seg_tree.query(le - 1, ri));
3333
}
34-
_ => unreachable!(),
3534
}
3635
}
3736
}

examples/data_structures/seg_tree_build_on_array.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,13 @@ fn main() {
2424
}
2525
seg_tree.update(p, p + 1, x);
2626
}
27-
1 => {
27+
_ => {
2828
input! {
2929
le: usize,
3030
ri: usize
3131
}
3232
println!("{}", seg_tree.query(le, ri));
3333
}
34-
_ => unreachable!(),
3534
}
3635
}
3736
}

0 commit comments

Comments
 (0)