2021-05-14 16:27:25 +01:00
|
|
|
#!/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
|
|
|
|
|
2021-05-19 00:02:50 +01:00
|
|
|
if [[ -z ${SAMPLE:-} ]]; then
|
|
|
|
sample=( `nix-build test/sample.nix` )
|
|
|
|
directRefs=( `nix-build test/invoke-writeDirectReferencesToFile.nix` )
|
|
|
|
references=( `nix-build test/invoke-writeReferencesToFile.nix` )
|
|
|
|
else
|
|
|
|
# Injected by Nix (to avoid evaluating in a derivation)
|
|
|
|
# turn them into arrays
|
|
|
|
sample=($SAMPLE)
|
|
|
|
directRefs=($DIRECT_REFS)
|
|
|
|
references=($REFERENCES)
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo >&2 Testing direct references...
|
|
|
|
for i in "${!sample[@]}"; do
|
|
|
|
echo >&2 Checking '#'$i ${sample[$i]} ${directRefs[$i]}
|
2021-05-14 16:27:25 +01:00
|
|
|
diff -U3 \
|
2021-05-19 00:02:50 +01:00
|
|
|
<(sort <${directRefs[$i]}) \
|
|
|
|
<(nix-store -q --references ${sample[$i]} | sort)
|
|
|
|
done
|
2021-05-14 16:27:25 +01:00
|
|
|
|
2021-05-19 00:02:50 +01:00
|
|
|
echo >&2 Testing closure...
|
|
|
|
for i in "${!sample[@]}"; do
|
|
|
|
echo >&2 Checking '#'$i ${sample[$i]} ${references[$i]}
|
2021-05-15 14:10:55 +01:00
|
|
|
diff -U3 \
|
2021-05-19 00:02:50 +01:00
|
|
|
<(sort <${references[$i]}) \
|
|
|
|
<(nix-store -q --requisites ${sample[$i]} | sort)
|
|
|
|
done
|
2021-05-15 14:10:55 +01:00
|
|
|
|
2021-05-14 16:27:25 +01:00
|
|
|
echo 'OK!'
|