Improve testing

This commit is contained in:
retropikzel 2026-03-21 13:17:14 +02:00
parent 8492575a65
commit 4501ccac4b
3 changed files with 54 additions and 125 deletions

View File

@ -1,41 +1,29 @@
ARG SCHEME=chibi
ARG IMAGE=${SCHEME}:head
FROM debian:trixie AS build
RUN apt-get update && apt-get install -y \
git ca-certificates make gcc libffi-dev libffi-dev wget xz-utils libcurl4
RUN mkdir ${HOME}/.snow && echo "()" > ${HOME}/.snow/config.scm
WORKDIR /build
RUN wget https://gitlab.com/-/project/6808260/uploads/094ce726ce3c6cf8c14560f1e31aaea0/akku-1.1.0.amd64-linux.tar.xz \
&& tar -xf akku-1.1.0.amd64-linux.tar.xz \
&& mv akku-1.1.0.amd64-linux akku
RUN git clone https://github.com/ashinn/chibi-scheme.git --depth=1
RUN git clone https://codeberg.org/retropikzel/compile-scheme.git --depth=1
WORKDIR /build/chibi-scheme
RUN make
RUN make install
WORKDIR /build/compile-scheme
RUN make build-gauche
ARG IMAGE=chibi:latest
FROM docker.io/schemers/${IMAGE}
ARG SCHEME=chibi
ENV COMPILE_R7RS=${SCHEME}
RUN apt-get update && apt-get install -y \
build-essential libffi-dev libcurl4-openssl-dev curl guile-3.0 \
git ca-certificates
COPY --from=schemers/loko:head /usr/local /usr/loko
RUN cp -r /usr/loko/* /usr/local/
COPY --from=schemers/chibi:head /usr/local /usr/chibi
RUN cp -r /usr/chibi/lib/* /usr/local/lib/
RUN cp -r /usr/chibi/share/* /usr/local/share/
RUN cp -r /usr/chibi/bin/*chibi* /usr/local/bin/
RUN ldconfig
ADD https://codeberg.org/retropikzel/compile-r7rs/raw/branch/main/compile-r7rs .
RUN install compile-r7rs /usr/local/bin/compile-r7rs
RUN mkdir -p /root/.snow && echo "()" > /root/.snow/config.scm
ARG SCHEME=chibi
ARG IMAGE=${SCHEME}:head
FROM schemers/${IMAGE}
RUN apt-get update && apt-get install -y make gcc libffi-dev libcurl4 gauche
RUN mkdir ${HOME}/.snow && echo "()" > ${HOME}/.snow/config.scm
COPY --from=build /build /build
ARG SCHEME=chibi
WORKDIR /build/compile-scheme
RUN make install
WORKDIR /build/chibi-scheme
RUN make install
WORKDIR /build/chibi-scheme
RUN make install
WORKDIR /build/akku
RUN bash install.sh
ENV PATH=/root/.local/bin:${PATH}
RUN akku update
RUN timeout 30 snow-chibi install --impls=${SCHEME} --always-yes "(srfi 64)" || true
RUN timeout 30 snow-chibi install --impls=${SCHEME} --always-yes "(foreign c)" || true
WORKDIR /workdir
ARG SCHEME=chibi
ENV COMPILE_R7RS=${SCHEME}
COPY Makefile .
COPY retropikzel retropikzel/

116
Makefile
View File

@ -1,4 +1,6 @@
SCHEME=chibi
DOCKER_TAG=latest
IMAGE=${SCHEME}:${DOCKER_TAG}
RNRS=r7rs
LIBRARY=system
EXAMPLE=editor
@ -13,102 +15,44 @@ TESTFILE=retropikzel/${LIBRARY}/test.scm
PKG=retropikzel-${LIBRARY}-${VERSION}.tgz
DOCKERIMG=${SCHEME}:head
ifeq "${SCHEME}" "chicken"
DOCKERIMG="chicken:5"
SFX=scm
SNOW=snow-chibi --impls=${SCHEME} install --always-yes
LIB_PATHS=
ifeq "${RNRS}" "r6rs"
SNOW=snow-chibi --impls=${SCHEME} install --always-yes --install-source-dir=. --install-library-dir=.
SFX=sps
LIB_PATHS=-I .akku/lib
endif
all: build
build: retropikzel/${LIBRARY}/LICENSE retropikzel/${LIBRARY}/VERSION
echo "<pre>$$(cat retropikzel/${LIBRARY}/README.md)</pre>" > ${README}
snow-chibi package --version=${VERSION} --authors=${AUTHOR} --doc=${README} --description="${DESCRIPTION}" ${LIBRARY_FILE}
snow-chibi package --always-yes --version=${VERSION} --authors=${AUTHOR} --doc=${README} --description="${DESCRIPTION}" ${LIBRARY_FILE}
install:
snow-chibi install --impls=${SCHEME} ${SNOW_CHIBI_ARGS} ${PKG}
snow-chibi install --impls=${SCHEME} --always-yes ${PKG}
uninstall:
-snow-chibi remove --impls=${SCHEME} ${PKG}
test: build
rm -rf .tmp
mkdir -p .tmp
# R6RS testfiles
printf "#!r6rs\n(import (except (rnrs) remove) (srfi :64) (retropikzel ${LIBRARY}))" > .tmp/test.sps
cat ${TESTFILE} >> .tmp/test.sps
# R7RS testfiles
echo "(import (scheme base) (scheme write) (scheme read) (scheme char) (scheme file) (scheme process-context) (srfi 64) (retropikzel ${LIBRARY}))" > .tmp/test.scm
cat ${TESTFILE} >> .tmp/test.scm
# Tests
cd .tmp && ${SNOW} srfi.64
cd .tmp && ${SNOW} retropikzel.ctrf
cd .tmp && ${SNOW} ../${PKG}
cd .tmp && akku install akku-r7rs 2> /dev/null
cd .tmp && CSC_OPTIONS="-L -lcurl -L -lSDL2 -L -lSDL2_image" COMPILE_R7RS=${SCHEME} compile-r7rs ${LIB_PATHS} -o test test.${SFX}
cd .tmp && ./test
run-test-venv: build
rm -rf venv
scheme-venv ${SCHEME} venv
echo "(import (scheme base) (scheme write) (scheme read) (scheme char) (scheme file) (scheme process-context) (srfi 64) (retropikzel ${LIBRARY}))" > venv/test.scm
printf "#!r6rs\n(import (except (rnrs) remove) (srfi :64) (retropikzel ${LIBRARY}))" > venv/test.sps
cat ${TESTFILE} >> venv/test.scm
cat ${TESTFILE} >> venv/test.sps
if [ "${RNRS}" = "r6rs" ]; then if [ -d ../foreign-c ]; then cp -r ../foreign-c/foreign venv/lib/; fi; fi
if [ "${RNRS}" = "r6rs" ]; then cp -r retropikzel venv/lib/; fi
#if [ "${SCHEME}" = "chezscheme" ]; then ./venv/bin/akku install akku-r7rs chez-srfi; fi
#if [ "${SCHEME}" = "ikarus" ]; then ./venv/bin/akku install akku-r7rs chez-srfi; fi
#if [ "${SCHEME}" = "ironscheme" ]; then ./venv/bin/akku install akku-r7rs chez-srfi; fi
#if [ "${SCHEME}" = "racket" ]; then ./venv/bin/akku install akku-r7rs chez-srfi; fi
if [ "${RNRS}" = "r6rs" ]; then ./venv/bin/akku install akku-r7rs chez-srfi; fi
if [ "${SCHEME}" = "chicken" ]; then ./venv/bin/snow-chibi install --always-yes srfi.64; fi
if [ "${SCHEME}-${RNRS}" = "mosh-r7rs" ]; then ./venv/bin/snow-chibi install --always-yes srfi.64; fi
if [ "${RNRS}" = "r7rs" ]; then ./venv/bin/snow-chibi install ${PKG}; fi
if [ "${RNRS}" = "r6rs" ]; then ./venv/bin/scheme-compile venv/test.sps; fi
if [ "${RNRS}" = "r7rs" ]; then CSC_OPTIONS="-L -lcurl -L -lSDL2 -L -lSDL2_image" ./venv/bin/scheme-compile venv/test.scm; fi
./venv/test
run-test-system: build
rm -rf tmp
mkdir -p tmp
printf "#!r6rs\n(import (except (rnrs) remove) (srfi :64) (retropikzel ${LIBRARY}))" > tmp/test.sps
cat ${TESTFILE} >> tmp/test.sps
echo "(import (scheme base) (scheme write) (scheme read) (scheme char) (scheme file) (scheme process-context) (srfi 64) (retropikzel ${LIBRARY}))" > tmp/test.scm
cat ${TESTFILE} >> tmp/test.scm
if [ "${RNRS}" = "r6rs" ]; then cp -r retropikzel tmp/lib/; fi
if [ "${RNRS}" = "r6rs" ]; then snow-chibi install --impls=generic --install-source-dir=tmp/lib --install-library-dir=tmp/lib --always-yes foreign.c; fi
if [ "${RNRS}" = "r6rs" ]; then cd tmp && akku install akku-r7rs chez-srfi; fi
if [ "${RNRS}" = "r7rs" ]; then snow-chibi install --impls=${SCHEME} --always-yes --skip-tests?=1 srfi.64; fi
if [ "${RNRS}" = "r7rs" ]; then snow-chibi install --impls=${SCHEME} --always-yes --skip-tests?=1 foreign.c; fi
if [ "${RNRS}" = "r7rs" ]; then snow-chibi install --impls=${SCHEME} --always-yes ${PKG}; fi
if [ "${RNRS}" = "r6rs" ]; then cd tmp && COMPILE_R7RS=${SCHEME} compile-scheme -o test test.sps; fi
if [ "${RNRS}" = "r7rs" ]; then cd tmp && CSC_OPTIONS="-L -lcurl -L -lSDL2 -L -lSDL2_image" COMPILE_R7RS=${SCHEME} compile-scheme -o test test.scm; fi
cd tmp && ./test
run-test-docker:
docker build --build-arg IMAGE=${DOCKERIMG} --build-arg SCHEME=${SCHEME} --tag=foreign-c-library-test-${SCHEME} -f Dockerfile.test .
docker run -v "${PWD}/logs:/workdir/logs" -w /workdir -t foreign-c-library-test-${SCHEME} sh -c "make SCHEME=${SCHEME} LIBRARY=${LIBRARY} RNRS=${RNRS} run-test-system"
test-r7rs:
echo "(import (scheme base) (scheme write) (scheme file) (scheme process-context) (foreign c) (retropikzel ${LIBRARY}) (srfi 64))" > test-r7rs.scm
cat retropikzel/${LIBRARY}/test.scm >> test-r7rs.scm
COMPILE_R7RS=${SCHEME} timeout 60 compile-scheme -I . -o test-r7rs test-r7rs.scm
printf "\n" | timeout 60 ./test-r7rs
test-r7rs-docker:
echo "Building docker image..."
docker build --build-arg IMAGE=${DOCKERIMG} --build-arg SCHEME=${SCHEME} --tag=foreign-c-library-test-${SCHEME} --quiet .
docker run -t foreign-c-library-test-${SCHEME} sh -c "make SCHEME=${SCHEME} LIBRARY=${LIBRARY} SNOW_CHIBI_ARGS=--always-yes build install test-r7rs"
example.scm: ${EXAMPLE_FILE}.scm
cp ${EXAMPLE_FILE}.scm example.scm
example-r7rs: example.scm
COMPILE_R7RS=${SCHEME} compile-scheme -I . -o example example.scm
./example
test-r6rs:
echo "(import (except (rnrs) remove) (foreign c) (retropikzel ${LIBRARY}) (srfi :64))" > test-r6rs.sps
cat retropikzel/${LIBRARY}/test.scm >> test-r6rs.sps
akku install chez-srfi akku-r7rs
COMPILE_R7RS=${SCHEME} timeout 60 compile-scheme -I .akku/lib -o test-r6rs test-r6rs.sps
timeout 60 ./test-r6rs
test-r6rs-docker:
echo "Building docker image..."
docker build --build-arg IMAGE=${DOCKERIMG} --build-arg SCHEME=${SCHEME} --tag=foreign-c-library-test-${SCHEME} --quiet .
docker run -t foreign-c-library-test-${SCHEME} sh -c "make SCHEME=${SCHEME} LIBRARY=${LIBRARY} test-r6rs"
example.sps: ${EXAMPLE_FILE}.sps
cp ${EXAMPLE_FILE}.scm example.sps
example-r6rs: example.sps
akku install akku-r7rs "(foreign c)"
COMPILE_R7RS=${SCHEME} compile-scheme -I .akku/lib -o example example.sps
./example
test-docker:
docker build --build-arg SCHEME=${SCHEME} --build-arg IMAGE=${IMAGE} --tag=foreign-c-library-test-${SCHEME} -f Dockerfile.test .
docker run -v "${PWD}/logs:/workdir/logs" -w /workdir -t foreign-c-library-test-${SCHEME} sh -c "make SCHEME=${SCHEME} LIBRARY=${LIBRARY} RNRS=${RNRS} test"
clean:
git clean -X -f

View File

@ -1,7 +1,4 @@
(define-c-library libc
'("stdlib.h")
libc-name
'((additional-versions ("6"))))
(define-c-library libc '("stdlib.h") #f '())
(define-c-library c-gi
'("girepository/girepository.h")
"girepository-2.0"