pkg

package
v0.0.0-...-0d370bc Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package pkg contains internal logic of the application.

Package internal contains internal logic of the application.

Package internal contains internal logic of the application.

Package pkg contains internal logic of the application.

Package internal contains internal logic of the application.

Package internal contains internal logic of the application.

Index

Constants

View Source
const (
	NONE = TestResult(iota)
	OK
	CE
	RE
	TL
	ML
	WA
	EOC
)

Enum values

Variables

This section is empty.

Functions

This section is empty.

Types

type CodeRunnerContext

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

CodeRunnerContext is a struct that contains all necessary information for running tests.

func NewCodeRunnerContext

func NewCodeRunnerContext(filePath, executablePath, language string, compileFile string) *CodeRunnerContext

NewCodeRunnerContext creates new COdeRunnerContext with giving parameters.

func (*CodeRunnerContext) Test

func (ctx *CodeRunnerContext) Test(
	directoryWithTests string,
	testsCount int,
) (TestingResult, error)

Test tests program on given tests and returns result of testing

type Config

type Config struct {
	Workers []WorkerConfig `json:"workers"`
}

type LocalWorker

type LocalWorker struct {
}

LocalWorker is a worker that runs tasks locally.

func NewLocalWorker

func NewLocalWorker() *LocalWorker

NewLocalWorker creates new LocalWorker.

func (*LocalWorker) RunTask

func (lw *LocalWorker) RunTask(task Task) error

RunTask runs task locally.

type ProblemInfo

type ProblemInfo = string

ProblemInfo represents number of the task

type RemoteWorker

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

RemoteWorker is a worker that runs tasks remotely.

func NewRemoteWorker

func NewRemoteWorker(address string) *RemoteWorker

NewRemoteWorker creates new RemoteWorker.

func (*RemoteWorker) RunTask

func (rw *RemoteWorker) RunTask(task Task) error

RunTask runs task remotely.

type Run

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

Run represents information that need to execute program on the specified tests

func NewRun

func NewRun(fileName, language, problem, username, userId string) *Run

NewRun creates Run

type RunInfo

type RunInfo struct {
	Id       string        `json:"id"`
	Problem  ProblemInfo   `json:"problem"`
	Result   TestingResult `json:"result"`
	Time     int64         `json:"time"`
	FileName string        `json:"fileName"`
	Language string        `json:"language"`
}

RunInfo represents information about the run such as Id, Problem, Result, Time and FileName

func NewRunInfo

func NewRunInfo(id, problem string, result TestingResult, t int64, fileName, language string) *RunInfo

NewRunInfo creates pointer of type RunInfo with given RunInfo.Result and RunInfo.Time

type RunTask

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

RunTask is an implementation of Task interface that needed to run tests.

func CreateRunTask

func CreateRunTask(duration int64, startTime, testPathForProblem string, testCount int, username, compileFile string,
	run *Run, action func(*RunInfo)) *RunTask

CreateRunTask creates RunTask for running tests

func (*RunTask) Local

func (rt *RunTask) Local() error

Local runs tests locally

func (*RunTask) Remote

func (rt *RunTask) Remote(addr string) error

Remote sends post request to remote Worker with the specified address and wait for response.

type Task

type Task interface {
	Local() error
	Remote(addr string) error
}

Task is an interface that can be executed by local Worker or remote Worker.

func CreateRejudgeTask

func CreateRejudgeTask(runInfo *RunInfo) Task

CreateRejudgeTask creates Task for rejudging tests FIXME: Implement me

type TestResult

type TestResult int

TestResult type of the enum

func (*TestResult) GetString

func (t *TestResult) GetString() string

GetString returns string representation of the test result

type TestingQueue

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

TestingQueue is a queue for running tasks

func CreateSimpleTestingQueue

func CreateSimpleTestingQueue() *TestingQueue

CreateSimpleTestingQueue creates simple TestingQueue

func NewTestingQueue

func NewTestingQueue(workers chan Worker) *TestingQueue

NewTestingQueue creates new pointer to TestingQueue

func NewTestingQueueFromConfig

func NewTestingQueueFromConfig(config *Config) *TestingQueue

func NewTestingQueueFromFile

func NewTestingQueueFromFile(path string) *TestingQueue

func (*TestingQueue) PushTask

func (tq *TestingQueue) PushTask(task Task)

PushTask pushes task to the queue

func (*TestingQueue) Update

func (tq *TestingQueue) Update()

Update updates the queue

type TestingResult

type TestingResult struct {
	Number int        `json:"number"`
	Result TestResult `json:"result"`
}

TestingResult is a struct that contains information about test result.

func (*TestingResult) String

func (t *TestingResult) String() string

String return string representation of TestingResult.

type TestingSystem

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

TestingSystem represents the system that runs tests.

func NewTestingSystem

func NewTestingSystem(duration int64,
	startTime string,
	testPathForProblem string,
	testCount int,
	username string,
	compileFile string) *TestingSystem

NewTestingSystem creates new TestingSystem with giving parameters.

func (*TestingSystem) RejudgeRun

func (ts *TestingSystem) RejudgeRun(run *RunInfo) error

RejudgeRun rejudges the specified RunInfo

func (*TestingSystem) RunTests

func (ts *TestingSystem) RunTests(run *Run) (*RunInfo, error)

RunTests runs tests and return the result of testing

type Worker

type Worker interface {
	RunTask(task Task) error
}

Worker is an interface that should be implemented by all workers.

type WorkerConfig

type WorkerConfig struct {
	Type    string `json:"type"`
	Address string `json:"address"`
}

Jump to

Keyboard shortcuts

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