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.

50 lines
893 B

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