diff --git a/Jenkinsfile b/Jenkinsfile index 5eb7e32..e7c305d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -14,19 +14,20 @@ pipeline { script { //def implementations = sh(script: 'docker run retropikzel1/compile-r7rs:chibi sh -c "compile-r7rs --list-r7rs-schemes"', returnStdout: true).split() def implementations = "chibi chicken gauche guile kawa mosh racket sagittarius stklos ypsilon".split() + def DOCKERIMG = sh(script: 'make docker-image', returnStdout: true) parallel implementations.collectEntries { implementation-> [(implementation): { stage("${implementation} install") { catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { - sh "docker build --build-arg SCHEME=${implementation} --tag=foreign-c-test-${implementation} -f dockerfiles/Dockerfile.snow-chibi-install-test ." + sh "docker build --build-arg IMAGE=${DOCKERIMG} --build-arg SCHEME=${implementation} --tag=foreign-c-test-${implementation} -f dockerfiles/Dockerfile.snow-chibi-install-test ." sh "docker run -v ${WORKSPACE}:/workdir -w /workdir -t foreign-c-test-${implementation} sh -c \"timeout 120 make clean all install-jenkins SCHEME=${implementation} && cp tests/hello.scm /tmp/ && cd /tmp && SCHEME=${implementation} compile-r7rs -o hello hello.scm && timeout 120 ./hello\"" } } tests.each { test -> stage("${implementation} ${test}") { catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { - sh "docker build --build-arg SCHEME=${implementation} --tag=foreign-c-test-${implementation} -f dockerfiles/Dockerfile.test ." + sh "docker build --build-arg IMAGE=${DOCKERIMG} --build-arg SCHEME=${implementation} --tag=foreign-c-test-${implementation} -f dockerfiles/Dockerfile.test ." sh "docker run -v ${WORKSPACE}:/workdir -w /workdir -t foreign-c-test-${implementation} sh -c \"timeout 120 make SCHEME=${implementation} TEST=${test} clean test\"" } } diff --git a/Makefile b/Makefile index 4b81db3..fcfcfce 100644 --- a/Makefile +++ b/Makefile @@ -6,9 +6,16 @@ VERSION=$(shell awk '/version:/{ print $$2 }' README.md ) TEST=primitives SCHEME=chibi TMPDIR=tmp/${SCHEME} +DOCKERIMG=${SCHEME}:head +ifeq "${SCHEME}" "chicken" +DOCKERIMG=${SCHEME} +endif all: build ${TMPDIR} +docker-image: + echo ${DOCKERIMG} + build: snow-chibi package \ --version=${VERSION} \ @@ -79,7 +86,7 @@ test-compile-r7rs-wine: wine ./${TEST}.bat test-docker: - docker build --build-arg SCHEME=${SCHEME} --tag=foreign-c-test-${SCHEME} -f dockerfiles/Dockerfile.test . + docker build --build-arg IMAGE=${DOCKERIMG} --build-arg SCHEME=${SCHEME} --tag=foreign-c-test-${SCHEME} -f dockerfiles/Dockerfile.test . docker run -it -v "${PWD}:/workdir" -w /workdir -t foreign-c-test-${SCHEME} sh -c "make SCHEME=${SCHEME} TEST=${TEST} test" ${TMPDIR}/test/libtest.o: tests/c-src/libtest.c diff --git a/dockerfiles/Dockerfile.snow-chibi-install-test b/dockerfiles/Dockerfile.snow-chibi-install-test index 9926af7..0492b61 100644 --- a/dockerfiles/Dockerfile.snow-chibi-install-test +++ b/dockerfiles/Dockerfile.snow-chibi-install-test @@ -1,4 +1,5 @@ ARG SCHEME=chibi +ARG IMAGE=chibi:head FROM schemers/chibi:head AS build RUN apt-get update && apt-get install -y \ ca-certificates \ @@ -11,7 +12,8 @@ RUN git clone https://gitea.scheme.org/Retropikzel/compile-r7rs.git --depth=1 RUN cd compile-r7rs --branch=retropikzel-dependency-fixes && make ARG SCHEME=chibi -FROM schemers/${SCHEME}:head +ARG IMAGE=chibi:head +FROM schemers/${IMAGE} RUN apt-get update && apt-get install -y \ build-essential \ git \ diff --git a/dockerfiles/Dockerfile.test b/dockerfiles/Dockerfile.test index 12ca3ee..a273cf6 100644 --- a/dockerfiles/Dockerfile.test +++ b/dockerfiles/Dockerfile.test @@ -1,4 +1,5 @@ ARG SCHEME=chibi +ARG IMAGE=chibi:head FROM schemers/chibi:head AS build RUN apt-get update && apt-get install -y \ ca-certificates \ @@ -11,7 +12,8 @@ RUN git clone https://gitea.scheme.org/Retropikzel/compile-r7rs.git --depth=1 RUN cd compile-r7rs && make ARG SCHEME=chibi -FROM schemers/${SCHEME}:head +ARG IMAGE=chibi:head +FROM schemers/${IMAGE} RUN apt-get update && apt-get install -y \ build-essential \ git \ diff --git a/tests/primitives.scm b/tests/primitives.scm index b4bc51c..9b258c1 100644 --- a/tests/primitives.scm +++ b/tests/primitives.scm @@ -1,5 +1,6 @@ (import (scheme base) (scheme write) + (scheme read) (scheme char) (scheme file) (scheme process-context) @@ -324,6 +325,8 @@ (string->c-utf8 "cat2"))) "con2cat2") #t) +(when (file-exists? "testfile.test") + (delete-file "testfile.test")) (define-c-procedure c-fopen libc 'fopen 'pointer '(pointer pointer)) (define output-file (c-fopen (string->c-utf8 "testfile.test") (string->c-utf8 "w"))) @@ -338,8 +341,8 @@ (debug closed-status) (assert equal? (= closed-status 0) #t) (assert equal? (file-exists? "testfile.test") #t) -(assert equal? (string=? (with-input-from-file "testfile.test" - (lambda () (read-line))) - "Hello world 1") #t) +(define file-content (with-input-from-file "testfile.test" + (lambda () (read-line)))) +(assert equal? (string=? file-content "Hello world 1") #t) -(exit 0) +(exit)