diff options
author | Florian Richer <florian.richer.97@outlook.com> | 2024-04-02 19:01:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-02 19:01:05 +0200 |
commit | 3b883d3cdf8942c56e5f232973b50fc1c9e941aa (patch) | |
tree | a25bda45439586ebdbb6332f6aa742cd88a6c19a /lib/tests/misc.nix | |
parent | 9ce47d84cddede3ee9330f63f458e60e267f939c (diff) |
lib/strings: Add makeIncludePath (#296237)
* Update strings.nix * Fix typo in docs * Update lib/strings.nix Co-authored-by: lolbinarycat <dogedoge61+github@gmail.com> * Update lib/strings.nix Co-authored-by: lolbinarycat <dogedoge61+github@gmail.com> * Add unit test with strings * Move test to strings * Add unit test with package structure * testMakeIncludePathWithPkgs: use real pkgs * Revert "testMakeIncludePathWithPkgs: use real pkgs" This reverts commit fb1850c069cfb324f3a43323da740a27a11793f3. * Update lib/tests/misc.nix Co-authored-by: lolbinarycat <dogedoge61+github@gmail.com> * Update lib/tests/misc.nix Co-authored-by: Silvan Mosberger <github@infinisil.com> --------- Co-authored-by: lolbinarycat <dogedoge61+github@gmail.com> Co-authored-by: Silvan Mosberger <github@infinisil.com>
Diffstat (limited to 'lib/tests/misc.nix')
-rw-r--r-- | lib/tests/misc.nix | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/tests/misc.nix b/lib/tests/misc.nix index 6f1d9039db802..3cb96c1b68bc2 100644 --- a/lib/tests/misc.nix +++ b/lib/tests/misc.nix @@ -64,6 +64,7 @@ let lists listToAttrs makeExtensible + makeIncludePath makeOverridable mapAttrs matchAttrs @@ -296,6 +297,35 @@ runTests { expected = "a\nb\nc\n"; }; + testMakeIncludePathWithPkgs = { + expr = (makeIncludePath [ + # makeIncludePath preferably selects the "dev" output + { dev.outPath = "/dev"; out.outPath = "/out"; outPath = "/default"; } + # "out" is used if "dev" is not found + { out.outPath = "/out"; outPath = "/default"; } + # And it returns the derivation directly if there's no "out" either + { outPath = "/default"; } + # Same if the output is specified explicitly, even if there's a "dev" + { dev.outPath = "/dev"; outPath = "/default"; outputSpecified = true; } + ]); + expected = "/dev/include:/out/include:/default/include:/default/include"; + }; + + testMakeIncludePathWithEmptyList = { + expr = (makeIncludePath [ ]); + expected = ""; + }; + + testMakeIncludePathWithOneString = { + expr = (makeIncludePath [ "/usr" ]); + expected = "/usr/include"; + }; + + testMakeIncludePathWithManyString = { + expr = (makeIncludePath [ "/usr" "/usr/local" ]); + expected = "/usr/include:/usr/local/include"; + }; + testReplicateString = { expr = strings.replicate 5 "hello"; expected = "hellohellohellohellohello"; |