Browse Source

Put back student repository as read-only #3

pull/768/head
xpetit 4 years ago
parent
commit
0d38d78c63
No known key found for this signature in database
GPG Key ID: 97C60669182C17A5
  1. 5
      go/tests/Dockerfile
  2. 9
      go/tests/entrypoint.sh
  3. 2
      go/tests/go.mod

5
go/tests/Dockerfile

@ -5,8 +5,8 @@ RUN apk add --no-cache git
RUN go get golang.org/x/tools/cmd/goimports RUN go get golang.org/x/tools/cmd/goimports
RUN mkdir -p /jail/student RUN mkdir -p /piscine-go
RUN touch /jail/student/go.mod RUN touch /piscine-go/go.mod
WORKDIR /public/go/tests WORKDIR /public/go/tests
COPY go.* ./ COPY go.* ./
@ -17,6 +17,7 @@ COPY lib lib
COPY prog prog COPY prog prog
COPY rc rc COPY rc rc
RUN go install ./rc ./prog/... RUN go install ./rc ./prog/...
RUN rm -rf /piscine-go
COPY entrypoint.sh /usr/local/bin COPY entrypoint.sh /usr/local/bin
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

9
go/tests/entrypoint.sh

@ -2,7 +2,8 @@
set -e set -e
cd student cp -a student piscine-go
cd piscine-go
if test "$EXAM_MODE"; then if test "$EXAM_MODE"; then
go mod init main 2>/dev/null go mod init main 2>/dev/null
@ -10,8 +11,7 @@ if test "$EXAM_MODE"; then
fi fi
if test "$EXAM_RUN_ONLY" = true; then if test "$EXAM_RUN_ONLY" = true; then
go build -o ../exe "./$EXERCISE" go build -o exe "./$EXERCISE"
cd ..
./exe "$@" ./exe "$@"
exit exit
fi fi
@ -46,8 +46,7 @@ fi
# Compile and run test # 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 -o ../exe "./$EXERCISE" go build -o exe "./$EXERCISE"
cd ..
"${EXERCISE}_test" "${EXERCISE}_test"
else else
# The exercise is a function # The exercise is a function

2
go/tests/go.mod

@ -9,4 +9,4 @@ require (
student v0.0.0 student v0.0.0
) )
replace student => ../../../jail/student replace student => ../../../piscine-go

Loading…
Cancel
Save