diff options
Diffstat (limited to 'pkgs/build-support/trivial-builders')
-rw-r--r-- | pkgs/build-support/trivial-builders/test.nix | 20 | ||||
-rwxr-xr-x | pkgs/build-support/trivial-builders/test.sh | 41 |
2 files changed, 61 insertions, 0 deletions
diff --git a/pkgs/build-support/trivial-builders/test.nix b/pkgs/build-support/trivial-builders/test.nix new file mode 100644 index 00000000000..0902a537222 --- /dev/null +++ b/pkgs/build-support/trivial-builders/test.nix @@ -0,0 +1,20 @@ +{ lib, nixosTest, path, writeText, hello, figlet, stdenvNoCC }: + +nixosTest { + name = "nixpkgs-trivial-builders"; + nodes.machine = { ... }: { + virtualisation.writableStore = true; + + # Test runs without network, so we don't substitute and prepare our deps + nix.binaryCaches = lib.mkForce []; + environment.etc."pre-built-paths".source = writeText "pre-built-paths" ( + builtins.toJSON [hello figlet stdenvNoCC] + ); + }; + testScript = '' + machine.succeed(""" + cd ${lib.cleanSource path} + ./pkgs/build-support/trivial-builders/test.sh 2>/dev/console + """) + ''; +} diff --git a/pkgs/build-support/trivial-builders/test.sh b/pkgs/build-support/trivial-builders/test.sh new file mode 100755 index 00000000000..eec501ae601 --- /dev/null +++ b/pkgs/build-support/trivial-builders/test.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +# -------------------------------------------------------------------------- # +# +# trivial-builders test +# +# -------------------------------------------------------------------------- # +# +# This file can be run independently (quick): +# +# $ pkgs/build-support/trivial-builders/test.sh +# +# or in the build sandbox with a ~20s VM overhead +# +# $ nix-build -A tests.trivial-builders +# +# -------------------------------------------------------------------------- # + +# strict bash +set -euo pipefail + +# debug +# set -x +# PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }' + +cd "$(dirname ${BASH_SOURCE[0]})" # nixpkgs root + +testDirectReferences() { + expr="$1" + diff -U3 \ + <(sort <$(nix-build --no-out-link --expr "with import ../../.. {}; writeDirectReferencesToFile ($expr)")) \ + <(nix-store -q --references $(nix-build --no-out-link --expr "with import ../../.. {}; ($expr)") | sort) +} + +testDirectReferences 'hello' +testDirectReferences 'figlet' +testDirectReferences 'writeText "hi" "hello"' +testDirectReferences 'writeText "hi" "hello ${hello}"' +testDirectReferences 'writeText "hi" "hello ${hello} ${figlet}"' + +echo 'OK!' |