Skip to content
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

Add post-run hook to support sending desktop notifications #74

Closed
dnephin opened this issue Oct 25, 2019 · 4 comments · Fixed by #76
Closed

Add post-run hook to support sending desktop notifications #74

dnephin opened this issue Oct 25, 2019 · 4 comments · Fixed by #76
Labels
enhancement New feature or request

Comments

@dnephin
Copy link
Member

dnephin commented Oct 25, 2019

Thanks to @glenjamin for the idea.

Instead of publishing notifications directly I'd like to add support for executing a script that is passed all of the necessary details, and can handle any type of notification.

The script should be called with env vars which contain a summary of the run, and a json blob could be passed to stdin to provide full details about any errors.

Such a feature might look something like this:

export GOTESTSUM_POST_RUN_SCRIPT=./scripts/notify-test-results.sh
gotestsum

Env vars:

TEST_TOTAL=100
TEST_FAILED=2
TEST_SKIPPED=5
TEST_ERRORS=0

I'm not sure how to encode more details. The junixml format might work, but is probably not the easiest format to integrate. A custom JSON document might work but will be more involved to maintain.

Maybe env vars will work for the first version.

@dnephin dnephin added the enhancement New feature or request label Oct 25, 2019
@glenjamin
Copy link
Contributor

When I use these I tend to have my editor window focused, and my terminal running tests hidden - so ideally the notification should get enough data exposed to be able to include some details about the failure:

  • files that failed to compile
  • the compilation errors
  • tests that failed
  • files and line numbers of failed tests

@dnephin
Copy link
Member Author

dnephin commented Oct 27, 2019

Started some work in #76 which I think would enable a basic notification.

File and line numbers is not something that is currently parsed. Test names are easy enough, but the file and line numbers are for the failed asserts/checks not for the tests cases themselves.

@glenjamin
Copy link
Contributor

I had a little play around with this, had to switch to a shell exec to be able to handle multiple arguments to the hook command well:

4728f41

Screenshot 2019-11-03 at 12 45 39

Screenshot 2019-11-03 at 12 45 26

@dnephin
Copy link
Member Author

dnephin commented May 16, 2020

Thanks for your work on this! I've merged the original PR which adds the new command line flag, and opened #116 for possible next steps.

I'll also open a PR now for adding it to the documentation in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants