#!/usr/bin/env bash set -euo pipefail shopt -s inherit_errexit # Use # || die die() { echo >&2 "test case failed: " "$@" exit 1 } if test -n "${TEST_LIB:-}"; then NIX_PATH=nixpkgs="$(dirname "$TEST_LIB")" else NIX_PATH=nixpkgs="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.."; pwd)" fi export NIX_PATH 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 --impure --raw --expr '(with import ; "${ cleanSource ./. }")')" (cd "$dir"; find) | sort -f | diff -U10 - <(cat <&2 tests ok