From d14be76615299c55e8f239cd1ec95c8107f41b33 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Sat, 6 Feb 2021 00:15:33 +0100 Subject: lib/tests/sources.sh: init --- lib/tests/sources.sh | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100755 lib/tests/sources.sh (limited to 'lib/tests/sources.sh') diff --git a/lib/tests/sources.sh b/lib/tests/sources.sh new file mode 100755 index 0000000000000..71fee719cb21e --- /dev/null +++ b/lib/tests/sources.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Use +# || die +die() { + echo >&2 "test case failed: " "$@" + exit 1 +} + +if test -n "${TEST_LIB:-}"; then + export NIX_PATH=nixpkgs="$(dirname "$TEST_LIB")" +else + export NIX_PATH=nixpkgs="$(cd $(dirname ${BASH_SOURCE[0]})/../..; pwd)" +fi + +work="$(mktemp -d)" +clean_up() { + rm -rf "$work" +} +trap clean_up EXIT +cd $work + +touch {README.md,module.o,foo.bar} + +# nix-instantiate doesn't write out the source, only computing the hash, so +# this uses the experimental nix command instead. + +dir="$(nix eval --raw '(with import ; "${ + cleanSource ./. +}")')" +(cd $dir; find) | sort -f | diff -U10 - <(cat <&2 tests ok -- cgit 1.4.1