Skip to content

Commit

Permalink
racket-minimal: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rc-zb committed Dec 17, 2024
1 parent 3b38032 commit 6c5dbbe
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkgs/development/interpreters/racket/minimal.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
ncurses,

disableDocs ? false,

callPackage,
}:

let
Expand Down Expand Up @@ -81,6 +83,13 @@ stdenv.mkDerivation (finalAttrs: {

dontStrip = isDarwin;

passthru = {
tests = builtins.mapAttrs (name: path: callPackage path { racket = finalAttrs.finalPackage; }) {
write-greeting = ./tests/write-greeting.nix;
get-current-launcher-variant = ./tests/get-current-launcher-variant.nix;
};
};

meta = {
description = "Programmable programming language";
longDescription = ''
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{ runCommandLocal, racket }:

runCommandLocal "racket-test-get-current-launcher-variant"
{
nativeBuildInputs = [ racket ];
}
''
expectation="cs"
output="$(racket -e '(require launcher/launcher) (write (current-launcher-variant))')"
if test "$output" != "$expectation"; then
echo "output mismatch: expected ''${expectation}, but got ''${output}"
exit 1
fi
touch $out
''
23 changes: 23 additions & 0 deletions pkgs/development/interpreters/racket/tests/write-greeting.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{ runCommandLocal, racket }:

runCommandLocal "racket-test-write-greeting"
{
nativeBuildInputs = [ racket ];
}
''
expectation="Hello, world!"
racket -f - <<EOF
(with-output-to-file (getenv "out")
(lambda ()
(display "Hello, world!")
(newline)))
EOF
output="$(cat $out)"
if test "$output" != "$expectation"; then
echo "output mismatch: expected ''${expectation}, but got ''${output}"
exit 1
fi
''

0 comments on commit 6c5dbbe

Please sign in to comment.