-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code coverage tooling #448
base: main
Are you sure you want to change the base?
Changes from all commits
b3e4aa5
78e089f
8e4de04
7d14cb9
2ce88c8
e31fe11
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,6 @@ Cargo.lock | |
Session.vim | ||
|
||
.env | ||
|
||
# grcov outputs | ||
*.profraw |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,19 @@ | ||||||||||||||||||||||||||||||||||||||||||
#!/bin/sh -e | ||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the |
||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
# cleanly run the following commands in their own session | ||||||||||||||||||||||||||||||||||||||||||
bash -c " | ||||||||||||||||||||||||||||||||||||||||||
# tell Rust to run with coverage instrumentation | ||||||||||||||||||||||||||||||||||||||||||
RUSTFLAGS=\"-Cinstrument-coverage\" | ||||||||||||||||||||||||||||||||||||||||||
# give grcov a profile name template for output files | ||||||||||||||||||||||||||||||||||||||||||
LLVM_PROFILE_FILE=\"svix-webhooks-%p-%m.profraw\" | ||||||||||||||||||||||||||||||||||||||||||
# put the compiler in nightly mode | ||||||||||||||||||||||||||||||||||||||||||
RUSTC_BOOTSTRAP=1 | ||||||||||||||||||||||||||||||||||||||||||
svix-dylan marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
# run tests | ||||||||||||||||||||||||||||||||||||||||||
./run-tests.sh | ||||||||||||||||||||||||||||||||||||||||||
" || true | ||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+4
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are you doing this in a subscript like this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So that these variables are only set in this new session, and don't affect rustc in any subsequent commands a developer might run unrelated to this script. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you do this:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You don't need to do anything, it won't affect anything outside of the script.
Comment on lines
+4
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
And then in run-tests:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or better yet, just tell people to use nightly (see other comment), and then: #!/bin/sh -e
# tell Rust to run with coverage instrumentation
export RUSTFLAGS="-Cinstrument-coverage"
# give grcov a profile name template for output files
export DIRNAME="./target/debug/coverage/$(date -u --iso-8601=seconds)"
mkdir -p "$DIRNAME"
export LLVM_PROFILE_FILE="$DIRNAME/svix-webhooks-%p-%m.profraw"
echo "Collecting coverage in $DIRNAME"
# run tests
./run-tests.sh
# generate and open report output
echo "Generating coverage report (may take time)."
~/.cargo/bin/grcov "$DIRNAME" -s svix-server --binary-path ./target/debug/ -t html --branch --ignore-not-existing -o "$DIRNAME"
echo "Coverage HTML file at:\n$(pwd)/$DIRNAME/index.html" |
||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
# generate and open report output | ||||||||||||||||||||||||||||||||||||||||||
grcov . -s . --binary-path ./target/debug/ -t html --branch --ignore-not-existing -o ./target/debug/coverage/ | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
echo "coverage HTML file at $(pwd)/target/debug/coverage/index.html" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't work if default is not set to nightly. Probably just need to say "use nightly" which will also simplify the rest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran both of these install commands on stable successfully
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, they install fine, but I had issues. Though maybe my issues were unrelated.