Skip to content

Commit 3ae489c

Browse files
VibhorCodecianGuptaVibhorCodecianGupta
authored andcommitted
swift support
1 parent 11d5e20 commit 3ae489c

File tree

7 files changed

+61
-3
lines changed

7 files changed

+61
-3
lines changed

containers/swift/Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM swiftdocker/swift:latest
2+
3+
COPY ./compile.sh /bin/compile.sh
4+
COPY ./run.sh /bin/run.sh
5+
6+
RUN chmod 777 /bin/compile.sh; \
7+
chmod 777 /bin/run.sh

containers/swift/compile.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#!/usr/bin/env bash

containers/swift/run.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
3+
chmod 777 script.swift
4+
swift script.swift < run.stdin 1> run.stdout 2> run.stderr

test.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
bash tests/c/test_worker.sh
55
}
66

7-
#@test "test cpp" {
8-
# bash tests/cpp/test_worker.sh
9-
#}
7+
@test "test cpp" {
8+
bash tests/cpp/test_worker.sh
9+
}
1010

1111
@test "test csharp" {
1212
bash tests/csharp/test_worker.sh
@@ -36,3 +36,6 @@
3636
bash tests/ruby/test_worker.sh
3737
}
3838

39+
@test "test swift" {
40+
bash tests/swift/test_worker.sh
41+
}

tests/swift/run.stdin

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
World

tests/swift/script.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import Foundation
2+
3+
let input = readLine()
4+
if let input = input { print("Hello",input) }

tests/swift/test_worker.sh

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

0 commit comments

Comments
 (0)