Skip to content

Commit

Permalink
Merge pull request #6 from kapillamba4/add-csharp
Browse files Browse the repository at this point in the history
Add support for csharp
  • Loading branch information
championswimmer authored Jul 6, 2018
2 parents 3cc17dc + cff5e3d commit 11d5e20
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Currently we have following images -

- [c](containers/c)
- [cpp](containers/cpp)
- [c#](containers/csharp)
- [java8](containers/java8)
- [nodejs6](containers/nodejs6)
- [nodejs](containers/nodejs8)
Expand Down
10 changes: 10 additions & 0 deletions containers/csharp/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM alpine:3.6

RUN echo "@testing http://dl-4.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \
&& apk add --update --no-cache mono@testing bash

COPY ./compile.sh /bin/compile.sh
COPY ./run.sh /bin/run.sh

RUN chmod 777 /bin/compile.sh; \
chmod 777 /bin/run.sh
3 changes: 3 additions & 0 deletions containers/csharp/compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

csc program.cs 2> compile.stderr 1> compile.stdout
4 changes: 4 additions & 0 deletions containers/csharp/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

chmod 777 program.exe
mono program.exe < run.stdin 1> run.stdout 2> run.stderr
4 changes: 4 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
# bash tests/cpp/test_worker.sh
#}

@test "test csharp" {
bash tests/csharp/test_worker.sh
}

@test "test java8" {
bash tests/java8/test_worker.sh
}
Expand Down
7 changes: 7 additions & 0 deletions tests/csharp/program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using System;

public class HelloWorld {
static public void Main () {
Console.WriteLine ("Hello " + Console.ReadLine());
}
}
1 change: 1 addition & 0 deletions tests/csharp/run.stdin
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
World
37 changes: 37 additions & 0 deletions tests/csharp/test_worker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/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/program.cs $RUNBOX/program.cs
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-csharp \
bash -c "/bin/compile.sh && /bin/run.sh"

ls -lh ${RUNBOX}

expected="Hello World"
actual="$(cat ${RUNBOX}/run.stdout)"
if [ "$expected" == "$actual" ] ;then
:
else
echo "MISMATCH: Expected = $expected; Actual = $actual"
exit 1
fi

# Delete runbox
rm -rf $RUNBOX
12 changes: 11 additions & 1 deletion tests/ruby/test_worker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ docker run \
-w /usr/src/runbox codingblocks/judge-worker-ruby \
bash -c "/bin/compile.sh && /bin/run.sh"

ls -lh ${RUNBOX}

expected="Hello World"
actual="$(cat ${RUNBOX}/run.stdout)"
if [ "$expected" == "$actual" ] ;then
:
else
echo "MISMATCH: Expected = $expected; Actual = $actual"
exit 1
fi

# Delete runbox
rm -rf $RUNBOX
rm -rf $RUNBOX

0 comments on commit 11d5e20

Please sign in to comment.