diff --git a/containers/kotlin/Dockerfile b/containers/kotlin/Dockerfile new file mode 100644 index 0000000..e2cf865 --- /dev/null +++ b/containers/kotlin/Dockerfile @@ -0,0 +1,7 @@ +FROM zenika/alpine-kotlin:1.2 + +COPY ./compile.sh /bin/compile.sh +COPY ./run.sh /bin/run.sh + +RUN chmod 777 /bin/compile.sh; \ + chmod 777 /bin/run.sh diff --git a/containers/kotlin/compile.sh b/containers/kotlin/compile.sh new file mode 100755 index 0000000..1118139 --- /dev/null +++ b/containers/kotlin/compile.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +kotlinc Main.kt 2> compile.stderr 1> compile.stdout diff --git a/containers/kotlin/run.sh b/containers/kotlin/run.sh new file mode 100644 index 0000000..59af5c5 --- /dev/null +++ b/containers/kotlin/run.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +kotlin MainKt < run.stdin 1> run.stdout 2> run.stderr \ No newline at end of file diff --git a/test.sh b/test.sh index ee3af42..111e17f 100755 --- a/test.sh +++ b/test.sh @@ -28,3 +28,7 @@ sh tests/py3/test_worker.sh } +@test "test kotlin" { + bash tests/kotlin/test_worker.sh +} + diff --git a/tests/kotlin/Main.kt b/tests/kotlin/Main.kt new file mode 100644 index 0000000..4ba92b5 --- /dev/null +++ b/tests/kotlin/Main.kt @@ -0,0 +1,4 @@ + +fun main(args: Array) { + println("Hello") +} \ No newline at end of file diff --git a/tests/kotlin/run.stdin b/tests/kotlin/run.stdin new file mode 100644 index 0000000..beef906 --- /dev/null +++ b/tests/kotlin/run.stdin @@ -0,0 +1 @@ +World \ No newline at end of file diff --git a/tests/kotlin/test_worker.sh b/tests/kotlin/test_worker.sh new file mode 100755 index 0000000..fa8a9c9 --- /dev/null +++ b/tests/kotlin/test_worker.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +pushd $(dirname "$0") +DIR=$(pwd) +RUNBOX="${DIR}/runbox" + +echo $RUNBOX +# Create runbox +mkdir -p $RUNBOX + +# Copy source to runbox +cp $DIR/Main.java $RUNBOX/Main.kt +cp $DIR/run.stdin $RUNBOX/run.stdin + +# Test Compile +docker run \ + --cpus="1" \ + --memory="100m" \ + --ulimit nofile=64:64 \ + --rm \ + --read-only \ + -v "$RUNBOX":/usr/src/runbox \ + -w /usr/src/runbox codingblocks/judge-worker-kotlin \ + bash -c "/bin/compile.sh && /bin/run.sh" + +# Delete runbox +rm -rf $RUNBOX \ No newline at end of file