Add testing

This commit is contained in:
retropikzel 2026-01-25 09:43:44 +02:00
parent d82742183e
commit 9aa370c7f7
6 changed files with 156 additions and 14 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
testvenv

29
Dockerfile.test Normal file
View File

@ -0,0 +1,29 @@
ARG SCHEME=chibi
FROM docker.io/debian:trixie AS build
RUN apt-get update && apt-get install -y \
build-essential chezscheme git ca-certificates wget
WORKDIR /build
RUN git clone https://github.com/ashinn/chibi-scheme.git --depth=1
WORKDIR /build/chibi-scheme
RUN make PREFIX=/root/.local
RUN make PREFIX=/root/.local install
WORKDIR /build
RUN wget https://gitlab.com/-/project/6808260/uploads/9d23bb6ec47dd2d7ee41802115cd7d80/akku-1.1.0.src.tar.xz && tar -xf akku-1.1.0.src.tar.xz
WORKDIR /build/akku-1.1.0.src
RUN ./install.sh
WORKDIR /build
RUN wget https://ftp.gnu.org/gnu/make/make-4.4.tar.gz && tar -xf make-4.4.tar.gz
WORKDIR /build/make-4.4
RUN ./configure --prefix=/root/.local
RUN make
run make install
ARG SCHEME=chibi
FROM docker.io/schemers/${SCHEME}:head
COPY --from=build /root/.local /root/.local
ENV PATH=/root/.local/bin:${PATH}
WORKDIR /workdir
COPY Makefile Makefile
COPY test.scm test.scm
COPY scheme-venv scheme-venv

61
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,61 @@
pipeline {
agent {
docker {
image 'debian'
label 'docker-x86_64'
args '--user=root --privileged -v /var/run/docker.sock:/var/run/docker.sock'
}
}
options {
disableConcurrentBuilds()
buildDiscarder(logRotator(numToKeepStr: '10', artifactNumToKeepStr: '10'))
}
parameters {
string(name: 'R6RS_SCHEMES', defaultValue: 'chezscheme', description: '')
string(name: 'R7RS_SCHEMES', defaultValue: 'chibi', description: '')
}
stages {
stage('Init') {
steps {
sh "apt-get update && apt-get install -y make docker.io"
sh "make build-docker-test-image"
}
}
stage('Tests') {
parallel {
stage('R6RS') {
steps {
script {
params.R6RS_SCHEMES.split().each { SCHEME ->
stage("${SCHEME}") {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "timeout 60 make SCHEME=${SCHEME} RNRS=r6rs test-docker"
}
}
}
}
}
}
stage('R7RS') {
steps {
script {
params.R7RS_SCHEMES.split().each { SCHEME ->
stage("${SCHEME}") {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "timeout 60 make SCHEME=${SCHEME} RNRS=r7rs test-docker"
}
}
}
}
}
}
}
}
}
}

View File

@ -1,10 +1,21 @@
PREFIX=/usr/local
SCHEME=chibi
RNRS=r7rs
all: build
build:
@echo "No build step, just install"
test:
rm -rf testvenv/ && ./scheme-venv ${SCHEME} ${RNRS} testvenv && ./testvenv/bin/snow-chibi install retropikzel.hello && ./testvenv/bin/scheme-script test.scm
build-docker-test-image:
docker build --build-arg SCHEME=${SCHEME} -f Dockerfile.test --tag=scheme-venv-test .
test-docker: build-docker-test-image
docker run -it -t scheme-venv-test bash -c "make SCHEME=${SCHEME} RNRS=${RNRS} test"
install:
mkdir -p ${PREFIX}/bin
install scheme-venv ${PREFIX}/bin/scheme-venv

61
scheme-venv Normal file → Executable file
View File

