summary refs log tree commit diff
path: root/pkgs/build-support/trivial-builders
diff options
context:
space:
mode:
authorBernardo Meurer <bernardo@meurer.org>2022-11-15 11:24:34 -0500
committerBernardo Meurer <bernardo@meurer.org>2022-11-15 11:47:36 -0500
commit43bf542ccd8f439964a049f1586689de20bbadb1 (patch)
tree70cec972ab9a1a07f09f98932b4aa3afdd71fa02 /pkgs/build-support/trivial-builders
parent6382598677548d5b483dce4ab380067cd91af6d2 (diff)
downloadnixpkgs-43bf542ccd8f439964a049f1586689de20bbadb1.tar
nixpkgs-43bf542ccd8f439964a049f1586689de20bbadb1.tar.gz
nixpkgs-43bf542ccd8f439964a049f1586689de20bbadb1.tar.bz2
nixpkgs-43bf542ccd8f439964a049f1586689de20bbadb1.tar.lz
nixpkgs-43bf542ccd8f439964a049f1586689de20bbadb1.tar.xz
nixpkgs-43bf542ccd8f439964a049f1586689de20bbadb1.tar.zst
nixpkgs-43bf542ccd8f439964a049f1586689de20bbadb1.zip
tests.trivial-builders.linkFarm: init
Diffstat (limited to 'pkgs/build-support/trivial-builders')
-rw-r--r--pkgs/build-support/trivial-builders/test/link-farm.nix45
1 files changed, 45 insertions, 0 deletions
diff --git a/pkgs/build-support/trivial-builders/test/link-farm.nix b/pkgs/build-support/trivial-builders/test/link-farm.nix
new file mode 100644
index 00000000000..1ebfc707632
--- /dev/null
+++ b/pkgs/build-support/trivial-builders/test/link-farm.nix
@@ -0,0 +1,45 @@
+{ linkFarm, hello, writeTextFile, runCommand }:
+let
+  foo = writeTextFile {
+    name = "foo";
+    text = "foo";
+  };
+
+  linkFarmFromList = linkFarm "linkFarmFromList" [
+    { name = "foo"; path = foo; }
+    { name = "hello"; path = hello; }
+  ];
+
+  linkFarmWithRepeats = linkFarm "linkFarmWithRepeats" [
+    { name = "foo"; path = foo; }
+    { name = "hello"; path = hello; }
+    { name = "foo"; path = hello; }
+  ];
+
+  linkFarmFromAttrs = linkFarm "linkFarmFromAttrs" {
+    inherit foo hello;
+  };
+in
+runCommand "test-linkFarm" { } ''
+  function assertPathEquals() {
+    local a b;
+    a="$(realpath "$1")"
+    b="$(realpath "$2")"
+    if [ "$a" != "$b" ]; then
+      echo "path mismatch!"
+      echo "a: $1 -> $a"
+      echo "b: $2 -> $b"
+      exit 1
+    fi
+  }
+
+  assertPathEquals "${linkFarmFromList}/foo" "${foo}"
+  assertPathEquals "${linkFarmFromList}/hello" "${hello}"
+
+  assertPathEquals "${linkFarmWithRepeats}/foo" "${hello}"
+  assertPathEquals "${linkFarmWithRepeats}/hello" "${hello}"
+
+  assertPathEquals "${linkFarmFromAttrs}/foo" "${foo}"
+  assertPathEquals "${linkFarmFromAttrs}/hello" "${hello}"
+  touch $out
+''