Documentation
¶
Overview ¶
Package examples reads the fenced code blocks of the pages, runs them and checks their output (spec 07).
Index ¶
- Variables
- func Clean(s string) string
- func Collect(file, src string, line0 int) ([]Case, []Issue)
- func LangID(name string) string
- func Normalize(s string, extra []string) string
- func Stream(got lang.RunResult, stream string) string
- func Update(src string, results []Result) (string, int)
- type Block
- type Case
- type Issue
- type Result
- type Runner
Constants ¶
This section is empty.
Variables ¶
var Expects = []string{"compile", "runtime", "exit", "exception", "error", "panic", "timeout", "sanitizer"}
Expects are the kinds of failure signature of spec 07.2.
var NorunReasons = []string{"network", "gui", "platform", "hardware", "ub", "vulnerable", "fragment", "pseudo", "long", "interactive"}
NorunReasons are the codes of spec 07.8.
Functions ¶
func Clean ¶
Clean gives the text that -update writes in an output block: the run output with the line ends, the colour codes and the trailing spaces made the same as Normalize makes them.
func Collect ¶
Collect gives the cases of one Markdown file, and the issues of the rules X01 and X02. The blocks of the languages that prog run can run need a mode; the other blocks, such as text or json, do not.
func Normalize ¶
Normalize applies the default normalizers of spec 07.6 and the extra ones that are named: addr, time, tmp, hash and float:<digits>.
func Update ¶
Update writes the output of the runs into the output blocks of a file (prog run -update). It replaces the text of an output block that differs from the run, and adds an output block after a run or wrong block that has none. It does not change an output block with match=regex or match=any, because a person wrote the pattern. The results must be of the cases of src. It returns the new text and the number of blocks that changed, and it sets Updated on each result whose blocks now match the run.
Types ¶
type Block ¶
type Block struct {
// Lang is the language id after the aliases, such as python or cpp. It is "output" or "input" for those blocks.
Lang string
Info string
Attrs map[string]string
// Words are the attributes without a value, such as run or fails.
Words []string
Code string
// Line is the line of the opening fence, from 1.
Line int
// Start and End are the byte offsets of the code in the file. Start is the first byte after the opening fence line and End is the first byte of the closing fence line.
Start, End int
// Closed is false when the file ends before the closing fence.
Closed bool
// After is the byte offset just after the closing fence line.
After int
}
Block is one fenced code block of a Markdown file.
type Case ¶
type Case struct {
File string
// Block is the block that owns the run: the block itself, or the last runnable block of a group.
Block *Block
// Parts are the blocks of the program in the order of the page. A block without file= adds its code to the main file of the language.
Parts []*Block
Outputs []*Block
// Stdin is the text of the input block that stdin= names.
Stdin string
}
Case is one program to run: a block, or the blocks of a group, with its output blocks.
func (*Case) Files ¶
Files gives the files of the program. The parts without file= go to the main file of the language, in order.
type Result ¶
type Result struct {
File string `json:"file"`
Line int `json:"line"`
ID string `json:"id"`
Lang string `json:"lang"`
Mode string `json:"mode"`
Status string `json:"status"` // pass, fail or skip
Why string `json:"why,omitempty"`
Tool string `json:"tool,omitempty"`
Ms int64 `json:"ms"`
// Updated is set by Update when the output blocks of the case were written from this run.
Updated bool `json:"updated,omitempty"`
// Got is the output of the run, for -update.
Got lang.RunResult `json:"-"`
// Case is the case of the result.
Case *Case `json:"-"`
}
Result is the result of one case.