Last active
May 9, 2019 22:20
-
-
Save eliben/f9321b97b18a71328eca6ad21ba6d592 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
package main | |
import ( | |
"bufio" | |
"encoding/json" | |
"fmt" | |
"log" | |
"os" | |
) | |
func main() { | |
var passed, failed, skipped int | |
scanner := bufio.NewScanner(bufio.NewReader(os.Stdin)) | |
for scanner.Scan() { | |
fmt.Println(scanner.Text()) | |
var m map[string]interface{} | |
if err := json.Unmarshal(scanner.Bytes(), &m); err != nil { | |
log.Fatal(err) | |
} | |
if v, ok := m["Action"]; ok { | |
s := v.(string) | |
fmt.Println(s) | |
if s == "pass" { | |
passed++ | |
} else if s == "fail" { | |
failed++ | |
} else if s == "skip" { | |
skipped++ | |
} | |
} else { | |
log.Fatal("Can't find Action in:", scanner.Text()) | |
} | |
} | |
total := passed + failed + skipped | |
fmt.Printf("Ran %d; Passed %d; Failed %d; Skipped %d\n", total, passed, failed, skipped) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment