Documentation ¶
Index ¶
- Variables
- type Flag
- type Status
- func (i Status) CountsForTiming() bool
- func (i Status) Flag() Flag
- func (i Status) IsBad() bool
- func (i Status) IsInBounds() bool
- func (i Status) IsOk() bool
- func (i Status) MarshalJSON() ([]byte, error)
- func (i Status) MarshalText() ([]byte, error)
- func (i Status) String() string
- func (i *Status) UnmarshalJSON(bytes []byte) error
- func (i *Status) UnmarshalText(text []byte) error
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ErrBad = errors.New("bad status")
ErrBad occurs when FromString encounters an unknown status string.
Functions ¶
This section is empty.
Types ¶
type Flag ¶
type Flag int
Flag programmatically represents, as a bitwise Flag set, the possible classifications for a subject.
const ( // FlagFiltered signifies that a subject was filtered out. FlagFiltered Flag = 1 << iota // FlagFlagged signifies that a subject was 'flagged'. FlagFlagged // FlagCompileFail signifies a compile failure. FlagCompileFail // FlagCompileTimeout signifies a compile timeout. FlagCompileTimeout // FlagRunFail signifies a runtime failure. FlagRunFail // FlagRunTimeout signifies a runtime timeout. FlagRunTimeout // FlagFail is the union of all failure flags. FlagFail = FlagCompileFail | FlagRunFail // FlagTimeout is the union of all timeout flags. FlagTimeout = FlagCompileTimeout | FlagRunTimeout // FlagBad is the union of all 'bad' flags; it should match the calculation in Status.IsBad. FlagBad = FlagFail | FlagTimeout | FlagFlagged )
func (Flag) MatchesAll ¶
MatchesAll tests whether this Flag has all flag bits in expected present.
Where there is only one bit set in expected, MatchesAny equals MatchesAll.
func (Flag) MatchesAny ¶
MatchesAny tests whether this Flag has any flag bits in expected present.
Where there is only one bit set in expected, MatchesAny equals MatchesAll.
func (Flag) MatchesStatus ¶
MatchesStatus tests whether this Flag matches the expected status. Generally, this is a MatchesAll test for Status.Flag, except that Ok only matches an absence of other flags.
type Status ¶
type Status int
Status is the type of completed-run statuses.
const ( // Unknown represents an unknown status. Unknown Status = iota // Ok indicates that a run completed successfully without incident. Ok // Filtered indicates that a run would have failed, but it has been caught by a filter. Filtered // Flagged indicates that a run completed successfully, but its observation was interesting. // Usually this means a counter-example occurred. Flagged // CompileFail indicates that a run failed because of the compilation failing. CompileFail // CompileTimeout indicates that a run failed because the compilation timed out. CompileTimeout // RunFail indicates that a run failed directly. RunFail // RunTimeout indicates that a run timed out. RunTimeout // FirstBad refers to the first status that represents an unwanted outcome. FirstBad = Flagged // Last is the last valid status. Last = RunTimeout )
func FromCompileError ¶
FromCompileError tries to see if err represents a non-fatal issue such as a timeout or process error. If so, it converts that error to a status and returns it alongside nil. Otherwise, it propagates the error forwards.
func FromRunError ¶
FromRunError tries to see if err represents a non-fatal issue such as a timeout or process error. If so, it converts that error to a status and returns it alongside nil. Otherwise, it propagates the error forwards.
func FromString ¶
FromString tries to resolve s to a status code.
func (Status) CountsForTiming ¶
CountsForTiming is true if this status should be logged in compiler/run timing data.
Any compile or run that is not filtered and executes to completion counts for timing purposes (so, ok or flagged compiles/runs).
func (Status) IsBad ¶
IsBad is true if, and only if, this status is in-bounds, not OK, and not unknown.
func (Status) IsInBounds ¶
IsInBounds is true if, and only if, this status is in bounds.
func (Status) IsOk ¶
IsOk is true if, and only if, this status is StatusOk.
Example ¶
ExampleStatus_IsOk is a runnable example for Status.IsOk.
package main import ( "fmt" "github.com/c4-project/c4t/internal/subject/status" ) func main() { fmt.Println("is", status.Ok, "ok?", status.Ok.IsOk()) fmt.Println("is", status.Flagged, "ok?", status.Flagged.IsOk()) fmt.Println("is", status.CompileFail, "ok?", status.CompileFail.IsOk()) }
Output: is Ok ok? true is Flagged ok? false is CompileFail ok? false
func (Status) MarshalJSON ¶
MarshalJSON marshals a Status to JSON via its string representation.
func (Status) MarshalText ¶
MarshalText marshals a Status to text via its string representation.
func (*Status) UnmarshalJSON ¶
UnmarshalJSON unmarshals a Status from JSON via its string representation.
func (*Status) UnmarshalText ¶
UnmarshalText unmarshals a Status from text via its string representation.