From 6c5dbbe74ab95aeda6e86df971e4da85c15dbdbf Mon Sep 17 00:00:00 2001 From: rczb Date: Tue, 17 Dec 2024 13:34:33 +0800 Subject: [PATCH] racket-minimal: add tests --- .../interpreters/racket/minimal.nix | 9 ++++++++ .../tests/get-current-launcher-variant.nix | 18 +++++++++++++++ .../racket/tests/write-greeting.nix | 23 +++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 pkgs/development/interpreters/racket/tests/get-current-launcher-variant.nix create mode 100644 pkgs/development/interpreters/racket/tests/write-greeting.nix diff --git a/pkgs/development/interpreters/racket/minimal.nix b/pkgs/development/interpreters/racket/minimal.nix index ed15c5833665b7..23202563a59ce4 100644 --- a/pkgs/development/interpreters/racket/minimal.nix +++ b/pkgs/development/interpreters/racket/minimal.nix @@ -9,6 +9,8 @@ ncurses, disableDocs ? false, + + callPackage, }: let @@ -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 = '' diff --git a/pkgs/development/interpreters/racket/tests/get-current-launcher-variant.nix b/pkgs/development/interpreters/racket/tests/get-current-launcher-variant.nix new file mode 100644 index 00000000000000..fd84220e640c5d --- /dev/null +++ b/pkgs/development/interpreters/racket/tests/get-current-launcher-variant.nix @@ -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 + '' diff --git a/pkgs/development/interpreters/racket/tests/write-greeting.nix b/pkgs/development/interpreters/racket/tests/write-greeting.nix new file mode 100644 index 00000000000000..33ccdc924d6ba4 --- /dev/null +++ b/pkgs/development/interpreters/racket/tests/write-greeting.nix @@ -0,0 +1,23 @@ +{ runCommandLocal, racket }: + +runCommandLocal "racket-test-write-greeting" + { + nativeBuildInputs = [ racket ]; + } + '' + expectation="Hello, world!" + + racket -f - <