mirror of
https://github.com/criyle/go-judge.git
synced 2025-09-26 22:39:12 +08:00
only diff if run successed
This commit is contained in:
parent
42ab854d7c
commit
19ab1bc1a6
@ -181,7 +181,7 @@ func updateResult(p *types.ProgressProgressed, jr *judgeResult) {
|
||||
cr.Error = p.Error
|
||||
cr.Result = &testcaseDetails{
|
||||
Status: convertResultTypes(p.ExecStatus),
|
||||
Time: uint64(p.Time / time.Millisecond),
|
||||
Time: uint64(p.Time.Round(time.Millisecond) / time.Millisecond),
|
||||
Memory: uint64(p.Memory >> 10),
|
||||
Input: getFileContent("input", p.Input),
|
||||
Output: getFileContent("output", p.Answer),
|
||||
|
@ -57,12 +57,7 @@ func main() {
|
||||
// however, /proc gives interface like /proc/1/fd/3 ..
|
||||
// it is fine since open that file will be a EPERM
|
||||
// changing the fs uid and gid would be a good idea
|
||||
WithMount(mount.Mount{
|
||||
Source: "proc",
|
||||
Target: "proc",
|
||||
FsType: "proc",
|
||||
Flags: syscall.MS_NOSUID,
|
||||
}).
|
||||
WithProc().
|
||||
// some compiler have multiple version
|
||||
WithBind("/etc/alternatives", "etc/alternatives", true).
|
||||
// fpc wants /etc/fpc.cfg
|
||||
|
@ -54,7 +54,7 @@ func (r *Runner) compile(done <-chan struct{}, task *types.CompileTask) *types.R
|
||||
Args: param.Args,
|
||||
Env: param.Env,
|
||||
Files: []interface{}{devNull, msgCollector, msgCollector},
|
||||
MemoryLimit: param.MemoryLimit << 10,
|
||||
MemoryLimit: param.MemoryLimit,
|
||||
PidLimit: param.ProcLimit,
|
||||
CopyIn: copyIn,
|
||||
CopyOut: copyOut,
|
||||
|
@ -100,10 +100,12 @@ func (r *Runner) exec(done <-chan struct{}, task *types.ExecTask) *types.RunTask
|
||||
if err != nil {
|
||||
return execErr(types.StatusFileError, err.Error())
|
||||
}
|
||||
if err := diff.Compare(bytes.NewReader(ans), bytes.NewReader(userOutput)); err != nil {
|
||||
spjOutput = []byte(err.Error())
|
||||
scoreRate = 0
|
||||
status = types.StatusWrongAnswer
|
||||
if status == types.StatusAccepted {
|
||||
if err := diff.Compare(bytes.NewReader(ans), bytes.NewReader(userOutput)); err != nil {
|
||||
spjOutput = []byte(err.Error())
|
||||
scoreRate = 0
|
||||
status = types.StatusWrongAnswer
|
||||
}
|
||||
}
|
||||
|
||||
// return result
|
||||
@ -115,6 +117,7 @@ func (r *Runner) exec(done <-chan struct{}, task *types.ExecTask) *types.RunTask
|
||||
Time: r0.Time,
|
||||
Memory: r0.Memory,
|
||||
Input: inputContent,
|
||||
Answer: ans,
|
||||
UserOutput: userOutput,
|
||||
UserError: userError,
|
||||
SPJOutput: spjOutput,
|
||||
|
Loading…
Reference in New Issue
Block a user