Skip to content

Commit

Permalink
[run_tests.sh] clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
kolloch committed Jan 4, 2024
1 parent 12f0a70 commit d518ae8
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ set -Eeuo pipefail
top="$(dirname "$0")"
top="$(cd "$top"; pwd)"

if [ -z "${IN_CRATE2NIX_SHELL:-}" -o "${IN_NIX_SHELL:-}" = "impure" ]; then
export CACHIX="$(which cachix 2>/dev/null || echo "")"
if [ -z "${IN_CRATE2NIX_SHELL:-}" ] || [ "${IN_NIX_SHELL:-}" = "impure" ]; then
export CACHIX
CACHIX="$(which cachix 2>/dev/null || echo "")"
echo -e "\e[1m=== Entering $top/shell.nix\e[0m" >&2
exec nix-shell --keep CACHIX --pure "$top/shell.nix" --run "$(printf "%q " $0 "$@")"
exec nix-shell --keep CACHIX --pure "$top/shell.nix" --run "$(printf "%q " "$0" "$@")"
fi

echo -e "\e[1m=== Parsing opts for $top/run_tests.sh\e[0m" >&2
Expand All @@ -25,24 +26,24 @@ options=$(getopt -o '' --long offline,build-test-nixpkgs:,no-cargo-build -- "$@
exit 1
}
eval set -- "$options"
NIX_OPTIONS="--option log-lines 100 --show-trace"
REGENERATE_OPTIONS=""
NIX_TESTS_OPTIONS="--out-link ./target/nix-result"
NIX_OPTIONS=( --option log-lines 100 --show-trace )
REGENERATE_OPTIONS=()
NIX_TESTS_OPTIONS=( --out-link ./target/nix-result )
NO_CARGO_BUILD=""
while true; do
case "$1" in
--no-cargo-build)
REGENERATE_OPTIONS="$REGENERATE_OPTIONS --no-cargo-build"
REGENERATE_OPTIONS+=( --no-cargo-build )
NO_CARGO_BUILD="1"
;;
--offline)
NIX_OPTIONS="$NIX_OPTIONS --option substitute false"
REGENERATE_OPTIONS="$REGENERATE_OPTIONS --offline"
NIX_OPTIONS+=( --option substitute false )
REGENERATE_OPTIONS+=( --offline )
CACHIX=""
;;
--build-test-nixpkgs)
shift
NIX_TESTS_OPTIONS="$NIX_TESTS_OPTIONS --arg buildTestNixpkgs $1"
NIX_TESTS_OPTIONS+=( --arg buildTestNixpkgs $1 )
;;
--)
shift
Expand Down Expand Up @@ -84,9 +85,9 @@ else
echo "Skipping because of --no-cargo-build"
fi

../regenerate_cargo_nix.sh $REGENERATE_OPTIONS || {
../regenerate_cargo_nix.sh "${REGENERATE_OPTIONS[@]}" || {
echo "==================" >&2
echo "$top/regenerate_cargo_nix.sh $REGENERATE_OPTIONS: FAILED" >&2
echo "$top/regenerate_cargo_nix.sh ${REGENERATE_OPTIONS[*]}: FAILED" >&2
exit 3
}

Expand All @@ -104,11 +105,11 @@ fi
cd "$top"
echo -e "\e[1m=== Building ./tests.nix (= Running Integration Tests)\e[0m" >&2
rm -rf target/nix-result*
nix build -L $NIX_OPTIONS $NIX_TESTS_OPTIONS -f ./tests.nix || {
nix build -L "${NIX_OPTIONS[@]}" "${NIX_TESTS_OPTIONS[@]}" -f ./tests.nix || {
echo "==================" >&2
echo "cd $top" >&2
echo "nix build -L \\" >&2
echo " $NIX_OPTIONS $NIX_TESTS_OPTIONS \\" >&2
echo " ${NIX_OPTIONS[*]} ${NIX_TESTS_OPTIONS[*]} \\" >&2
echo " -f ./tests.nix"
echo "=> FAILED" >&2
exit 5
Expand All @@ -135,7 +136,7 @@ if test -n "${CACHIX:-}" && test -r ~/.config/cachix/cachix.dhall &&\
echo -e "\e[1m=== Pushing artifacts to eigenvalue.cachix.org \e[0m" >&2
# we filter for "rust_" to exclude some things that are in the
# nixos cache anyways
nix-store -q -R --include-outputs $(nix-store -q -d target/nix-result* | grep -v crates.io) |\
nix-store -q -R --include-outputs "$(nix-store -q -d target/nix-result* | grep -v crates.io)" |\
grep -e "-rust_" |\
$CACHIX push eigenvalue
fi
Expand Down

0 comments on commit d518ae8

Please sign in to comment.