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