Skip to content

Commit bdde0e6

Browse files
vibhorgupta-ghchampionswimmer
authored andcommitted
perl support (#25)
1 parent 4b2c82a commit bdde0e6

File tree

8 files changed

+62
-0
lines changed

8 files changed

+62
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Currently we have following images -
2626
- [java8](containers/java8)
2727
- [nodejs6](containers/nodejs6)
2828
- [nodejs](containers/nodejs8)
29+
- [perl](containers/perl)
2930
- [py2](containers/py2)
3031
- [py3](containers/py3)
3132
- [ruby](containers/ruby)

containers/perl/Dockerfile

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM alpine:3.6
2+
3+
RUN apk add --no-cache perl="5.24.4-r0" bash
4+
5+
COPY ./compile.sh /bin/compile.sh
6+
COPY ./run.sh /bin/run.sh
7+
8+
RUN chmod 777 /bin/compile.sh; \
9+
chmod 777 /bin/run.sh

containers/perl/compile.sh

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#!/usr/bin/env bash

containers/perl/run.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
perl script.pl < run.stdin 1> run.stdout 2> run.stderr

test.sh

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
bash tests/nodejs8/test_worker.sh
2929
}
3030

31+
@test "test perl" {
32+
bash tests/perl/test_worker.sh
33+
}
34+
3135
@test "test py2" {
3236
bash tests/py2/test_worker.sh
3337
}

tests/perl/run.stdin

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
World

tests/perl/script.pl

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
$input = <STDIN>;
2+
print "Hello ${input}";

tests/perl/test_worker.sh

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env bash
2+
pushd $(dirname "$0")
3+
DIR=$(pwd)
4+
RUNBOX="${DIR}/runbox"
5+
6+
echo $RUNBOX
7+
# Remove RUNBOX
8+
rm -rf $RUNBOX
9+
10+
# Create runbox
11+
mkdir -p $RUNBOX
12+
13+
# Copy source to runbox
14+
cp -fv $DIR/script.pl $RUNBOX/script.pl
15+
cp -fv $DIR/run.stdin $RUNBOX/run.stdin
16+
17+
# Test Compile
18+
docker run \
19+
--cpus="0.5" \
20+
--memory="20m" \
21+
--ulimit nofile=64:64 \
22+
--rm \
23+
--read-only \
24+
-v "$RUNBOX":/usr/src/runbox \
25+
-v "$RUNBOX":/tmp \
26+
-w /usr/src/runbox codingblocks/judge-worker-perl \
27+
bash -c "/bin/compile.sh && /bin/run.sh"
28+
29+
ls -lh ${RUNBOX}
30+
31+
expected="Hello World"
32+
actual="$(cat ${RUNBOX}/run.stdout)"
33+
if [ "$expected" == "$actual" ] ;then
34+
:
35+
else
36+
echo "MISMATCH: Expected = $expected; Actual = $actual"
37+
exit 1
38+
fi
39+
40+
# Delete runbox
41+
rm -rf $RUNBOX

0 commit comments

Comments
 (0)