1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-03-06 23:31:34 +00:00
nixpkgs/pkgs/build-support/dev-shell-tools/tests/default.nix
2024-06-29 17:21:01 +02:00

46 lines
1.3 KiB
Nix

{
devShellTools,
emptyFile,
lib,
stdenv,
hello,
}:
let
inherit (lib) escapeShellArg;
in
{
# nix-build -A tests.devShellTools.stringValue
stringValue =
let inherit (devShellTools) stringValue; in
stdenv.mkDerivation {
name = "devShellTools-stringValue-built-tests";
# Test inputs
inherit emptyFile hello;
one = 1;
boolTrue = true;
boolFalse = false;
foo = "foo";
list = [ 1 2 3 ];
pathDefaultNix = ./default.nix;
packages = [ hello emptyFile ];
# TODO: nested lists
buildCommand = ''
touch $out
( set -x
[[ "$one" = ${escapeShellArg (stringValue 1)} ]]
[[ "$boolTrue" = ${escapeShellArg (stringValue true)} ]]
[[ "$boolFalse" = ${escapeShellArg (stringValue false)} ]]
[[ "$foo" = ${escapeShellArg (stringValue "foo")} ]]
[[ "$hello" = ${escapeShellArg (stringValue hello)} ]]
[[ "$list" = ${escapeShellArg (stringValue [ 1 2 3 ])} ]]
[[ "$packages" = ${escapeShellArg (stringValue [ hello emptyFile ])} ]]
[[ "$pathDefaultNix" = ${escapeShellArg (stringValue ./default.nix)} ]]
[[ "$emptyFile" = ${escapeShellArg (stringValue emptyFile)} ]]
) >log 2>&1 || { cat log; exit 1; }
'';
};
}