mirror of
https://github.com/criyle/go-judge.git
synced 2025-11-04 14:50:02 +08:00
28 lines
530 B
Go
28 lines
530 B
Go
package runner
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/criyle/go-judge/file"
|
|
"github.com/criyle/go-judge/problem"
|
|
)
|
|
|
|
const maxOutput = 4 << 20 // 4M
|
|
|
|
func (r *Runner) run(done <-chan struct{}, task *RunTask) *RunTaskResult {
|
|
switch task.Type {
|
|
case problem.Compile:
|
|
return r.compile(done, task.Compile)
|
|
|
|
default:
|
|
return r.exec(done, task.Exec)
|
|
}
|
|
}
|
|
|
|
func getFile(files map[string]file.File, name string) ([]byte, error) {
|
|
if f, ok := files[name]; ok {
|
|
return f.Content()
|
|
}
|
|
return nil, fmt.Errorf("file %s not exists", name)
|
|
}
|