Something went wrong. Try again.
What happens if I push all of nixpkgs
Something went wrong. Try again.
Shell
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374#!/usr/bin/env bash
# Tests lib/sources.nix# Run:# [nixpkgs]$ lib/tests/sources.sh# or:# [nixpkgs]$ nix-build lib/tests/release.nix
set -euo pipefailshopt -s inherit_errexit
# Use# || diedie() { 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)"fiexport NIX_PATH
work="$(mktemp -d)"clean_up() { rm -rf "$work"}trap clean_up EXITcd "$work"
# Crudely unquotes a JSON string by just taking everything between the first and the second quote.# We're only using this for resulting /nix/store paths, which can't contain " anyways,# nor can they contain any other characters that would need to be escaped specially in JSON# This way we don't need to add a dependency on e.g. jqcrudeUnquoteJSON() { cut -d \" -f2}
touch {README.md,module.o,foo.bar}
dir="$(nix-instantiate --eval --strict --read-write-mode --json --expr '(with import <nixpkgs/lib>; "${ cleanSource ./.}")' | crudeUnquoteJSON)"(cd "$dir"; find) | sort -f | diff -U10 - <(cat <<EOF../foo.bar./README.mdEOF) || die "cleanSource 1"
dir="$(nix-instantiate --eval --strict --read-write-mode --json --expr '(with import <nixpkgs/lib>; "${ cleanSourceWith { src = '"$work"'; filter = path: type: ! hasSuffix ".bar" path; }}")' | crudeUnquoteJSON)"(cd "$dir"; find) | sort -f | diff -U10 - <(cat <<EOF../module.o./README.mdEOF) || die "cleanSourceWith 1"
dir="$(nix-instantiate --eval --strict --read-write-mode --json --expr '(with import <nixpkgs/lib>; "${ cleanSourceWith { src = cleanSource '"$work"'; filter = path: type: ! hasSuffix ".bar" path; }}")' | crudeUnquoteJSON)"(cd "$dir"; find) | sort -f | diff -U10 - <(cat <<EOF../README.mdEOF) || die "cleanSourceWith + cleanSource"
echo >&2 tests ok