@ -1,11 +1,26 @@
#!/bin/sh
# TODO:
# Capyscheme
# Cyclone
# Ikarus
# Ironscheme
# Larceny
# Meevax
# MIT-Scheme
# Mosh
# Sagittarius
# Skint
# Vicare
# Ypsilon
# vi: ft=bash
stringContain() { case $2 in *$1* ) return 0;; *) return 1;; esac ;}
supported_rnrs="r6rs r7rs"
supported_implementations="chezscheme chibi chicken gambit gauche kawa loko"
supported_implementations="chezscheme chibi chicken foment gambit gauche kawa \
loko mit-scheme racket stklos tr7"
## Make sure all arguments are right
if [ "${1}" = "" ]; then
@ -61,13 +76,10 @@ mkdir "${venvpath}"
mkdir "${venvpath}/bin"
mkdir "${venvpath}/lib"
## Set scheme type
## Set scheme type if other than interpreter
case "${implementation}" in
"chezscheme") scheme_type=interpreter ;;
"chibi") scheme_type=interpreter ;;
"chicken") scheme_type=compiler ;;
"gambit") scheme_type=compiler ;;
"gauche") scheme_type=interpreter;;
esac
## bin/snow-chibi
@ -82,6 +94,7 @@ if [ "\${1}" = "install" ]; then
--install-source-dir=${venvpath}/lib \
--install-library-dir=${venvpath}/lib \
--install-data-dir=${venvpath}/lib \
--install-binary-dir=${venvpath}/bin \
"\$@"
else
snow-chibi "\$@"
@ -162,15 +175,18 @@ if [ "${rnrs}" = "r6rs" ]; then
"chezscheme")
if command -v chezscheme >/dev/null 2>&1
then
scheme_cmd="chezscheme --libdirs ${venvpath}/lib/.akku/lib --program \"\${1}\""
scheme_cmd="chezscheme --libdirs ${venvpath}/lib/.akku/lib --program \"\${IF}\""
else
scheme_cmd="scheme --libdirs \"${venvpath}/lib/.akku/lib\" --program \"\${1}\""
scheme_cmd="scheme --libdirs \"${venvpath}/lib/.akku/lib\" --program \"\${IF}\""
fi
;;
"loko")
scheme_cmd="LOKO_LIBRARY_PATH=\"${venvpath}/lib\" loko -std=r6rs --program \"\${1}\""
scheme_cmd="LOKO_LIBRARY_PATH=\"${venvpath}/lib\" loko -std=r6rs --program \"\${IF}\""
scheme_compile_cmd="LOKO_LIBRARY_PATH=\"${venvpath}/lib\" loko -std=r6rs -o \"\${OF}\" --compile \"\${IF}\""
;;
"racket")
scheme_cmd="racket -I scheme/init -l r6rs/run.rkt -S \"${venvpath}/lib\" \"\${IF}\""
;;
*)
>&2 echo "Unsupported implementation RnRS combination: ${implementation} ${rnrs}"
exit 1
@ -181,27 +197,42 @@ else
## R7RS
case "${implementation}" in
"chibi")
scheme_cmd="chibi-scheme -I \"${venvpath}/lib\" \"\${1}\""
scheme_cmd="chibi-scheme -I \"${venvpath}/lib\" \"\${IF}\""
;;
"chicken")
scheme_cmd="echo \"Chicken scripts not yet supported\" && exit 1"
scheme_compile_cmd="csc -static -X r7rs -R r7rs -o \"\${OF}\" \"\${IF}\""
;;
"foment")
scheme_cmd="foment -I \"${venvpath}/lib\" \"\${IF}\""
;;
"gambit")
scheme_cmd="gsi \"${venvpath}/lib/\" \"\${1}\""
scheme_cmd="gsi \"${venvpath}/lib/\" \"\${IF}\""
#scheme_compile_cmd="gsc -o \"\${OF}\" -exe -nopreload \"${venvpath}/lib/\" \"\${IF}\""
scheme_compile_cmd="echo \"Gambit compiler not yet supported\" && exit 1"
;;
"gauche")
scheme_cmd="gosh -r7 -I \"${venvpath}/lib\" \"\${1}\""
scheme_cmd="gosh -r7 -I \"${venvpath}/lib\" \"\${IF}\""
;;
"kawa")
scheme_cmd="kawa --r7rs -Dkawa.import.path=\"${venvpath}/lib/*.sld\" \"\${1}\""
scheme_cmd="kawa --r7rs --full-tailcalls -Dkawa.import.path=\"${venvpath}/lib/*.sld\" \"\${IF}\""
;;
"loko")
scheme_cmd="LOKO_LIBRARY_PATH=\"${venvpath}/lib\" loko -std=r7rs --program \"\${1}\""
scheme_cmd="LOKO_LIBRARY_PATH=\"${venvpath}/lib\" loko -std=r7rs --program \"\${IF}\""
scheme_compile_cmd="LOKO_LIBRARY_PATH=\"${venvpath}/lib\" loko -std=r7rs -o \"\${OF}\" --compile \"\${IF}\""
;;
"mit-scheme")
scheme_cmd="mit-scheme --prepend-library ${venvpath}/lib --batch-mode --load \"\${IF}\" --eval \"(exit 0)\" --args"
;;
"racket")
scheme_cmd="racket -I r7rs -S \"${venvpath}/lib\" --script \"\${IF}\""
;;
"stklos")
scheme_cmd="stklos -I \"${venvpath}/lib\" \"\${IF}\""
;;
"tr7")
scheme_cmd="TR7_LIB_PATH=\"${venvpath}/lib\" tr7i -1 \"\${IF}\""
;;
*)
>&2 echo "Unsupported implementation RnRS combination: ${implementation} ${rnrs}"
exit 1
@ -215,7 +246,9 @@ fi
echo "#!/bin/sh"
echo "if [ \"\${1}\" = \"\" ]; then echo 'scheme-venv (${implementation} ${rnrs}) Give script file as argument' && exit 1; fi"
echo "if [ \"\${1}\" = \"--help\" ]; then echo 'scheme-venv (${implementation} ${rnrs}) Give script file as argument' && exit 1; fi"
echo "${scheme_cmd}"
echo "IF=\"\${1}\""
echo "shift"
echo "${scheme_cmd} \"\$@\""
} > "${venvpath}/bin/scheme-script"
chmod +x "${venvpath}/bin/scheme-script"

7
test.scm Normal file
View File

@ -0,0 +1,7 @@
(import (scheme base)
(scheme write)
(scheme process-context)
(retropikzel hello))
(hello)
(exit)