internal

package
v0.2.0-alpha Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultURL = "https://www.turing.sk"
)

Variables

View Source
var (
	ErrTestFailedByExitCode = errors.New("test failed by exit code")
	ErrBuildFailed          = errors.New("build failed")
	ErrNoBuildCommand       = errors.New("no build command specified")
	ErrNoExecutable         = errors.New("no executable specified")
	ErrNoMainFile           = errors.New("no main file specified")
	ErrInvalidTests         = errors.New("invalid tests")
)
View Source
var (
	ErrLoginFailed          = fmt.Errorf("login failed")
	ErrSaveAssignmentFailed = fmt.Errorf("save assignment failed")
)

Functions

func GetLogger

func GetLogger() *zap.SugaredLogger

func RenderResult

func RenderResult(testName, expected, got, input string, err error, execTime time.Duration, strip bool) (string, error)

func SetupLogger

func SetupLogger(verbose bool)

func TestsMarshal

func TestsMarshal(tests Tests) ([]byte, error)

Types

type BuildResult

type BuildResult struct {
	ExitCode int
}

func RunBuild

func RunBuild(ctx context.Context, buildCommands []string, workingDir string, stdOutWriter io.Writer, stdErrWriter io.Writer) (*BuildResult, error)

type CloudTuring

type CloudTuring struct {
	Name     string `yaml:"name"`
	Password string `yaml:"password"`
	URL      string `yaml:"url,omitempty"`
}

type Config

type Config struct {
	CloudTuring CloudTuring `yaml:"cloud-turing,omitempty"`
	LocalTuring LocalTuring `yaml:"local-turing"`
}

func ReadConfig

func ReadConfig(r io.Reader) (*Config, error)

type LocalTuring

type LocalTuring struct {
	TestsFile     string                  `yaml:"tests-file"`
	BuildCommands []string                `yaml:"build-commands,omitempty"`
	Executable    string                  `yaml:"executable,omitempty"`
	MainFile      string                  `yaml:"main-file,omitempty"`
	Assignments   []LocalTuringAssignment `yaml:"assignments"`
}

type LocalTuringAssignment

type LocalTuringAssignment struct {
	Name          string   `yaml:"name"`
	Dir           string   `yaml:"dir,omitempty"`
	BuildCommands []string `yaml:"build-commands,omitempty"`
	Executable    string   `yaml:"executable,omitempty"`
	MainFile      string   `yaml:"main-file,omitempty"`
	PushName      string   `yaml:"push-name,omitempty"`
}

type Test

type Test struct {
	Inputs  string `json:"inputs"`
	Outputs string `json:"outputs"`
}

type TestResult

type TestResult struct {
	StdOut   string
	StdErr   string
	ExitCode int
}

func RunTest

func RunTest(ctx context.Context, workingDir, executable, testInput, testOutput string) (*TestResult, error)

type Tests

type Tests struct {
	Schema string            `json:"$schema"`
	Tests  map[string][]Test `json:"tests"`
}

func TestsUnmarshal

func TestsUnmarshal(r io.Reader) (Tests, error)

type TuringClient

type TuringClient struct {
	// contains filtered or unexported fields
}

func NewTuringClient

func NewTuringClient(url string) (*TuringClient, error)
func (c *TuringClient) GetAssignmentLink(assignment *LocalTuringAssignment) string

func (*TuringClient) Login

func (c *TuringClient) Login(username, password string) error

func (*TuringClient) SaveAssigment

func (c *TuringClient) SaveAssigment(assignment *LocalTuringAssignment) error

Jump to

Keyboard shortcuts

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