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.

49 lines
907 B

#!/bin/sh
set -o noglob
set -o errexit
4 years ago
set -o nounset
IFS='
'
mkdir -p src/student
4 years ago
cd src/student
if test "$REPOSITORY"; then
password=$(cat)
4 years ago
git clone --quiet --depth=1 --shallow-submodules http://root:"${password}"@"$REPOSITORY" .
else
first_file=$(echo "$EXPECTED_FILES" | cut -d' ' -f1)
mkdir -p "$(dirname "$first_file")"
cat > "$first_file"
fi
4 years ago
# Check formatting
s=$(goimports -d .)
if test "$s"; then
echo '$ goimports -d .'
echo "$s"
exit 1
fi
4 years ago
# Check restrictions
if test "$ALLOWED_FUNCTIONS"; then
for file in $EXPECTED_FILES; do
# shellcheck disable=SC2086
4 years ago
rc "$file" $ALLOWED_FUNCTIONS
done
fi
4 years ago
# Compile and run test
4 years ago
cd
4 years ago
GOPATH=$HOME:$GOPATH
if command -v "${EXERCISE}_test" >/dev/null 2>&1; then
4 years ago
# The exercise is a program
go build "./src/student/$EXERCISE"
"${EXERCISE}_test"
4 years ago
else
# The exercise is a function
go build "func/${EXERCISE}_test"
"./${EXERCISE}_test"
4 years ago
fi