nixpkgs-update/check-result.sh

85 lines
1.8 KiB
Bash
Raw Normal View History

2018-02-25 08:22:10 +03:00
#! /usr/bin/env bash
set -euxo pipefail
RESULT_PATH=$1
EXPECTED_VERSION=$2
2018-02-26 04:19:55 +03:00
LOG_FILE=~/.nix-update/check-result-log.tmp
2018-02-25 08:22:10 +03:00
2018-03-22 21:14:04 +03:00
EDITOR="echo"
export EDITOR
OLD_HOME=~/
HOME=/homeless-shelter
pushd "$(mktemp -d)" >/dev/null
2018-03-22 21:14:04 +03:00
2018-02-25 08:22:10 +03:00
rm -f $LOG_FILE
2018-02-26 04:19:55 +03:00
function check_binary_help()
2018-02-25 08:22:10 +03:00
{
2018-03-17 17:57:57 +03:00
if timeout -k 2 1 "$1" "$2" 2>/dev/null 1>/dev/null
2018-02-25 08:22:10 +03:00
then
2018-02-26 04:17:42 +03:00
echo "- ran \`$1 $2\` got 0 exit code" >> $LOG_FILE
2018-02-25 08:22:10 +03:00
fi
}
2018-02-26 04:19:55 +03:00
function check_version_type()
2018-02-25 08:22:10 +03:00
{
2018-03-17 17:57:57 +03:00
if timeout -k 2 1 "$1" "$2" 2>&1 | grep "$EXPECTED_VERSION" >/dev/null
2018-02-25 08:22:10 +03:00
then
2018-02-26 04:17:42 +03:00
echo "- ran \`$1 $2\` and found version $EXPECTED_VERSION" >> $LOG_FILE
2018-02-25 08:22:10 +03:00
fi
}
2018-02-26 04:19:55 +03:00
function check_binary() {
2018-02-25 08:22:10 +03:00
2018-02-26 04:19:55 +03:00
check_binary_help "$1" "-h"
check_binary_help "$1" "--help"
check_binary_help "$1" "help"
2018-02-25 08:22:10 +03:00
2018-02-26 04:19:55 +03:00
check_version_type "$1" "-V"
check_version_type "$1" "-v"
check_version_type "$1" "--version"
check_version_type "$1" "version"
check_version_type "$1" "-h"
check_version_type "$1" "--help"
check_version_type "$1" "help"
2018-02-25 08:22:10 +03:00
}
2018-03-17 17:57:57 +03:00
BINARIES=$(find "$RESULT_PATH"/bin -type f || true)
2018-02-25 08:22:10 +03:00
for b in $BINARIES
do
2018-03-17 17:57:57 +03:00
check_binary "$b"
2018-02-25 08:22:10 +03:00
done
if [ -s $LOG_FILE ]
then
true
else
2018-03-04 22:06:22 +03:00
echo "- Warning: no binary found that responded to help or version flags. (This warning appears even if the package isn't expected to have binaries.)" >> $LOG_FILE
fi
2018-03-17 17:57:57 +03:00
if grep -r "$EXPECTED_VERSION" "$RESULT_PATH" >/dev/null
2018-02-26 04:17:42 +03:00
then
echo "- found $EXPECTED_VERSION with grep in $RESULT_PATH" >> $LOG_FILE
fi
2018-03-17 17:57:57 +03:00
if find "$RESULT_PATH" -type f -printf '%f\n' | grep "$EXPECTED_VERSION" >/dev/null
2018-02-26 04:17:42 +03:00
then
echo "- found $EXPECTED_VERSION in filename of file in $RESULT_PATH" >> $LOG_FILE
fi
2018-03-22 21:14:04 +03:00
HOME="$OLD_HOME"
2018-03-17 17:57:57 +03:00
GIST=$(tree "$RESULT_PATH" | gist || "")
if [ -n "$GIST" ]
then
echo "- directory tree listing: $GIST" >> $LOG_FILE
fi
popd >/dev/null
2018-03-22 21:14:04 +03:00
2018-02-26 04:17:42 +03:00
cat $LOG_FILE || true