Documentation
¶
Index ¶
- func CompileC(workDir, source, output string, flags ...string) error
- type CompileError
- type ExitCodeMismatch
- type Mismatch
- type RejectError
- type Runner
- func (r *Runner) Error() error
- func (r *Runner) Execute() *Runner
- func (r *Runner) Exit(code int) *Runner
- func (r *Runner) GetStdout() string
- func (r *Runner) Kill() *Runner
- func (r *Runner) Reject(rejectTimeout ...time.Duration) *Runner
- func (r *Runner) Result() *executable.ExecutableResult
- func (r *Runner) SendLine(input string) *Runner
- func (r *Runner) Start() *Runner
- func (r *Runner) Stdin(input string) *Runner
- func (r *Runner) Stdout(expected string) *Runner
- func (r *Runner) StdoutExact(expected string) *Runner
- func (r *Runner) StdoutRegex(pattern string) *Runner
- func (r *Runner) WaitForExit() *Runner
- func (r *Runner) WithEnv(env ...string) *Runner
- func (r *Runner) WithLogger(l *logger.Logger) *Runner
- func (r *Runner) WithPty() *Runner
- func (r *Runner) WithTimeout(t time.Duration) *Runner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CompileError ¶
CompileError 表示编译错误
func (*CompileError) Error ¶
func (e *CompileError) Error() string
type ExitCodeMismatch ¶
ExitCodeMismatch 表示退出码不匹配
func (*ExitCodeMismatch) Error ¶
func (e *ExitCodeMismatch) Error() string
type RejectError ¶
type RejectError struct {
Message string
}
RejectError 表示程序未能正确拒绝无效输入
func (*RejectError) Error ¶
func (e *RejectError) Error() string
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner 提供类似 check50 的链式 API 来运行和测试程序 支持两种模式: 1. 阻塞模式: Stdin("input") 发送输入并等待程序结束 2. 交互模式: Start() 启动程序,SendLine() 发送输入,Reject() 检查程序是否拒绝输入
用法示例:
// 阻塞模式
runner.Run("./mario").Stdin("4").Stdout(expected).Exit(0)
// 交互模式 (用于测试输入拒绝)
runner.Run("./mario").Start().SendLine("-1").Reject().SendLine("4").Stdout(expected).Exit(0)
func (*Runner) StdoutExact ¶
StdoutExact 检查标准输出是否完全匹配
func (*Runner) StdoutRegex ¶
StdoutRegex 使用正则表达式检查标准输出
func (*Runner) WithLogger ¶
WithLogger 设置 logger
Click to show internal directories.
Click to hide internal directories.