"make confidence" should work on mac (partial implementation)

This commit is contained in:
tlimoncelli@stackexchange.com
2015-02-28 07:58:08 -06:00
parent 5baec75e4b
commit a9562e73d6
2 changed files with 24 additions and 5 deletions

View File

@@ -69,7 +69,6 @@ unlock-rpm:
confidence: confidence:
@if [[ -e ~/.gnupg ]]; then echo ERROR: '~/.gnupg should not exist. If it does, bugs may polute your .gnupg configuration. If the code has no bugs everything will be fine. Do you feel lucky?'; false ; fi @if [[ -e ~/.gnupg ]]; then echo ERROR: '~/.gnupg should not exist. If it does, bugs may polute your .gnupg configuration. If the code has no bugs everything will be fine. Do you feel lucky?'; false ; fi
@if which >/dev/null gpg-agent ; then pkill gpg-agent ; rm -rf /tmp/tmp.* ; fi @if which >/dev/null gpg-agent ; then pkill gpg-agent ; rm -rf /tmp/tmp.* ; fi
@export PATH=~/gitwork/blackbox/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin ; @export PATH=~/gitwork/blackbox/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/local/bin ; tools/confidence_test.sh
cd ~/gitwork/blackbox && tools/confidence_test.sh
@if which >/dev/null gpg-agent ; then pkill gpg-agent ; fi @if which >/dev/null gpg-agent ; then pkill gpg-agent ; fi
@if [[ -e ~/.gnupg ]]; then echo ERROR: '~/.gnupg was created which means the scripts might be poluting GnuPG configuration. Fix this bug.'; false ; fi @if [[ -e ~/.gnupg ]]; then echo ERROR: '~/.gnupg was created which means the scripts might be poluting GnuPG configuration. Fix this bug.'; false ; fi

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
blackbox_home=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/../bin blackbox_home=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/../bin
export PATH=${blackbox_home}:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin export PATH="${blackbox_home}:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/local/bin"
. _stack_lib.sh . _stack_lib.sh
@@ -15,6 +15,25 @@ function PHASE() {
echo '********************' echo '********************'
} }
function md5sum_file() {
# Portably generate the MD5 hash of file $1.
case $(uname -s) in
Darwin )
md5 -r "$1" | awk '{ print $1 }'
;;
Linux )
md5sum "$1" | awk '{ print $1 }'
;;
CYGWIN* )
md5sum "$1" | awk '{ print $1 }'
;;
* )
echo 'ERROR: Unknown OS. Exiting.'
exit 1
;;
esac
}
function assert_file_missing() { function assert_file_missing() {
if [[ -e "$1" ]]; then if [[ -e "$1" ]]; then
echo "ASSERT FAILED: ${1} should not exist." echo "ASSERT FAILED: ${1} should not exist."
@@ -36,7 +55,7 @@ function assert_file_md5hash() {
local file="$1" local file="$1"
local wanted="$2" local wanted="$2"
assert_file_exists "$file" assert_file_exists "$file"
local found=$(md5sum <"$file" | cut -d' ' -f1 ) local found=$(md5sum_file "$file")
if [[ "$wanted" != "$found" ]]; then if [[ "$wanted" != "$found" ]]; then
echo "ASSERT FAILED: $file hash wanted=$wanted found=$found" echo "ASSERT FAILED: $file hash wanted=$wanted found=$found"
exit 1 exit 1
@@ -54,7 +73,7 @@ function assert_file_group() {
;; ;;
esac esac
local found=$(ls -l "$file" | awk '{ print $4 }') local found=$(ls -lg "$file" | awk '{ print $3 }')
# NB(tlim): We could do this with 'stat' but it would break on BSD-style OSs. # NB(tlim): We could do this with 'stat' but it would break on BSD-style OSs.
if [[ "$wanted" != "$found" ]]; then if [[ "$wanted" != "$found" ]]; then
echo "ASSERT FAILED: $file chgrp wanted=$wanted found=$found" echo "ASSERT FAILED: $file chgrp wanted=$wanted found=$found"
@@ -220,6 +239,7 @@ gpg --import keyrings/live/pubring.gpg
TEST_GID_NUM=$(id -G | fmt -1 | tail -n +2 | grep -xv $(id -u) | head -n 1) TEST_GID_NUM=$(id -G | fmt -1 | tail -n +2 | grep -xv $(id -u) | head -n 1)
TEST_GID_NAME=$(getent group "$TEST_GID_NUM" | cut -d: -f1) TEST_GID_NAME=$(getent group "$TEST_GID_NUM" | cut -d: -f1)
DEFAULT_GID_NAME=$(getent group $(id -u) | cut -d: -f1) DEFAULT_GID_NAME=$(getent group $(id -u) | cut -d: -f1)
: ${DEFAULT_GID_NAME:=staff) ;
echo TEST_GID_NUM=$TEST_GID_NUM echo TEST_GID_NUM=$TEST_GID_NUM
echo TEST_GID_NAME=$TEST_GID_NAME echo TEST_GID_NAME=$TEST_GID_NAME
echo DEFAULT_GID_NAME=$DEFAULT_GID_NAME echo DEFAULT_GID_NAME=$DEFAULT_GID_NAME