Skip to content

Commit

Permalink
racket-minimal: add info for config dir and main collection dir
Browse files Browse the repository at this point in the history
  • Loading branch information
rc-zb committed Dec 18, 2024
1 parent 13df8a7 commit 68cc2f8
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 5 deletions.
20 changes: 15 additions & 5 deletions pkgs/development/interpreters/racket/minimal.nix
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,11 @@ 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;
nix-write-script = ./tests/nix-write-script.nix;
};
# Useful information #
configDir = "etc/racket";
collectsDir = "share/racket/collects";

# Functionalities #
writeScript =
nameOrPath:
{
Expand All @@ -106,6 +105,17 @@ stdenv.mkDerivation (finalAttrs: {
}
) nameOrPath;
writeScriptBin = name: finalAttrs.passthru.writeScript "/bin/${name}";

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

## Nixpkgs supports ##
nix-write-script = ./tests/nix-write-script.nix;
nix-dirs = ./tests/nix-dirs.nix;
};
};

meta = {
Expand Down
40 changes: 40 additions & 0 deletions pkgs/development/interpreters/racket/tests/nix-dirs.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
lib,
runCommandLocal,
racket,
}:

let
expectation = lib.concatMapStringsSep ":" (subDir: "${racket}/${subDir}/") (
with racket.passthru;
[
configDir
collectsDir
]
);
in

runCommandLocal "racket-test-nix-dirs"
{
nativeBuildInputs = [ racket ];
}
''
expectation="${expectation}"
racket -f - <<EOF
(require setup/dirs)
(with-output-to-file (getenv "out")
(lambda ()
(displayln (string-join (map path->string
(list (find-config-dir)
(find-collects-dir)))
":"))))
EOF
output="$(cat $out)"
if test "$output" != "$expectation"; then
echo "output mismatch: expected ''${expectation}, but got ''${output}"
exit 1
fi
''

0 comments on commit 68cc2f8

Please sign in to comment.