|
|
|
|
@ -13,8 +13,43 @@ import ( |
|
|
|
|
"lcthw.dev/go/ttarpit/config" |
|
|
|
|
"github.com/fsnotify/fsnotify" |
|
|
|
|
"bufio" |
|
|
|
|
"regexp" |
|
|
|
|
"strconv" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
type ErrInfo struct { |
|
|
|
|
File string |
|
|
|
|
Line int |
|
|
|
|
Col int |
|
|
|
|
ErrType string |
|
|
|
|
Message string |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func ParseErrInfo(line string, reg *regexp.Regexp) (ErrInfo, bool) { |
|
|
|
|
var info ErrInfo |
|
|
|
|
|
|
|
|
|
matches := reg.FindStringSubmatch(line) |
|
|
|
|
if matches == nil { |
|
|
|
|
return info, false |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
et_index := reg.SubexpIndex("ErrType") |
|
|
|
|
if et_index != -1 { |
|
|
|
|
info.ErrType = matches[et_index] |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// BUG: use reflect
|
|
|
|
|
info.File = matches[reg.SubexpIndex("File")] |
|
|
|
|
|
|
|
|
|
info.Line, _ = strconv.Atoi(matches[reg.SubexpIndex("Line")]) |
|
|
|
|
|
|
|
|
|
info.Col, _ = strconv.Atoi(matches[reg.SubexpIndex("Col")]) |
|
|
|
|
|
|
|
|
|
info.Message = matches[reg.SubexpIndex("Message")] |
|
|
|
|
|
|
|
|
|
return info, true |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func LaunchLogger(in io.Reader, out io.Writer, err error) { |
|
|
|
|
if err != nil { log.Fatal(err) } |
|
|
|
|
|
|
|
|
|
@ -25,11 +60,11 @@ func LaunchLogger(in io.Reader, out io.Writer, err error) { |
|
|
|
|
for _, reg := range config.Settings.TriggerRegex { |
|
|
|
|
line := scan.Text() |
|
|
|
|
|
|
|
|
|
matches := reg.FindStringSubmatch(line) |
|
|
|
|
if len(matches) > 0 { |
|
|
|
|
file, line, col, err_type, text := matches[1], matches[2], matches[3], matches[4], matches[5] |
|
|
|
|
fmt.Printf("!!!!!!!!!!!!!! file=%s, line=%s, col=%s, type=%s, text=%s\n",
|
|
|
|
|
file, line, col, err_type, text) |
|
|
|
|
errinfo, ok := ParseErrInfo(line, reg) |
|
|
|
|
if ok { |
|
|
|
|
fmt.Println("!!!!!!!!!!!!!!!!!", errinfo) |
|
|
|
|
config.Settings.Errors++ |
|
|
|
|
config.Settings.HP-- |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -57,8 +92,6 @@ func LaunchProcess(proc *config.Process) { |
|
|
|
|
|
|
|
|
|
fmt.Println("WAITING for", proc.Command) |
|
|
|
|
|
|
|
|
|
fmt.Println("SENDING READY on channel") |
|
|
|
|
|
|
|
|
|
proc.ExecCmd.Wait() |
|
|
|
|
fmt.Println("PROCESS", proc.Command, "EXITED") |
|
|
|
|
} |
|
|
|
|
@ -89,7 +122,16 @@ func RunBuild() { |
|
|
|
|
fmt.Println("PROCESS:", name) |
|
|
|
|
|
|
|
|
|
LaunchProcess(&proc) |
|
|
|
|
fmt.Println("=================== PROCESS EXIT") |
|
|
|
|
fmt.Println("============== PROCESS EXIT") |
|
|
|
|
fmt.Printf("==== HP: %d Errors: %d =====\n", |
|
|
|
|
config.Settings.HP, config.Settings.Errors) |
|
|
|
|
|
|
|
|
|
if config.Settings.HP <= 0 { |
|
|
|
|
fmt.Println("!!!!!! YOU DIED !!!!!!!") |
|
|
|
|
config.Settings.HP = config.Settings.StartingHP |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fmt.Println("===========================") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
time.Sleep(1000 * time.Millisecond) |
|
|
|
|
|