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.
49 lines
899 B
49 lines
899 B
5 years ago
|
#!/bin/sh
|
||
|
|
||
5 years ago
|
set -o errexit
|
||
|
set -o pipefail
|
||
5 years ago
|
set -o nounset
|
||
5 years ago
|
IFS='
|
||
|
'
|
||
5 years ago
|
mkdir -p src/student
|
||
|
cd src/student
|
||
5 years ago
|
|
||
5 years ago
|
if test "$REPOSITORY"; then
|
||
5 years ago
|
password=$(cat)
|
||
|
if ! git clone --depth=1 --shallow-submodules https://root:"${password}"@"$REPOSITORY" . 2>/dev/null; then
|
||
|
echo Could not clone your repository
|
||
|
exit 1
|
||
|
fi
|
||
|
else
|
||
|
first_file=$(echo "$EXPECTED_FILES" | cut -d' ' -f1)
|
||
|
mkdir -p "$(dirname $first_file)"
|
||
|
cat > "$first_file"
|
||
5 years ago
|
fi
|
||
|
|
||
5 years ago
|
# Check formatting
|
||
|
s=$(goimports -d .)
|
||
|
if test "$s"; then
|
||
|
echo '$ goimports -d .'
|
||
|
echo "$s"
|
||
5 years ago
|
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
|