navinpeiris / ex_unit_notifier Goto Github PK
View Code? Open in Web Editor NEWDesktop notifications for ExUnit
License: MIT License
Desktop notifications for ExUnit
License: MIT License
The gist of this feature request, have an option to only notify if test status changes. For instance if a test starts breaking, more tests break, or tests all pass after a fix.
This way of working is superior to me. They I don't get distracted when status has not changed. Tests just run in the background.
I would be happy to contribute some code, if you would like this feature.
Related, but unsure if possible, is to notify when test code does not compile. Will be happy to have a look at that as well.
Terminal Notifier breaks in tmux. Change ExUnitNotifier.Notifiers.TerminalNotifier.available?/0
to check for TMUX
in the environment. If TMUX
is set then we are in TMUX
and the notifier should not be available.
On Windows the following PowerShell script can be used for creating a tray notification:
Invoke-Notification.ps1
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
Function Invoke-Notification {
<#
.Synopsis
Display a balloon tip message in the system tray.
.Description
This function displays a user-defined message as a balloon popup in the system tray. This function
requires Windows Vista or later.
.Parameter Title
The title for the message balloon.
.Parameter Message
The message text you want to display. Recommended to keep it short and simple.
.Parameter MessageType
The type of message. This value determines what type of icon to display. Valid values are:
Info,Error,Warning,None
.Parameter SysTrayIcon
The path to a file that you will use as the system tray icon. Default is the PowerShell ISE icon.
.Parameter Duration
The number of seconds to display the balloon popup. The default is 1000.
.Inputs
None
.Outputs
None
.Notes
NAME: Invoke-BalloonTip
VERSION: 1.1
AUTHOR: Marduk Bolaños
HISTORY: Based on the original by Boe Prox.
#>
[CmdletBinding()]
Param (
[Parameter(HelpMessage="The message title")]
[string]$Title="Attention $env:username",
[Parameter(Mandatory=$True,HelpMessage="The message text to display. Keep it short and simple.")]
[string]$Message,
[Parameter(HelpMessage="The message type: Info,Error,Warning,None")]
[System.Windows.Forms.ToolTipIcon]$MessageType="Info",
[Parameter(HelpMessage="The path to a file to use its icon in the system tray")]
[string]$SysTrayIconPath='C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe',
[Parameter(HelpMessage="The number of milliseconds to display the message.")]
[int]$Duration=1000
)
Add-Type -AssemblyName System.Windows.Forms
If (-NOT $global:balloon) {
$global:balloon = New-Object System.Windows.Forms.NotifyIcon
}
$balloon.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($SysTrayIconPath)
$balloon.BalloonTipIcon = [System.Windows.Forms.ToolTipIcon]$MessageType
$balloon.BalloonTipText = $Message
$balloon.BalloonTipTitle = $Title
$balloon.Visible = $true
$balloon.ShowBalloonTip($Duration)
Write-Verbose "Ending function"
}
$cmd, $params = $args
& $cmd @params
The script can be executed with:
powershell.exe .\path\to\Invoke-Notification.ps1 Invoke-Notification Title Message
I started a fresh phoenix project on a Mac. The following are my dependencies:
defp deps do
[{:phoenix, "~> 1.2.1"},
{:phoenix_pubsub, "~> 1.0"},
{:phoenix_ecto, "~> 3.0"},
{:postgrex, ">= 0.0.0"},
{:phoenix_html, "~> 2.6"},
{:phoenix_live_reload, "~> 1.0", only: :dev},
{:gettext, "~> 0.11"},
{:cowboy, "~> 1.0"},
{:distillery, "~> 0.10"},
{:excoveralls, "~> 0.5", only: :test},
{:credo, "~> 0.4", only: [:dev, :test]},
{:dogma, "~> 0.1", only: :dev},
{:mix_test_watch, "~> 0.2", only: :dev},
{:ex_unit_notifier, "~> 0.1", only: :test}]
end
As soon as I add
ExUnit.configure formatters: [ExUnit.CLIFormatter, ExUnitNotifier]
above the ExUnit.start
line to test/test_helper.exs
the tests start to run (I get 4 dots), but then there's no notification and the tests hang. Commenting out the above line, the tests run fine.
Uncommented:
$ mix test
....
Commented out:
$ mix test
....
Finished in 0.1 seconds
4 tests, 0 failures
Randomized with seed 717882
I do have terminal-notifier installed and on my path.
$ which terminal-notifier
/usr/local/bin/terminal-notifier
$ terminal-notifier --help
terminal-notifier (1.7.1) is a command-line tool to send OS X User Notifications.
# ... <help output removed> ...
Using elixir 1.3.2 / erlang 19
$ elixir -v
Erlang/OTP 19 [erts-8.0.2] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]
Elixir 1.3.2
Terminal notifier has some options that could be useful when testing. I personally would like to have the notifier use the SOUND option. It would be nice to be able to have two different sounds when the notifier signals failure or success.
Today I just installed
{:ex_unit_notifier, "~> 0.1", only: :test}
ExUnit.configure formatters: [ExUnit.CLIFormatter, ExUnitNotifier]
config :ex_unit_notifier, notifier: ExUnitNotifier.Notifiers.NotifySend
neither it's working with defaultI'm using:
and got this
11:55:00.139 [error] GenEvent handler ExUnitNotifier installed in #PID<0.1123.0> terminating
** (UndefinedFunctionError) function ExUnitNotifier.handle_event/2 is undefined or private. Did you mean one of:
* handle_cast/2
* handle_info/2
To perform a notification, TmuxNotifier manually alters the user's tmux configuration value "window-status-style" with a fixed value of red or green. This is not raising an alert of any kind, it is manually changing the user's configuration. It causes several issues:
The tmux notifier doesn't seem necessary at all. ExUnit already provides an exit code for success or failure, and it is trivial to cause a terminal bell for failure (e.g. mix test || echo -e \\a
) which is already handled as a notification by tmux and other systems.
Simply removing the tmux notifier fixes all the above issues.
Hello,
I just released terminal-notifier 2.0.0 which has some large changes, I figured you might be interested.
https://github.com/julienXX/terminal-notifier/releases/tag/2.0.0
Cheers,
Julien
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.