-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #362 from afbjorklund/notify-linux
Add post-run-command notify implementation for linux
- Loading branch information
Showing
10 changed files
with
144 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
notify |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
GO = go | ||
INSTALL = install | ||
|
||
ICONS = icons/test-pass.svg icons/test-fail.svg | ||
ICONDIR = $(HOME)/.icons # or /usr/share/icons | ||
|
||
build: | ||
$(GO) build | ||
|
||
install: $(ICONS) | ||
$(GO) install | ||
$(INSTALL) -d $(ICONDIR) | ||
$(INSTALL) $^ $(ICONDIR) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<a href="https://www.vecteezy.com/free-vector/pass-fail">Pass Fail Vectors by Vecteezy</a> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"os" | ||
"os/exec" | ||
"strconv" | ||
) | ||
|
||
func main() { | ||
total := envInt("TOTAL") | ||
skipped := envInt("SKIPPED") | ||
failed := envInt("FAILED") | ||
errors := envInt("ERRORS") | ||
|
||
icon := "test-pass" | ||
title := "Passed" | ||
switch { | ||
case errors > 0: | ||
icon = "dialog-warning" | ||
title = "Errored" | ||
case failed > 0: | ||
icon = "test-fail" | ||
title = "Failed" | ||
case skipped > 0: | ||
title = "Passed with skipped" | ||
} | ||
|
||
subtitle := fmt.Sprintf("%d Tests Run", total) | ||
if errors > 0 { | ||
subtitle += fmt.Sprintf(", %d Errored", errors) | ||
} | ||
if failed > 0 { | ||
subtitle += fmt.Sprintf(", %d Failed", failed) | ||
} | ||
if skipped > 0 { | ||
subtitle += fmt.Sprintf(", %d Skipped", skipped) | ||
} | ||
|
||
cmd := exec.Command("notify-send", "--icon", icon, title, subtitle) | ||
log.Printf("%#v", cmd.Args) | ||
cmd.Stdout = os.Stdout | ||
cmd.Stderr = os.Stderr | ||
if err := cmd.Run(); err != nil { | ||
log.Fatalf("Failed to exec: %v", err) | ||
} | ||
} | ||
|
||
func envInt(name string) int { | ||
val := os.Getenv("TESTS_" + name) | ||
n, err := strconv.Atoi(val) | ||
if err != nil { | ||
return 0 | ||
} | ||
return n | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"os" | ||
"os/exec" | ||
"strconv" | ||
) | ||
|
||
func main() { | ||
total := envInt("TOTAL") | ||
skipped := envInt("SKIPPED") | ||
failed := envInt("FAILED") | ||
errors := envInt("ERRORS") | ||
|
||
icon := "info" // Info 🛈 | ||
title := "Passed" | ||
switch { | ||
case errors > 0: | ||
icon = "important" // Warning ⚠ | ||
title = "Errored" | ||
case failed > 0: | ||
icon = "error" // Error ⮾ | ||
title = "Failed" | ||
case skipped > 0: | ||
title = "Passed with skipped" | ||
} | ||
|
||
subtitle := fmt.Sprintf("%d Tests Run", total) | ||
if errors > 0 { | ||
subtitle += fmt.Sprintf(", %d Errored", errors) | ||
} | ||
if failed > 0 { | ||
subtitle += fmt.Sprintf(", %d Failed", failed) | ||
} | ||
if skipped > 0 { | ||
subtitle += fmt.Sprintf(", %d Skipped", skipped) | ||
} | ||
|
||
cmd := exec.Command("notify-send.exe", "-i", icon, title, subtitle) | ||
log.Printf("%#v", cmd.Args) | ||
cmd.Stdout = os.Stdout | ||
cmd.Stderr = os.Stderr | ||
if err := cmd.Run(); err != nil { | ||
log.Fatalf("Failed to exec: %v", err) | ||
} | ||
} | ||
|
||
func envInt(name string) int { | ||
val := os.Getenv("TESTS_" + name) | ||
n, err := strconv.Atoi(val) | ||
if err != nil { | ||
return 0 | ||
} | ||
return n | ||
} |