-
Notifications
You must be signed in to change notification settings - Fork 4
/
find-hanging-tests.go
51 lines (46 loc) · 970 Bytes
/
find-hanging-tests.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"bufio"
"fmt"
"os"
"strings"
)
func main() {
activeMap := make(map[string]bool)
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
s := scanner.Text()
rightBracketIndex := strings.Index(s, "]")
if rightBracketIndex > 0 {
handleLine(s[rightBracketIndex+2:], activeMap)
}
}
printMap(activeMap)
}
func handleLine(s string, activeMap map[string]bool) {
startedIndex := strings.Index(s, "STARTED")
if startedIndex > 0 {
activeMap[s[:startedIndex]] = true
return
}
passedIndex := strings.Index(s, "PASSED")
if passedIndex > 0 {
delete(activeMap, s[:passedIndex])
return
}
failedIndex := strings.Index(s, "FAILED")
if failedIndex > 0 {
delete(activeMap, s[:failedIndex])
return
}
skippedIndex := strings.Index(s, "SKIPPED")
if skippedIndex > 0 {
delete(activeMap, s[:skippedIndex])
return
}
}
func printMap(activeMap map[string]bool) {
for t := range(activeMap) {
fmt.Printf("%s\n", t)
}
}