gotestyourself / gotestsum

'go test' runner with output optimized for humans, JUnit XML for CI integration, and a summary of the test results.
Apache License 2.0
2.03k stars 119 forks source link

Add post-run-command notify implementation for linux #362

Closed afbjorklund closed 1 year ago

afbjorklund commented 1 year ago

Using notify-send instead of terminal-notifier, and icons instead of emojis.

Renamed the "notify-macos" to the proper "notify_darwin", so the build works.

Sample notification:

gotestsum-notify-linux-pass

gotestsum-notify-linux-fail

Issue #116

afbjorklund commented 1 year ago

There is some debugging log spam when invoked, but I kept it the same as the Mac version for now...

        log.Printf("notify-send %#v", args)
        log.Printf("terminal-notifier %#v", args)

I don't think it needs to log this (definitely not to stderr), but if it does it should have a "debug" log level.

afbjorklund commented 1 year ago

In theory this should also work on Windows, with notify-send: http://vaskovsky.net/notify-send/

@@ -39,12 +39,12 @@
    }

    args := []string{
-       "--icon", icon,
+       "-i", icon,
        title,
        subtitle,
    }
    log.Printf("notify-send %#v", args)
-   err := exec.Command("notify-send", args...).Run()
+   err := exec.Command("notify-send.exe", args...).Run()
    if err != nil {
        log.Fatalf("Failed to exec: %v", err)
    }

It might need some patches to allow additional icons https://github.com/vaskovsky/notify-send

EDIT: apparently you can't use custom icons with the default API, so not possible (this way at least)

It could probably be done using a different API call, with a modification to the external C# program

afbjorklund commented 1 year ago

Tested with GOOS=windows and Wine + Mono:

wine-pass

wine-fail

https://github.com/vaskovsky/notify-send/releases