-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add epicbox-hyperskill/go image (#33)
- Loading branch information
Vladimir Turov
authored
Jun 16, 2021
1 parent
1c8f891
commit 7c4bc4d
Showing
3 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM golang:1.16.5-buster | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y python3 python3-pip && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
RUN pip3 install https://github.com/hyperskill/hs-test-python/archive/v5.tar.gz | ||
|
||
COPY checker/ /checker/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
cd /sandbox | ||
python3 tests.py --inside_docker > stdout.txt 2> stderr.txt | ||
echo $? > code.txt | ||
python3 /checker/process.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import json | ||
|
||
FAILED_TEST_BEGIN = '#educational_plugin FAILED + ' | ||
FAILED_TEST_CONTINUE = '#educational_plugin ' | ||
|
||
if __name__ == '__main__': | ||
score = 1 | ||
feedback = '' | ||
|
||
code = open('code.txt').read().strip() | ||
stdout = open('stdout.txt').read().splitlines() | ||
stderr = open('stderr.txt').read().splitlines() | ||
if code != '0': | ||
score = 0 | ||
feedback = ( | ||
'Cannot check the submission.\n\nPerhaps your program ' | ||
'has fallen into an infinite loop or created too many objects in memory. ' | ||
'If you are sure that this is not the case, please send the report to [email protected]\n' | ||
'stdout:\n{stdout}\n\nstderr:\n{stderr}' | ||
.format(stdout='\n'.join(stdout), stderr='\n'.join(stderr)) | ||
) | ||
|
||
elif any(line.startswith(FAILED_TEST_BEGIN) for line in stdout): | ||
score = 0 | ||
output = [] | ||
output_started = False | ||
|
||
for line in stdout: | ||
if output_started and line.startswith(FAILED_TEST_CONTINUE): | ||
output.append(line[len(FAILED_TEST_CONTINUE):]) | ||
|
||
if not output_started and line.startswith(FAILED_TEST_BEGIN): | ||
output_started = True | ||
output.append(line[len(FAILED_TEST_BEGIN):]) | ||
|
||
feedback = '\n'.join(output).strip() | ||
|
||
result = { | ||
'score': score, | ||
'feedback': feedback, | ||
} | ||
print(json.dumps(result)) |