Move scheme runner code here as it's the only repo that needs it

This commit is contained in:
retropikzel 2024-09-05 11:27:07 +03:00
parent 22e30570d0
commit 24eacb64e2
4 changed files with 90 additions and 38 deletions

34
Dockerfile Normal file
View File

@ -0,0 +1,34 @@
ARG IMPLEMENTATION
FROM schemers/$IMPLEMENTATION
ARG IMPLEMENTATION
RUN echo "deb http://ftp.fi.debian.org/debian/ bookworm main" > /etc/apt/sources.list
WORKDIR /workdir
RUN echo 'this system will not be supported in the future' > /etc/unsupported-skip-usrmerge-conversion
#RUN echo debconf usrmerge/autoconvert select true | debconf-set-selections && apt-get update && apt-get -y install usrmerge
RUN sed -i 's/bullseye/bookworm/g' /etc/apt/sources.list
RUN apt update && apt full-upgrade -y && apt install -y make git curl wget zip unzip bash && apt clean
RUN apt full-upgrade -y
RUN cat /etc/issue
RUN if [ "$IMPLEMENTATION" = "kawa" ] ; then \
apt remove -y openjdk* --purge && apt autoremove -y && apt clean; \
curl -s "https://get.sdkman.io" | bash; \
bash -c "source ${HOME}/.sdkman/bin/sdkman-init.sh && sdk install java 22.0.2-tem"; \
cp -r ${HOME}/.sdkman/candidates/java/22.0.2-tem/bin/* /usr/local/bin; \
cp -r ${HOME}/.sdkman/candidates/java/22.0.2-tem/lib/* /usr/local/lib; \
sed -i 's/--no-console//' /usr/local/bin/kawa; \
fi
RUN if [ ! "$IMPLEMENTATION" = "guile" ] ; then apt install -y guile-3.0; fi
RUN git clone https://git.sr.ht/~retropikzel/schubert --depth=1 --branch=v0-16-3 && cd schubert && make && make install
RUN if [ "$IMPLEMENTATION" = "chicken" ] ; then chicken-install r7rs; fi
RUN if [ "$IMPLEMENTATION" = "racket" ] ; then raco pkg install --auto r7rs || true; fi
ARG WINE
RUN if [ "$WINE" = "true" ] ; then \
dpkg --add-architecture i386; \
mkdir -pm755 /etc/apt/keyrings; \
wget -O /etc/apt/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key; \
wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/debian/dists/bookworm/winehq-bookworm.sources; \
apt update; \
apt install -y wine-binfmt --install-recommends winehq-stable; \
fi
ARG PACKAGES=curl
RUN apt update && apt install -y $PACKAGES

View File

@ -1,5 +1,5 @@
TEST_PACKAGES_APT="libcurl4-openssl-dev libuv1"
SCHEME_RUNNER=PACKAGES=${TEST_PACKAGES_APT} scheme_runner
SCHEME_RUNNER=PACKAGES=${TEST_PACKAGES_APT} ./scheme_runner
TESTFILES=$(shell ls tests/*.scm)
SRFI_BUNDLE_VERSION=v0-1-0

30
scheme_runner Executable file
View File

@ -0,0 +1,30 @@
#!/bin/bash
set -e
DOCKERFILE=Dockerfile
if test "${1}" = "" -o "${2}" = "";
then
echo "Example: "
echo "scheme_runner debian guile \"make test\""
exit
else
implementation="${1}"
cmd="${2}"
tag="scheme-runner-${implementation}"
if [ "${WINE}" = "true" ];
then
tag=${tag}-wine
fi
echo "Running command: ${cmd}, with implementation: ${implementation}"
docker build \
--build-arg IMPLEMENTATION=${implementation} \
--build-arg PACKAGES="${PACKAGES}" \
--build-arg WINE="${WINE}" \
-f ${DOCKERFILE} \
--tag ${tag}:latest \
--quiet \
.
docker run -it -v ${PWD}:/workdir:z ${tag}:latest ${cmd}
fi

View File

@ -4,30 +4,20 @@
(scheme process-context)
(retropikzel r7rs-pffi version main))
(define exit-on-fail? #t)
(define tag 'none)
(define-syntax assert
(syntax-rules ()
((_ check value)
(let ((result (apply check (list value))))
((_ check value-a value-b)
(let ((result (apply check (list value-a value-b))))
(if (not result) (display "FAIL: ") (display "PASS: "))
(display "[")
(display tag)
(display "] ")
(write (list 'check 'value))
(write (list 'check 'value-a 'value-b))
(newline)
(when (and exit-on-fail? (not result)) (exit 1))
))))
(when (not result) (exit 1))))))
;; pffi-init
(set! tag 'pffi-init)
(pffi-init)
;; pffi-shared-object-auto-load
(set! tag 'pffi-shared-object-auto-load-libc)
(define libc-stdlib
(if (string=? pffi-os-name "windows")
@ -35,32 +25,30 @@
(pffi-shared-object-auto-load (list "stdlib.h") (list) "c" (list "" ".6"))))
;; pffi-define
(set! tag 'pffi-define-atoi)
(pffi-define atoi libc-stdlib 'atoi 'int (list 'pointer))
(assert number? (atoi (pffi-string->pointer "100")))
(assert = (atoi (pffi-string->pointer "100")) 100)
;; Size of
(set! tag 'size-of)
(assert number? (pffi-size-of 'int8))
(assert number? (pffi-size-of 'uint8))
(assert number? (pffi-size-of 'int16))
(assert number? (pffi-size-of 'uint16))
(assert number? (pffi-size-of 'int32))
(assert number? (pffi-size-of 'uint32))
(assert number? (pffi-size-of 'int64))
(assert number? (pffi-size-of 'uint64))
(assert number? (pffi-size-of 'char))
(assert number? (pffi-size-of 'unsigned-char))
(assert number? (pffi-size-of 'short))
(assert number? (pffi-size-of 'unsigned-short))
(assert number? (pffi-size-of 'int))
(assert number? (pffi-size-of 'unsigned-int))
(assert number? (pffi-size-of 'long))
(assert number? (pffi-size-of 'unsigned-long))
(assert number? (pffi-size-of 'float))
(assert number? (pffi-size-of 'double))
(assert number? (pffi-size-of 'string))
(assert number? (pffi-size-of 'pointer))
(assert equal? (number? (pffi-size-of 'int8)) #t)
(assert equal? (number? (pffi-size-of 'uint8)) #t)
(assert equal? (number? (pffi-size-of 'int16)) #t)
(assert equal? (number? (pffi-size-of 'uint16)) #t)
(assert equal? (number? (pffi-size-of 'int32)) #t)
(assert equal? (number? (pffi-size-of 'uint32)) #t)
(assert equal? (number? (pffi-size-of 'int64)) #t)
(assert equal? (number? (pffi-size-of 'uint64)) #t)
(assert equal? (number? (pffi-size-of 'char)) #t)
(assert equal? (number? (pffi-size-of 'unsigned-char)) #t)
(assert equal? (number? (pffi-size-of 'short)) #t)
(assert equal? (number? (pffi-size-of 'unsigned-short)) #t)
(assert equal? (number? (pffi-size-of 'int)) #t)
(assert equal? (number? (pffi-size-of 'unsigned-int)) #t)
(assert equal? (number? (pffi-size-of 'long)) #t)
(assert equal? (number? (pffi-size-of 'unsigned-long)) #t)
(assert equal? (number? (pffi-size-of 'float)) #t)
(assert equal? (number? (pffi-size-of 'double)) #t)
(assert equal? (number? (pffi-size-of 'string)) #t)
(assert equal? (number? (pffi-size-of 'pointer)) #t)
(exit 0)