Skip to content

Fix payjoin-cli v1 coverage#532

Merged
spacebear21 merged 6 commits intopayjoin:masterfrom
spacebear21:payjoin-cli-interrupt
Feb 7, 2025
Merged

Fix payjoin-cli v1 coverage#532
spacebear21 merged 6 commits intopayjoin:masterfrom
spacebear21:payjoin-cli-interrupt

Conversation

@spacebear21
Copy link
Collaborator

@spacebear21 spacebear21 commented Feb 7, 2025

Fix #499

This required a few changes:

  • Add an explicit llvm-cov command for running the payjoin-cli v1 e2e test, as it is not currently covered by --all-features.
  • Add graceful SIGINT handling to payjoin-cli v1.
  • Modify the sigint test function to wait until the child process completely exits, so that the interrupt handlers can actually print to stdout without panicking (failed printing to stdout: Broken pipe (os error 32)). This issue also affected the payjoin-cli v2 test, so this fix reduces the noise there as well (see Fix payjoin-cli v1 coverage #499 (comment)).
  • Remove unnecessary tokio::spawns in tests which moved cli.stdout out of the main loop, also causing panics like the former in interrupt handlers.
  • The last commit only refactors and extracts shared e2e testing code.

The v1 e2e test is feature-gated behind `not(feature = "v2")`, so it
doesn't run when --all-features is enabled. This change ensures v1
coverage is reported.
Exiting cleanly allows other processes to complete (e.g. coverage
reports).
Ensure that the child process completes its handling of the interrupt
signal. This prevents the child process from panicking with `failed
printing to stdout: Broken pipe (os error 32)` when it tries to print to
stdout in the interrupt handler.
There is no obvious reason to spawn new tasks only for the purpose of
reading and writing from/to stdout.

More importantly, this behavior previously caused the payjoin-cli
interrupt handlers to panic with `failed printing to stdout: Broken pipe
(os error 32)` due to `stdout` getting dropped by the time sigint is
called. This ensures `stdout` lives long enough for the interrupt
message to print.
Avoid repetition by introducing `wait_for_stdout_match` which reads from
stdout until a match is found against the given pattern.

Note: it's important that `child_stdout` lives long enough, until
`sigint` is called on the child process. Otherwise the interrupt handler
would try to `println!` to a dropped stdout and panic.
@coveralls
Copy link
Collaborator

coveralls commented Feb 7, 2025

Pull Request Test Coverage Report for Build 13203104215

Details

  • 14 of 15 (93.33%) changed or added relevant lines in 2 files are covered.
  • 4 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.03%) to 79.049%

Changes Missing Coverage Covered Lines Changed/Added Lines %
payjoin-cli/src/app/mod.rs 5 6 83.33%
Files with Coverage Reduction New Missed Lines %
payjoin-cli/src/app/config.rs 1 95.56%
payjoin-cli/src/db/error.rs 3 0.0%
Totals Coverage Status
Change from base Build 13170265281: -0.03%
Covered Lines: 4022
Relevant Lines: 5088

💛 - Coveralls

Copy link
Collaborator

@nothingmuch nothingmuch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK. This was very easy to review, great commit messages, clear changes, couldn't ask for a better PR. One tiny nit, sigint now no longer just sends a signint, maybe it should be renamed to terminate or something more descriptive?

I was also kind of surprised at the coverage report comment (not so much the report itself) since comparing the actual new & base reports, v1.rs is indeed included whereas before it wasn't, but the summary doesn't seem to take this into account.

Copy link
Collaborator

@nothingmuch nothingmuch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, meant to approve

It no longer just sends a sigint, so rename it to something more
descriptive.
@spacebear21
Copy link
Collaborator Author

I was also kind of surprised at the coverage report comment (not so much the report itself) since comparing the actual new & base reports, v1.rs is indeed included whereas before it wasn't, but the summary doesn't seem to take this into account.

That is surprising 🤔 it even shows v1.rs as "new coverage" in the report itself.

@spacebear21 spacebear21 merged commit e56520a into payjoin:master Feb 7, 2025
6 checks passed
@spacebear21 spacebear21 mentioned this pull request Apr 2, 2025
17 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix payjoin-cli v1 coverage

3 participants