Skip to content

Commit affca97

Browse files
VibhorCodecianGuptaVibhorCodecianGupta
authored andcommitted
swift
1 parent 52f952b commit affca97

File tree

5 files changed

+63
-3
lines changed

5 files changed

+63
-3
lines changed

containers/swift/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM ubuntu:16.04
2+
3+
RUN apt-get install swift-4.0.3-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

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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import Foundation
2+
3+
let inputStr = readLine()
4+
if let inputStr = inputStr {
5+
print("Hello ", inputStr)
6+
}

tests/swift/test_worker.sh

Lines changed: 41 additions & 0 deletions
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.swift $RUNBOX/script.swift
15+
cp -fv $DIR/run.stdin $RUNBOX/run.stdin
16+
17+
# Test Compile
18+
docker run \
19+
--cpus="1" \
20+
--memory="100m" \
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-swift \
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)