test_case_harness

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 10, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

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()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL