Documentation
¶
Index ¶
- type TestCaseHarness
- func (s *TestCaseHarness) FileExists(relativePath string) bool
- func (s *TestCaseHarness) FilePath(relativePath string) string
- func (s *TestCaseHarness) NewExecutable() *executable.Executable
- func (s *TestCaseHarness) ReadFile(relativePath string) ([]byte, error)
- func (s *TestCaseHarness) RegisterTeardownFunc(teardownFunc func())
- func (s *TestCaseHarness) RunTeardownFuncs()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TestCaseHarness ¶
type TestCaseHarness struct {
// Logger is to be used for all logs generated from the test function.
Logger *logger.Logger
// SubmissionDir is the directory containing the student's submission.
// Use this for direct file access without needing your_program.sh.
SubmissionDir string
// Executable is the program to be tested (may point to SubmissionDir if no ExecutableFileName).
Executable *executable.Executable
// contains filtered or unexported fields
}
TestCaseHarness is passed to your TestCase's TestFunc.
For BootLLM courses that don't use your_program.sh, use SubmissionDir directly:
if !harness.FileExists("hello.c") {
return fmt.Errorf("hello.c does not exist")
}
For long-lived programs (like a Redis server), use Executable:
if err := harness.Executable.Start(); err != nil {
return err
}
harness.RegisterTeardownFunc(func() { harness.Executable.Kill() })
For scripts that run and exit (like a Git command):
result, err := harness.Executable.Run("cat-file", "-p", "sha")
if err != nil {
return err
}
func (*TestCaseHarness) FileExists ¶
func (s *TestCaseHarness) FileExists(relativePath string) bool
FileExists checks if a file exists within the submission directory.
func (*TestCaseHarness) FilePath ¶
func (s *TestCaseHarness) FilePath(relativePath string) string
FilePath returns the absolute path to a file within the submission directory.
func (*TestCaseHarness) NewExecutable ¶
func (s *TestCaseHarness) NewExecutable() *executable.Executable
func (*TestCaseHarness) ReadFile ¶
func (s *TestCaseHarness) ReadFile(relativePath string) ([]byte, error)
ReadFile reads the contents of a file within the submission directory.
func (*TestCaseHarness) RegisterTeardownFunc ¶
func (s *TestCaseHarness) RegisterTeardownFunc(teardownFunc func())
func (*TestCaseHarness) RunTeardownFuncs ¶
func (s *TestCaseHarness) RunTeardownFuncs()
Click to show internal directories.
Click to hide internal directories.