Compare commits
No commits in common. "5abda79a544572ae2903f5d4cb0c8fd3003bea2b" and "a708e768ec6f2ed69780f37aee374a7d2929d02a" have entirely different histories.
5abda79a54
...
a708e768ec
|
|
@ -7,7 +7,6 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/criyle/go-judge/envexec"
|
"github.com/criyle/go-judge/envexec"
|
||||||
|
|
@ -53,31 +52,11 @@ func (e *Local) Run(cmds []stage.Cmd) ([]stage.ExecutorResult, error) {
|
||||||
err = execCmd.Wait()
|
err = execCmd.Wait()
|
||||||
endTime := time.Now()
|
endTime := time.Now()
|
||||||
runTime := endTime.Sub(startTime)
|
runTime := endTime.Sub(startTime)
|
||||||
processState := execCmd.ProcessState
|
|
||||||
result := stage.ExecutorResult{
|
result := stage.ExecutorResult{
|
||||||
Status: stage.Status(envexec.StatusAccepted),
|
Status: stage.Status(envexec.StatusAccepted),
|
||||||
ExitStatus: processState.ExitCode(),
|
ExitStatus: 0,
|
||||||
Error: "",
|
Error: "",
|
||||||
Time: func() uint64 {
|
|
||||||
nanos := processState.UserTime().Nanoseconds()
|
|
||||||
if nanos < 0 {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
return uint64(nanos)
|
|
||||||
}(),
|
|
||||||
Memory: func() uint64 {
|
|
||||||
usage := processState.SysUsage()
|
|
||||||
rusage, ok := usage.(*syscall.Rusage)
|
|
||||||
if !ok {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
maxRssKB := rusage.Maxrss
|
|
||||||
maxRssBytes := maxRssKB * 1024
|
|
||||||
if maxRssBytes < 0 {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
return uint64(maxRssBytes)
|
|
||||||
}(),
|
|
||||||
RunTime: func() uint64 {
|
RunTime: func() uint64 {
|
||||||
nanos := runTime.Nanoseconds()
|
nanos := runTime.Nanoseconds()
|
||||||
if nanos < 0 {
|
if nanos < 0 {
|
||||||
|
|
@ -91,6 +70,7 @@ func (e *Local) Run(cmds []stage.Cmd) ([]stage.ExecutorResult, error) {
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if exitErr, ok := err.(*exec.ExitError); ok {
|
if exitErr, ok := err.(*exec.ExitError); ok {
|
||||||
|
result.ExitStatus = exitErr.ExitCode()
|
||||||
result.Status = stage.Status(envexec.StatusNonzeroExitStatus)
|
result.Status = stage.Status(envexec.StatusNonzeroExitStatus)
|
||||||
result.Error = exitErr.Error()
|
result.Error = exitErr.Error()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Conf struct {
|
type Conf struct {
|
||||||
Name string
|
Name string
|
||||||
ForceQuitOnNonEmpty bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type File struct{}
|
type File struct{}
|
||||||
|
|
@ -21,16 +20,12 @@ func (*File) Run(results []stage.ExecutorResult, confAny any) (
|
||||||
return nil, true, err
|
return nil, true, err
|
||||||
}
|
}
|
||||||
var res []stage.ParserResult
|
var res []stage.ParserResult
|
||||||
forceQuit := false
|
|
||||||
for _, result := range results {
|
for _, result := range results {
|
||||||
content := result.Files[conf.Name]
|
content := result.Files[conf.Name]
|
||||||
if conf.ForceQuitOnNonEmpty && content != "" {
|
|
||||||
forceQuit = true
|
|
||||||
}
|
|
||||||
if !strings.HasSuffix(content, "\n") {
|
if !strings.HasSuffix(content, "\n") {
|
||||||
content += "\n"
|
content += "\n"
|
||||||
}
|
}
|
||||||
res = append(res, stage.ParserResult{Score: 0, Comment: content})
|
res = append(res, stage.ParserResult{Score: 0, Comment: content})
|
||||||
}
|
}
|
||||||
return res, forceQuit, nil
|
return res, false, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user