BootLab Tester Utils
A shared framework module for BootLab course testing tools.
Based on: codecrafters-io/tester-utils
Key improvements:
-
Flexible run modes - Three execution modes:
- Full JSON format (platform-dispatched)
- Single stage test (development/debugging)
- Run all tests (local self-test, default)
-
CLI argument support - Command-line argument parsing:
- Positional:
./tester hello
- Flags:
./tester -s hello -d ~/work
- Help/version:
--help, --version
-
Optional config file - bootlab.yml is optional (with sensible defaults), not mandatory
-
Default working directory - BOOTLAB_REPOSITORY_DIR defaults to current directory ., no explicit setup needed
-
New SubmissionDir - TestCaseHarness exposes the student submission directory for easy relative path access
-
Improved Runner API - Enhanced program testing API with automatic local executable detection
Quick Start
package main
import (
"os"
tester_utils "github.com/bootlab-dev/tester-utils"
)
func main() {
definition := GetDefinition() // your test definition
os.Exit(tester_utils.Run(os.Args[1:], definition))
}
CLI Usage
# Run all tests
./tester
# Run a specific stage
./tester hello
./tester -s hello
./tester --stage hello
# Specify working directory
./tester -d ./my-solution hello
# Show help
./tester --help
Runner Package
Fluent API for testing programs (similar to check50):
import "github.com/bootlab-dev/tester-utils/runner"
// Basic usage
err := runner.Run("./hello").
Stdin("Alice").
Stdout("hello, Alice").
Exit(0)
// PTY support
err := runner.Run("./mario").
WithPty().
Stdin("5").
Stdout("#####").
Exit(0)
// Test input rejection
err := runner.Run("./mario").
Stdin("-1").
Reject()
Environment Variables
Streaming log support (Worker integration):
BOOTLAB_STREAM_LOGS=1 - Disables colors and redirects stdout to stderr, enabling the Worker to capture real-time log streams
Documentation
For detailed API documentation, see GoDoc.