Browse Source

Make tester work again (need to fix sh exercises with curl)

pull/685/head
xpetit 4 years ago
parent
commit
4cb9d7cdf8
  1. 7
      dom/Dockerfile
  2. 18
      dom/entrypoint.sh
  3. 5
      go/tests/Dockerfile
  4. 47
      go/tests/entrypoint.sh
  5. 2
      go/tests/lib/lib.go
  6. 6
      js/tests/Dockerfile
  7. 20
      js/tests/entrypoint.sh
  8. 4
      sh/tests/Dockerfile
  9. 25
      sh/tests/entrypoint.sh

7
dom/Dockerfile

@ -1,11 +1,6 @@
FROM buildkite/puppeteer:5.2.1
ENV GIT_TERMINAL_PROMPT=0
RUN apt-get update
RUN apt-get install -y git
COPY --from=mkcert-ca . /usr/local/share/ca-certificates
RUN update-ca-certificates
WORKDIR /app
COPY dom .
COPY subjects ./subjects
ENTRYPOINT ["/bin/sh", "/app/entrypoint.sh"]
ENTRYPOINT ["/app/entrypoint.sh"]

18
dom/entrypoint.sh

@ -1,22 +1,6 @@
#!/bin/sh
set -o noglob
set -o errexit
set -o nounset
IFS='
'
mkdir student
cd student
if test "$REPOSITORY"; then
password=$(cat)
git clone --quiet --depth=1 --shallow-submodules https://root:"${password}"@"$REPOSITORY" .
else
first_file=$(echo "$EXPECTED_FILES" | cut -d' ' -f1)
mkdir -p "$(dirname "$first_file")"
cat > "$first_file"
fi
set -e
cd /app
node --no-warnings --unhandled-rejections=strict test.js "${EXERCISE}"

5
go/tests/Dockerfile

@ -7,7 +7,6 @@ RUN go get github.com/01-edu/z01
COPY . src
RUN go get rc
RUN go install rc prog/...
COPY entrypoint.sh /usr/local/bin
COPY --from=mkcert-ca . /usr/local/share/ca-certificates
RUN update-ca-certificates
ENTRYPOINT ["/bin/sh", "/usr/local/bin/entrypoint.sh"]
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

47
go/tests/entrypoint.sh

@ -1,25 +1,10 @@
#!/bin/sh
set -o noglob
set -o errexit
set -o nounset
IFS='
'
mkdir -p src/student
cd src/student
if test "$REPOSITORY"; then
password=$(cat)
git clone --quiet --depth=1 --shallow-submodules https://root:"${password}"@"$REPOSITORY" .
else
first_file=$(echo "$EXPECTED_FILES" | cut -d' ' -f1)
mkdir -p "$(dirname "$first_file")"
cat > "$first_file"
fi
set -e
cd student
set +o nounset # TODO: Remove me after this variable is always set in all/tester/main.go
if test "$SKIP_FORMATTING"; then
if ! test "$SKIP_FORMATTING"; then
s=$(goimports -d .)
if test "$s"; then
echo 'Your Go files are not correctly formatted :'
@ -29,7 +14,11 @@ if test "$SKIP_FORMATTING"; then
exit 1
fi
fi
set -o nounset # TODO: Remove me after this variable is always set in all/tester/main.go
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"
@ -37,23 +26,23 @@ if find . -type f -name '*.go' -exec grep -qE 'print(ln)?\(' {} +; then
fi
# Check restrictions
if test "$ALLOWED_FUNCTIONS" && test "$EXPECTED_FILES"; then
IFS=' '
first_file=$(echo "$EXPECTED_FILES" | cut -d' ' -f1)
if test "$ALLOWED_FUNCTIONS" && test "$FILE"; then
# shellcheck disable=SC2086
rc "$first_file" $ALLOWED_FUNCTIONS
rc "$FILE" $ALLOWED_FUNCTIONS
fi
IFS='
'
# Compile and run test
cd
GOPATH=$HOME:$GOPATH
# Compile and run test
if command -v "${EXERCISE}_test" >/dev/null 2>&1; then
# The exercise is a program
go build "./src/student/$EXERCISE"
go build -o exe "./student/$EXERCISE"
"${EXERCISE}_test"
else
# The exercise is a function
mkdir src
ln -s $(pwd)/student $(pwd)/src/student
GOPATH=$GOPATH:$PWD
go build "func/${EXERCISE}_test"
"./${EXERCISE}_test"
fi

2
go/tests/lib/lib.go

@ -371,7 +371,7 @@ func ChallengeMainStdin(exercise, input string, args ...string) {
code := func(code int) string {
return fmt.Sprintf("echo $?\n%d\n$", code)
}
student, studentCode := run("./" + exercise)
student, studentCode := run("./exe")
solution, solutionCode := run(exercise + "_prog")
if solutionCode == 0 {
if studentCode != 0 {

6
js/tests/Dockerfile

@ -1,9 +1,5 @@
FROM node:14.7.0-alpine3.12
ENV GIT_TERMINAL_PROMPT=0
RUN apk add --no-cache git
COPY --from=mkcert-ca . /usr/local/share/ca-certificates
RUN update-ca-certificates
WORKDIR /app
COPY . .
ENTRYPOINT ["/bin/sh", "/app/entrypoint.sh"]
ENTRYPOINT ["/app/entrypoint.sh"]

20
js/tests/entrypoint.sh

@ -1,23 +1,5 @@
#!/bin/sh
set -o noglob
set -o errexit
set -o nounset
IFS='
'
mkdir student
cd student
if test "$REPOSITORY"; then
password=$(cat)
git clone --quiet --depth=1 --shallow-submodules https://root:"${password}"@"$REPOSITORY" .
else
first_file=$(echo "$EXPECTED_FILES" | cut -d' ' -f1)
mkdir -p "$(dirname "$first_file")"
cat > "$first_file"
fi
cd
set -e
node /app/test.mjs "${EXERCISE}"

4
sh/tests/Dockerfile

@ -2,7 +2,5 @@ FROM debian:10.5-slim
RUN apt-get update
RUN apt-get -y install jq curl git
COPY --from=mkcert-ca . /usr/local/share/ca-certificates
RUN update-ca-certificates
COPY . /app
ENTRYPOINT ["/bin/bash", "/app/entrypoint.sh"]
ENTRYPOINT ["/app/entrypoint.sh"]

25
sh/tests/entrypoint.sh

@ -1,28 +1,13 @@
#!/usr/bin/env bash
# Unofficial Bash Strict Mode
set -euo pipefail
IFS='
'
set -e
mkdir student
cd student
if test "$REPOSITORY"; then
password=$(cat)
git clone --quiet --depth=1 --shallow-submodules https://root:"${password}"@"$REPOSITORY" .
else
first_file=$(echo "$EXPECTED_FILES" | cut -d' ' -f1)
mkdir -p "$(dirname "$first_file")"
cat > "$first_file"
chmod +x "$first_file"
fi
cd
cp -rT /app .
cp -r /app .
cp -a student app
cd app
if ! test -f "${EXERCISE}_test.sh"; then
echo No test file found for the exercise : "$EXERCISE"
echo "No test file found for the exercise : $EXERCISE"
exit 1
fi

Loading…
Cancel
Save