diff options
Diffstat (limited to 'lib/path/tests')
-rw-r--r-- | lib/path/tests/default.nix | 5 | ||||
-rwxr-xr-x | lib/path/tests/prop.sh | 2 | ||||
-rw-r--r-- | lib/path/tests/unit.nix | 19 |
3 files changed, 22 insertions, 4 deletions
diff --git a/lib/path/tests/default.nix b/lib/path/tests/default.nix index 9a31e42828f48..6b8e515f43304 100644 --- a/lib/path/tests/default.nix +++ b/lib/path/tests/default.nix @@ -24,8 +24,9 @@ pkgs.runCommand "lib-path-tests" { export TEST_LIB=$PWD/lib echo "Running unit tests lib/path/tests/unit.nix" - nix-instantiate --eval lib/path/tests/unit.nix \ - --argstr libpath "$TEST_LIB" + nix-instantiate --eval --show-trace \ + --argstr libpath "$TEST_LIB" \ + lib/path/tests/unit.nix echo "Running property tests lib/path/tests/prop.sh" bash lib/path/tests/prop.sh ${toString seed} diff --git a/lib/path/tests/prop.sh b/lib/path/tests/prop.sh index d6021cfcd5fe2..f321fdf1cf450 100755 --- a/lib/path/tests/prop.sh +++ b/lib/path/tests/prop.sh @@ -74,7 +74,7 @@ fi # Precalculate all normalisations with a single Nix call. Calling Nix for each # string individually would take way too long -nix-instantiate --eval --strict --json \ +nix-instantiate --eval --strict --json --show-trace \ --argstr libpath "$TEST_LIB" \ --argstr dir "$tmp/strings" \ "$SCRIPT_DIR"/prop.nix \ diff --git a/lib/path/tests/unit.nix b/lib/path/tests/unit.nix index 61c4ab4d6f2ee..9c5b752cf64a3 100644 --- a/lib/path/tests/unit.nix +++ b/lib/path/tests/unit.nix @@ -3,7 +3,7 @@ { libpath }: let lib = import libpath; - inherit (lib.path) append subpath; + inherit (lib.path) hasPrefix append subpath; cases = lib.runTests { # Test examples from the lib.path.append documentation @@ -40,6 +40,23 @@ let expected = false; }; + testHasPrefixExample1 = { + expr = hasPrefix /foo /foo/bar; + expected = true; + }; + testHasPrefixExample2 = { + expr = hasPrefix /foo /foo; + expected = true; + }; + testHasPrefixExample3 = { + expr = hasPrefix /foo/bar /foo; + expected = false; + }; + testHasPrefixExample4 = { + expr = hasPrefix /. /foo; + expected = true; + }; + # Test examples from the lib.path.subpath.isValid documentation testSubpathIsValidExample1 = { expr = subpath.isValid null; |