init:
This commit is contained in:
66
runner/result.go
Normal file
66
runner/result.go
Normal file
@@ -0,0 +1,66 @@
|
||||
package runner
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Status int
|
||||
|
||||
const (
|
||||
StatusPass Status = iota
|
||||
StatusFail
|
||||
StatusTLE
|
||||
StatusBuildError
|
||||
StatusRuntimeError
|
||||
)
|
||||
|
||||
func (s Status) String() string {
|
||||
switch s {
|
||||
case StatusPass:
|
||||
return "PASS"
|
||||
case StatusFail:
|
||||
return "FAIL"
|
||||
case StatusTLE:
|
||||
return "TLE"
|
||||
case StatusBuildError:
|
||||
return "BUILD_ERROR"
|
||||
case StatusRuntimeError:
|
||||
return "RE"
|
||||
default:
|
||||
return "UNKNOWN"
|
||||
}
|
||||
}
|
||||
|
||||
type TestResult struct {
|
||||
Name string
|
||||
Status Status
|
||||
Elapsed time.Duration
|
||||
|
||||
Failures []string
|
||||
|
||||
ActualStdout string
|
||||
ActualStderr string
|
||||
ActualCode int
|
||||
}
|
||||
|
||||
func (r *TestResult) fail(msg string, args ...any) {
|
||||
r.Failures = append(r.Failures, fmt.Sprintf(msg, args...))
|
||||
r.Status = StatusFail
|
||||
}
|
||||
|
||||
type GroupResult struct {
|
||||
Name string
|
||||
Weight float64
|
||||
Score float64
|
||||
|
||||
Tests []*TestResult
|
||||
Passed int
|
||||
Total int
|
||||
}
|
||||
|
||||
type SuiteResult struct {
|
||||
Groups []*GroupResult
|
||||
TotalScore float64
|
||||
BuildLog string
|
||||
}
|
||||
Reference in New Issue
Block a user