depot/third_party/nixpkgs/pkgs/build-support/dev-shell-tools/tests/default.nix
Default email f34ce41345 Project import generated by Copybara.
GitOrigin-RevId: b73c2221a46c13557b1b3be9c2070cc42cf01eb3
2024-07-27 08:49:29 +02:00

45 lines
1.3 KiB
Nix

{
devShellTools,
emptyFile,
lib,
stdenv,
hello,
}:
let
inherit (lib) escapeShellArg;
in
{
# nix-build -A tests.devShellTools.valueToString
valueToString =
let inherit (devShellTools) valueToString; in
stdenv.mkDerivation {
name = "devShellTools-valueToString-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 (valueToString 1)} ]]
[[ "$boolTrue" = ${escapeShellArg (valueToString true)} ]]
[[ "$boolFalse" = ${escapeShellArg (valueToString false)} ]]
[[ "$foo" = ${escapeShellArg (valueToString "foo")} ]]
[[ "$hello" = ${escapeShellArg (valueToString hello)} ]]
[[ "$list" = ${escapeShellArg (valueToString [ 1 2 3 ])} ]]
[[ "$packages" = ${escapeShellArg (valueToString [ hello emptyFile ])} ]]
[[ "$pathDefaultNix" = ${escapeShellArg (valueToString ./default.nix)} ]]
[[ "$emptyFile" = ${escapeShellArg (valueToString emptyFile)} ]]
) >log 2>&1 || { cat log; exit 1; }
'';
};
}