Skip to content

Commit

Permalink
Merge pull request #6997 from ipfs/chore/sharness_fixes_2019-03-16
Browse files Browse the repository at this point in the history
Chore/sharness fixes 2019 03 16
  • Loading branch information
Stebalien committed Mar 17, 2020
2 parents 4acb15d + 51d4383 commit 97401b9
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
5 changes: 4 additions & 1 deletion bin/test-go-fmt
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#!/usr/bin/env bash
set -euo pipefail
T="$(mktemp)"
find . -name '*.go' '!' -path ./plugin/loader/preload.go | xargs gofmt -l > "$T"
find . \
-path ./test/sharness -prune \
-o -path ./plugin/loader/preload.go -prune \
-o -name '*.go' -print0 | xargs -0 gofmt -l > "$T"

if [ -n "$(cat $T)" ]; then
echo "Following Go code is not formatted."
Expand Down
41 changes: 41 additions & 0 deletions test/sharness/lib/test-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,47 @@ SHARNESS_LIB="lib/sharness/sharness.sh"

# Please put go-ipfs specific shell functions below

###
# BEGIN Check for pre-existing daemon being stuck
###
wait_prev_cleanup_tick_secs=1
wait_prev_cleanup_max_secs=5
cur_test_pwd="$(pwd)"

while true ; do
echo -n > stuck_cwd_list

lsof -c ipfs -Ffn 2>/dev/null | grep -A1 '^fcwd$' | grep '^n' | cut -b 2- | while read -r pwd_of_stuck ; do
case "$pwd_of_stuck" in
"$cur_test_pwd"*)
echo "$pwd_of_stuck" >> stuck_cwd_list
;;
*)
;;
esac
done

test -s stuck_cwd_list || break

test "$wait_prev_cleanup_max_secs" -le 0 && break

echo "Daemons still running, waiting for ${wait_prev_cleanup_max_secs}s"
sleep $wait_prev_cleanup_tick_secs

wait_prev_cleanup_max_secs="$(( $wait_prev_cleanup_max_secs - $wait_prev_cleanup_tick_secs ))"
done

if test -s stuck_cwd_list ; then
test_expect_success "ipfs daemon (s)seems to be running with CWDs of
$(cat stuck_cwd_list)
Almost certainly a leftover from a prior test, ABORTING" 'false'

test_done
fi
###
# END Check for pre-existing daemon being stuck
###

# Make sure the ipfs path is set, also set in test_init_ipfs but that
# is not always used.
export IPFS_PATH="$(pwd)/.ipfs"
Expand Down

0 comments on commit 97401b9

Please sign in to comment.