All checks were successful
build-dsl-smoke / Discover matrix (push) Successful in 8s
build-dsl-smoke / Build judge (push) Successful in 11s
build-dsl-smoke / ${{ matrix.cell.build }} / ${{ matrix.cell.toolchain }} / ${{ matrix.cell.platform }} (push) Successful in 5s
memory-limit / Build judge (pull_request) Successful in 10s
build-dsl-smoke / SUMMARY (push) Successful in 3s
memory-limit / Linux / gcc (pull_request) Successful in 9s
memory-limit / Linux / clang (pull_request) Successful in 13s
memory-limit / Windows / clang (pull_request) Successful in 16s
memory-limit / Windows / msvc (pull_request) Successful in 17s
105 lines
1.4 KiB
Go
105 lines
1.4 KiB
Go
package runner
|
|
|
|
import (
|
|
"fmt"
|
|
"math"
|
|
"time"
|
|
)
|
|
|
|
type Status int
|
|
|
|
const (
|
|
StatusPass Status = iota
|
|
StatusFail
|
|
StatusTLE
|
|
StatusMLE
|
|
StatusBuildError
|
|
StatusRuntimeError
|
|
)
|
|
|
|
func (s Status) String() string {
|
|
switch s {
|
|
case StatusPass:
|
|
return "PASS"
|
|
case StatusFail:
|
|
return "FAIL"
|
|
case StatusTLE:
|
|
return "TLE"
|
|
case StatusMLE:
|
|
return "MLE"
|
|
case StatusBuildError:
|
|
return "BUILD_ERROR"
|
|
case StatusRuntimeError:
|
|
return "RE"
|
|
default:
|
|
return "UNKNOWN"
|
|
}
|
|
}
|
|
|
|
type TestResult struct {
|
|
Name string
|
|
Status Status
|
|
Elapsed time.Duration
|
|
|
|
PeakMemory int64
|
|
MemoryLimit int64
|
|
|
|
Failures []string
|
|
|
|
ActualStdout string
|
|
ActualStderr string
|
|
ActualCode int
|
|
}
|
|
|
|
func (r *TestResult) addFailure(msg string, args ...any) {
|
|
r.Failures = append(r.Failures, fmt.Sprintf(msg, args...))
|
|
}
|
|
|
|
type GroupResult struct {
|
|
Name string
|
|
Weight float64
|
|
Score float64
|
|
|
|
Tests []*TestResult
|
|
Passed int
|
|
Total int
|
|
}
|
|
|
|
type BuildRun struct {
|
|
Name string
|
|
Toolchain string
|
|
Skipped bool
|
|
SkipReason string
|
|
|
|
BuildLog string
|
|
Groups []*GroupResult
|
|
TotalScore float64
|
|
}
|
|
|
|
type SuiteResult struct {
|
|
Builds []*BuildRun
|
|
|
|
TotalScore float64
|
|
}
|
|
|
|
func (r *SuiteResult) AggregateScore() float64 {
|
|
if len(r.Builds) == 0 {
|
|
return 0
|
|
}
|
|
min := math.Inf(1)
|
|
anyRan := false
|
|
for _, b := range r.Builds {
|
|
if b.Skipped {
|
|
continue
|
|
}
|
|
anyRan = true
|
|
if b.TotalScore < min {
|
|
min = b.TotalScore
|
|
}
|
|
}
|
|
if !anyRan {
|
|
return 1.0
|
|
}
|
|
return min
|
|
}
|