Browse Source

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

content-update
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 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 WORKDIR /app
COPY dom . COPY dom .
COPY subjects ./subjects COPY subjects ./subjects
ENTRYPOINT ["/bin/sh", "/app/entrypoint.sh"] ENTRYPOINT ["/app/entrypoint.sh"]

18
dom/entrypoint.sh

@ -1,22 +1,6 @@
#!/bin/sh #!/bin/sh
set -o noglob set -e
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 /app cd /app
node --no-warnings --unhandled-rejections=strict test.js "${EXERCISE}" 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 COPY . src
RUN go get rc RUN go get rc
RUN go install rc prog/... RUN go install rc prog/...
COPY entrypoint.sh /usr/local/bin COPY entrypoint.sh /usr/local/bin
COPY --from=mkcert-ca . /usr/local/share/ca-certificates ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
RUN update-ca-certificates
ENTRYPOINT ["/bin/sh", "/usr/local/bin/entrypoint.sh"]

47
go/tests/entrypoint.sh

@ -1,25 +1,10 @@
#!/bin/sh #!/bin/sh
set -o noglob set -e
set -o errexit
set -o nounset cd student
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 +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 .) s=$(goimports -d .)
if test "$s"; then if test "$s"; then
echo 'Your Go files are not correctly formatted :' echo 'Your Go files are not correctly formatted :'
@ -29,7 +14,11 @@ if test "$SKIP_FORMATTING"; then
exit 1 exit 1
fi fi
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 if find . -type f -name '*.go' -exec grep -qE 'print(ln)?\(' {} +; then
echo "Your Go files cannot use print & println builtins" 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 fi
# Check restrictions # Check restrictions
if test "$ALLOWED_FUNCTIONS" && test "$EXPECTED_FILES"; then if test "$ALLOWED_FUNCTIONS" && test "$FILE"; then
IFS=' '
first_file=$(echo "$EXPECTED_FILES" | cut -d' ' -f1)
# shellcheck disable=SC2086 # shellcheck disable=SC2086
rc "$first_file" $ALLOWED_FUNCTIONS rc "$FILE" $ALLOWED_FUNCTIONS
fi fi
IFS='
'
# Compile and run test
cd cd
GOPATH=$HOME:$GOPATH
# Compile and run test
if command -v "${EXERCISE}_test" >/dev/null 2>&1; then if command -v "${EXERCISE}_test" >/dev/null 2>&1; then
# The exercise is a program # The exercise is a program
go build "./src/student/$EXERCISE" go build -o exe "./student/$EXERCISE"
"${EXERCISE}_test" "${EXERCISE}_test"
else else
# The exercise is a function # The exercise is a function
mkdir src
ln -s $(pwd)/student $(pwd)/src/student
GOPATH=$GOPATH:$PWD
go build "func/${EXERCISE}_test" go build "func/${EXERCISE}_test"
"./${EXERCISE}_test" "./${EXERCISE}_test"
fi fi

2
go/tests/lib/lib.go

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

6
js/tests/Dockerfile

@ -1,9 +1,5 @@
FROM node:14.7.0-alpine3.12 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 WORKDIR /app
COPY . . COPY . .
ENTRYPOINT ["/bin/sh", "/app/entrypoint.sh"] ENTRYPOINT ["/app/entrypoint.sh"]

20
js/tests/entrypoint.sh

@ -1,23 +1,5 @@
#!/bin/sh #!/bin/sh
set -o noglob set -e
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
node /app/test.mjs "${EXERCISE}" 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 update
RUN apt-get -y install jq curl git RUN apt-get -y install jq curl git
COPY --from=mkcert-ca . /usr/local/share/ca-certificates
RUN update-ca-certificates
COPY . /app 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 #!/usr/bin/env bash
# Unofficial Bash Strict Mode set -e
set -euo pipefail
IFS='
'
mkdir student cp -r /app .
cd student cp -a student app
cd app
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 .
if ! test -f "${EXERCISE}_test.sh"; then 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 exit 1
fi fi

Loading…
Cancel
Save