From 37e153a5b658cb29ad0511c2dad9d9957918fe44 Mon Sep 17 00:00:00 2001 From: Arnav Gupta Date: Fri, 6 Jul 2018 05:57:35 +0530 Subject: [PATCH 1/2] kotlin support Signed-off-by: Arnav Gupta --- containers/kotlin/Dockerfile | 7 +++++++ containers/kotlin/compile.sh | 3 +++ containers/kotlin/run.sh | 3 +++ test.sh | 4 ++++ tests/kotlin/Main.kt | 4 ++++ tests/kotlin/run.stdin | 1 + tests/kotlin/test_worker.sh | 26 ++++++++++++++++++++++++++ 7 files changed, 48 insertions(+) create mode 100644 containers/kotlin/Dockerfile create mode 100755 containers/kotlin/compile.sh create mode 100644 containers/kotlin/run.sh create mode 100644 tests/kotlin/Main.kt create mode 100644 tests/kotlin/run.stdin create mode 100755 tests/kotlin/test_worker.sh 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..5f14e8b 100755 --- a/test.sh +++ b/test.sh @@ -28,3 +28,7 @@ sh tests/py3/test_worker.sh } +@test "test kotlin" { + sh 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 From aa2514a1e661cf693bc3356de6d619a612ce83b2 Mon Sep 17 00:00:00 2001 From: Arnav Gupta Date: Fri, 6 Jul 2018 18:25:15 +0530 Subject: [PATCH 2/2] bash test --- test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.sh b/test.sh index 5f14e8b..111e17f 100755 --- a/test.sh +++ b/test.sh @@ -29,6 +29,6 @@ } @test "test kotlin" { - sh tests/kotlin/test_worker.sh + bash tests/kotlin/test_worker.sh }