3
0
Fork 0
forked from mirrors/nixpkgs

tinyscheme: add some tests

This commit is contained in:
Rahul Butani 2022-07-18 16:44:50 -05:00
parent 8f0ec82696
commit 4c958b1200
No known key found for this signature in database
GPG key ID: 1C7CE491479FA273

View file

@ -1,4 +1,10 @@
{ lib, stdenv, fetchurl, dos2unix }:
{ lib
, stdenv
, fetchurl
, dos2unix
, runCommand
, tinyscheme
}:
stdenv.mkDerivation rec {
pname = "tinyscheme";
@ -38,6 +44,28 @@ stdenv.mkDerivation rec {
cp scheme $out/bin/tinyscheme
'';
passthru.tests = {
# Checks that the program can run and exit:
simple = runCommand "${pname}-simple-test" {} ''
${tinyscheme}/bin/tinyscheme <<<"(quit 0)"
echo "success" > $out
'';
fileIo = runCommand "${pname}-file-io-test" {} ''
${tinyscheme}/bin/tinyscheme <<EOF
(call-with-output-file "$out"
(lambda (p)
(begin
(write "success!" p)
(newline p)
)))
EOF
'';
helpText = runCommand "${pname}-help-text-test" {} ''
${tinyscheme}/bin/tinyscheme '-?' | tee > $out || :
[[ "$(cat $out)" =~ ^Usage: ]]
'';
};
meta = with lib; {
description = "Lightweight Scheme implementation";
longDescription = ''