tiffany352 / rink-rs

Unit conversion tool and library written in rust
https://rinkcalc.app/about
GNU General Public License v3.0
442 stars 28 forks source link

Add more tests #127

Closed tiffany352 closed 2 years ago

tiffany352 commented 2 years ago

Now that I have working code coverage I can start trying to get the code coverage percent back to where it was in the past.

I realized recently that chrono-humanize has an API that takes a duration instead of a straight date, allowing it to be deterministic, so I updated the tests with that.

Local development with coverage

Coverage Gutters VS code extension - set to watch mode.

tasks.json:

{
  "label": "rust: cargo test (with coverage)",
  "isTestCommand": true,
  "type": "process",
  "command": "sh",
  "args": [".vscode/coverage.sh"],
  "problemMatcher": ["$rustc"]
}

.vscode/coverage.sh:

#!/bin/sh

export RUSTFLAGS="-C instrument-coverage"
export LLVM_PROFILE_FILE="$(pwd)/coverage/profraws/%p-%m.profraw"
export RUST_TOOLCHAIN="nightly"

mkdir -p coverage/profraws
rm coverage/profraws/*
cargo +nightly test --all
grcov coverage/profraws/* --binary-path target/debug/ -t lcov -o coverage/lcov.info
echo 'Coverage information updated.'

Note: If you use a non-standard target directory location like I do, then update the --binary-path.

codecov[bot] commented 2 years ago

Codecov Report

Merging #127 (21e1699) into master (aedcb26) will increase coverage by 1.06%. The diff coverage is 83.97%.

@@            Coverage Diff             @@
##           master     #127      +/-   ##
==========================================
+ Coverage   62.58%   63.64%   +1.06%     
==========================================
  Files          55       55              
  Lines       10155    10245      +90     
==========================================
+ Hits         6355     6520     +165     
+ Misses       3800     3725      -75     
Impacted Files Coverage Δ
core/src/ast/mod.rs 19.84% <47.91%> (+8.33%) :arrow_up:
core/src/algorithms/btree_merge.rs 100.00% <100.00%> (+2.70%) :arrow_up:
core/src/ast/def.rs 97.82% <100.00%> (+14.49%) :arrow_up:
core/src/ast/expr.rs 100.00% <100.00%> (+1.19%) :arrow_up:
core/src/ast/query.rs 97.14% <100.00%> (+61.84%) :arrow_up:
core/src/commands/factorize.rs 100.00% <100.00%> (+7.14%) :arrow_up:
core/src/loader/context.rs 90.58% <100.00%> (+2.35%) :arrow_up:
core/src/parsing/datetime.rs 94.56% <100.00%> (+0.65%) :arrow_up:
core/tests/query.rs 99.83% <100.00%> (+<0.01%) :arrow_up:
core/src/output/reply.rs 80.20% <0.00%> (ø)
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update aedcb26...21e1699. Read the comment docs.