mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.0 KiB
54 lines
1.0 KiB
#!/bin/sh |
|
|
|
set -e |
|
|
|
cd student |
|
|
|
if test "$EXAM_MODE"; then |
|
go mod init main 2>/dev/null |
|
GOSUMDB=off go get github.com/01-edu/z01@v0.1.0 2>/dev/null |
|
fi |
|
|
|
if test "$EXAM_RUN_ONLY" = true; then |
|
go build -o exe "./$EXERCISE" |
|
./exe "$@" |
|
exit |
|
fi |
|
|
|
if ! test "$EXAM_MODE"; then |
|
s=$(goimports -d .) |
|
if test "$s"; then |
|
echo 'Your Go files are not correctly formatted :' |
|
echo |
|
echo '$ goimports -d .' |
|
echo "$s" |
|
exit 1 |
|
fi |
|
fi |
|
|
|
if ! find . -type f -name '*.go' | grep -q .; then |
|
echo "Missing Go file: $FILE" |
|
exit 1 |
|
fi |
|
|
|
if find . -type f -name '*.go' -exec grep -qE 'print(ln)?\(' {} +; then |
|
echo "Your Go files cannot use print & println builtins" |
|
exit 1 |
|
fi |
|
|
|
# Check restrictions |
|
if test "$ALLOWED_FUNCTIONS" && test "$FILE"; then |
|
# shellcheck disable=SC2086 |
|
rc "$FILE" $ALLOWED_FUNCTIONS |
|
fi |
|
|
|
# Compile and run test |
|
if command -v "${EXERCISE}_test" >/dev/null 2>&1; then |
|
# The exercise is a program |
|
go build -o exe "./$EXERCISE" |
|
"${EXERCISE}_test" |
|
else |
|
# The exercise is a function |
|
cd "/public/go/tests/func/${EXERCISE}_test" |
|
go run . |
|
fi
|
|
|