Skip to content

Add test support for rust language #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion internal/container/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
FROM ubuntu:latest
RUN apt update && apt install -y g++ gcc bash perl
RUN apt update && apt install -y g++ gcc bash perl
RUN DEBIAN_FRONTEND=noninteractive apt install -y openjdk-8-jdk
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y
RUN echo 'source $HOME/.cargo/env' >> $HOME/.bashrc
WORKDIR /tests
COPY . /tests
RUN apt install -y --install-recommends ./benchexec_*.deb
Expand Down
45 changes: 45 additions & 0 deletions test/rust_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package tests

import (
"io/ioutil"
"log"
"testing"

"github.com/codeiiest/test-runner/runner/run"
"github.com/codeiiest/test-runner/test/utils"
)

func TestRust(t *testing.T) {
t.Helper()
t.Run("Rust test with all ACCEPTED", func(t *testing.T) {
testDat, _ := ioutil.ReadFile("testdata/rust/main.rs")
testIn := []string{""}
testOut := []string{"x x y: 12"}
var testCases int = 1
var testTimeLimit int = 1
var testMemoryLimit int64 = 500 * 1024 * 1024
got := run.Evaluate(string(testDat), "rust", "main.rs", testIn, testOut, testCases, testTimeLimit, testMemoryLimit)
log.Print(got, "\n", got.Status, got.Message, got.Error, got.Result)
wantStatus := "OK"
wantMessage := ""
wantError := []string{""}
wantResult := []string{"ACCEPTED"}
utils.CompareUtils(got, wantStatus, wantMessage, wantError, wantResult, t)
})

t.Run("Rust test with 1 WRONG ANSWER", func(t *testing.T) {
testDat, _ := ioutil.ReadFile("testdata/rust/main.rs")
testIn := []string{""}
testOut := []string{"-1"}
var testCases int = 1
var testTimeLimit int = 1
var testMemoryLimit int64 = 500 * 1024 * 1024
got := run.Evaluate(string(testDat), "rust", "main.rs", testIn, testOut, testCases, testTimeLimit, testMemoryLimit)
log.Print(got, "\n", got.Status, got.Message, got.Error, got.Result)
wantStatus := "OK"
wantMessage := ""
wantError := []string{"", "", ""}
wantResult := []string{"WRONG ANSWER"}
utils.CompareUtils(got, wantStatus, wantMessage, wantError, wantResult, t)
})
}
5 changes: 5 additions & 0 deletions test/testdata/rust/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fn main() {
let x: i32 = 4;
let y: i32 = 3;
println!("x x y: {}", x * y);
}