Improving tests

This commit is contained in:
retropikzel 2026-03-14 09:12:24 +02:00
parent 71d611c2a5
commit 366444e1e0
4 changed files with 61 additions and 101 deletions

View File

@ -1,2 +1,2 @@
FROM debian:trixie-slim
RUN apt-get update && apt-get install -y make docker.io
FROM alpine
RUN apk add make docker

View File

@ -1,44 +1,26 @@
ARG SCHEME=chibi
ARG IMAGE=chibi:head
FROM docker.io/debian:trixie AS build
RUN apt-get update && apt-get install -y build-essential git ca-certificates curl xz-utils chicken-bin
RUN chicken-install r7rs
WORKDIR /build
RUN git clone https://github.com/ashinn/chibi-scheme.git --depth=1
RUN curl -O https://gitlab.com/-/project/6808260/uploads/094ce726ce3c6cf8c14560f1e31aaea0/akku-1.1.0.amd64-linux.tar.xz
RUN tar -xf akku*.tar.xz && mv akku-1.1.0.amd64-linux akku
RUN git clone https://codeberg.org/retropikzel/scheme-venv.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 mkdir -p /root/.snow && echo "()" > /root/.snow/config.scm
RUN snow-chibi install --impls=chicken --always-yes retropikzel.system
RUN snow-chibi install --impls=chicken --always-yes srfi.170
RUN make build-chicken
FROM docker.io/schemers/${SCHEME}
ARG SCHEME=chibi
FROM docker.io/schemers/${IMAGE}
ENV COMPILE_R7RS=${SCHEME}
COPY --from=build /build /build
RUN apt-get update && apt-get install -y make curl libcurl4-openssl-dev emscripten
WORKDIR /build/chibi-scheme
RUN make install
WORKDIR /build/akku
RUN bash install.sh
RUN ln -sf /root/.local/bin/akku /usr/local/bin/akku
WORKDIR /build/scheme-venv
RUN make install
WORKDIR /build/compile-scheme
RUN make install
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/* /usr/local/
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
RUN snow-chibi install --impls=${SCHEME} --skip-tests?=1 --always-yes srfi.64
RUN snow-chibi install --impls=${SCHEME} --skip-tests?=1 --always-yes retropikzel.ctrf
WORKDIR /workdir
ARG SCHEME=chibi
ENV COMPILE_R7RS=${SCHEME}

View File

@ -3,20 +3,14 @@ RNRS=r7rs
LIBRARY=ctrf
VENV=venv-${SCHEME}-${RNRS}-${LIBRARY}
AUTHOR=retropikzel
PKG=${AUTHOR}-${LIBRARY}-${VERSION}.tgz
LIBRARY_FILE=retropikzel/${LIBRARY}.sld
VERSION=$(shell cat retropikzel/${LIBRARY}/VERSION)
DESCRIPTION=$(shell head -n1 retropikzel/${LIBRARY}/README.md)
README=retropikzel/${LIBRARY}/README.html
TESTFILE=retropikzel/${LIBRARY}/test.scm
PKG=${AUTHOR}-${LIBRARY}-${VERSION}.tgz
MOUTHPKG=${AUTHOR}-mouth-$(shell cat retropikzel/mouth/VERSION).tgz
DOCKERIMG=${SCHEME}:head
ifeq "${SCHEME}" "chicken"
DOCKERIMG="chicken:5"
endif
TEST_DEPENDS=srfi.64 retropikzel.mouth retropikzel.ctrf
all: build
@ -24,65 +18,46 @@ build: retropikzel/${LIBRARY}/LICENSE retropikzel/${LIBRARY}/VERSION retropikzel
echo "<pre>$$(cat retropikzel/${LIBRARY}/README.md)</pre>" > ${README}
snow-chibi package --version=${VERSION} --authors=${AUTHOR} --doc=${README} --description="${DESCRIPTION}" ${LIBRARY_FILE}
install:
snow-chibi install --impls=${SCHEME} ${SNOW_CHIBI_ARGS} ${PKG}
index:
snow-chibi index ${PKG}
install: index
snow-chibi install --impls=${SCHEME} --always-yes retropikzel.${LIBRARY}
uninstall:
-snow-chibi remove --impls=${SCHEME} ${PKG}
snow-chibi remove --impls=${SCHEME} retropikzel.${LIBRARY}
logs:
test: logs build index
mkdir -p logs
# tmpdir
mkdir -p .tmp
# r6rs testfiles
printf "#!r6rs\n(import (rnrs) (srfi :64) (srfi :98) (retropikzel mouth) (retropikzel ctrf) (retropikzel ${LIBRARY}))" > .tmp/test.sps
echo "(test-runner-current (ctrf-runner))" >> .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) (retropikzel mouth) (srfi 64) (retropikzel ctrf) (retropikzel ${LIBRARY}))" > .tmp/test.scm
echo "(test-runner-current (ctrf-runner))" >> .tmp/test.scm
cat ${TESTFILE} >> .tmp/test.scm
# r6rs
if [ "${RNRS}" = "r6rs" ]; then \
cd .tmp \
&& snow-chibi install --impls=${SCHEME} --skip-tests?=1 --always-yes --install-source-dir=. --install-library-dir=. ${TEST_DEPENDS} retropikzel.${LIBRARY} \
&& akku install akku-r7rs 2> /dev/null \
&& COMPILE_R7RS=${SCHEME} compile-r7rs -I .akku/lib -o test test.sps; \
fi
# r7rs
if [ "${RNRS}" = "r7rs" ]; then \
cd .tmp \
&& snow-chibi install --impls=${SCHEME} retropikzel.${LIBRARY} \
&& COMPILE_R7RS=${SCHEME} CSC_OPTIONS="-L -lcurl" compile-r7rs -o test test.scm; \
fi
cd .tmp && ./test
mv .tmp/*.json logs/ || true
snow:
snow-chibi install --impls=generic --skip-tests?=1 --always-yes --install-source-dir=snow --install-library-dir=snow retropikzel.ctrf || true
snow-chibi install --impls=generic --skip-tests?=1 --always-yes --install-source-dir=snow --install-library-dir=snow srfi.64 || true
${VENV}:
scheme-venv ${SCHEME} ${VENV}
if [ "${RNRS}" = "r7rs" ]; then ${VENV}/bin/snow-chibi install --always-yes srfi.64; fi
if [ "${RNRS}" = "r7rs" ]; then ${VENV}/bin/snow-chibi install --always-yes retropikzel.mouth; fi
if [ "${RNRS}" = "r7rs" ]; then ${VENV}/bin/snow-chibi install --always-yes retropikzel.ctrf; fi
if [ "${SCHEME}-${RNRS}" = "mosh-r7rs" ]; then ${VENV}/bin/snow-chibi install --always-yes srfi.64; 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
run-test-venv: ${VENV} logs build
echo "(import (scheme base) (scheme write) (scheme read) (scheme char) (scheme file) (scheme process-context) (retropikzel mouth) (srfi 64) (retropikzel ctrf) (retropikzel ${LIBRARY}))" > ${VENV}/test.scm
echo "(test-runner-current (ctrf-runner))" >> ${VENV}/test.scm
printf "#!r6rs\n(import (rnrs) (srfi :64) (srfi :98) (retropikzel mouth) (retropikzel ${LIBRARY}))" > ${VENV}/test.sps
cat ${TESTFILE} >> ${VENV}/test.scm
cat ${TESTFILE} >> ${VENV}/test.sps
if [ "${RNRS}" = "r6rs" ]; then cp -r retropikzel ${VENV}/lib/; fi
if [ "${RNRS}" = "r6rs" ]; then ${VENV}/bin/akku install; 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" ${VENV}/bin/scheme-compile ${VENV}/test.scm; fi
cd ${VENV} && ./test
mv ${VENV}/*.json logs/ || true
run-test-system: logs snow build
printf "#!r6rs\n(import (rnrs) (srfi :64) (srfi :98) (retropikzel mouth) (retropikzel ctrf) (retropikzel ${LIBRARY}))" > run-test.sps
echo "(test-runner-current (ctrf-runner))" >> run-test.sps
cat ${TESTFILE} >> run-test.sps
echo "(import (scheme base) (scheme write) (scheme read) (scheme char) (scheme file) (scheme process-context) (retropikzel mouth) (srfi 64) (retropikzel ctrf) (retropikzel ${LIBRARY}))" > run-test.scm
echo "(test-runner-current (ctrf-runner))" >> run-test.scm
cat ${TESTFILE} >> run-test.scm
if [ "${RNRS}" = "r6rs" ]; then akku install akku-r7rs; fi
if [ "${RNRS}" = "r7rs" ]; then snow-chibi install --impls=${SCHEME} --always-yes srfi.64; fi
if [ "${RNRS}" = "r7rs" ]; then snow-chibi install --impls=${SCHEME} --always-yes retropikzel.mouth; fi
if [ "${RNRS}" = "r7rs" ]; then snow-chibi install --impls=${SCHEME} --always-yes retropikzel.ctrf; fi
if [ "${RNRS}" = "r7rs" ]; then snow-chibi install --impls=${SCHEME} ${PKG}; fi
rm -rf run-test
if [ "${RNRS}" = "r6rs" ]; then COMPILE_R7RS=${SCHEME} compile-scheme -I .akku/lib run-test.sps; fi
if [ "${RNRS}" = "r7rs" ]; then COMPILE_R7RS=${SCHEME} CSC_OPTIONS="-L -lcurl" compile-scheme run-test.scm; fi
./run-test
mv *.json logs/ || true
run-test-docker:
docker build --build-arg IMAGE=${DOCKERIMG} -f Dockerfile.test --tag=scheme-libraries-${SCHEME} .
docker run -v "${PWD}/logs:/workdir/logs" -w /workdir scheme-libraries-${SCHEME} sh -c "make SCHEME=${SCHEME} RNRS=${RNRS} LIBRARY=${LIBRARY} run-test-system"
test-docker:
docker build --build-arg IMAGE=${IMAGE} --build-arg SCHEME=${SCHEME} -f Dockerfile.test --tag=${SCHEME}-testing .
docker run -v "${PWD}/logs:/workdir/logs" -w /workdir ${SCHEME}-testing sh -c "make SCHEME=${SCHEME} RNRS=${RNRS} LIBRARY=${LIBRARY} test"
retropikzel/wasm/plus.wasm: retropikzel/wasm/plus.c
emcc -o retropikzel/wasm/plus.js retropikzel/wasm/plus.c

View File

@ -4,5 +4,8 @@
(scheme write)
(scheme file))
(export slurp
spit)
spit
;slurb ; TODO Read whole file as bytevector
;sbit ; TODO Write bytevector into file
)
(include "mouth.scm"))