diff options
| author | nsfisis <nsfisis@gmail.com> | 2024-08-05 05:35:37 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2024-08-05 05:35:37 +0900 |
| commit | dc16e903999af89d87364ad6619e7c8b41301da4 (patch) | |
| tree | 529f1debc2972ac1486e8c0ca4b25827ccd069a6 /backend/taskqueue/processor.go | |
| parent | 2a551a05d714657d7cd3b581290054c97398e968 (diff) | |
| download | iosdc-japan-2025-albatross-dc16e903999af89d87364ad6619e7c8b41301da4.tar.gz iosdc-japan-2025-albatross-dc16e903999af89d87364ad6619e7c8b41301da4.tar.zst iosdc-japan-2025-albatross-dc16e903999af89d87364ad6619e7c8b41301da4.zip | |
feat: show execution result in play page
Diffstat (limited to 'backend/taskqueue/processor.go')
| -rw-r--r-- | backend/taskqueue/processor.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/backend/taskqueue/processor.go b/backend/taskqueue/processor.go index 1105da5..e505c5a 100644 --- a/backend/taskqueue/processor.go +++ b/backend/taskqueue/processor.go @@ -15,11 +15,13 @@ import ( type ExecProcessor struct { q *db.Queries + c chan string } -func NewExecProcessor(q *db.Queries) *ExecProcessor { +func NewExecProcessor(q *db.Queries, c chan string) *ExecProcessor { return &ExecProcessor{ q: q, + c: c, } } @@ -78,6 +80,7 @@ func (p *ExecProcessor) ProcessTask(ctx context.Context, t *asynq.Task) error { if err != nil { return fmt.Errorf("CreateTestcaseExecution failed: %v", err) } + p.c <- "compile_error" return fmt.Errorf("swiftc failed: %v", resData.Stderr) } } @@ -118,6 +121,7 @@ func (p *ExecProcessor) ProcessTask(ctx context.Context, t *asynq.Task) error { if err != nil { return fmt.Errorf("CreateTestcaseExecution failed: %v", err) } + p.c <- "compile_error" return fmt.Errorf("wasmc failed: %v", resData.Stderr) } } @@ -166,6 +170,7 @@ func (p *ExecProcessor) ProcessTask(ctx context.Context, t *asynq.Task) error { if err != nil { return fmt.Errorf("CreateTestcaseExecution failed: %v", err) } + p.c <- resData.Result return fmt.Errorf("testrun failed: %v", resData.Stderr) } if isTestcaseExecutionCorrect(testcase.Stdout, resData.Stdout) { @@ -179,6 +184,7 @@ func (p *ExecProcessor) ProcessTask(ctx context.Context, t *asynq.Task) error { if err != nil { return fmt.Errorf("CreateTestcaseExecution failed: %v", err) } + p.c <- "wrong_answer" return fmt.Errorf("testrun failed: %v", resData.Stdout) } } |
