@cryptotaxi247 / kubo / commits / c93adf670

test(sharness): fix flaky repo test

Just make sure we've removed all the blocks. We can't guarantee that the size will revert.

Steven Allen committed Oct 29, 2019 at 00:20 UTC c93adf6701ad1efc01fd21d3cb8abd969c1fa19b
2 files changed +3 -29
test/sharness/lib/test-lib.sh
-24
@@ -398,30 +398,6 @@ file_size() {
398 $_STAT "$1"
399 }
400
401 -directory_size() {
402 - local total=0
403 - local fsize=0
404 - local res=0
405 - find "$1" -type f | ( while read fname; do
406 - fsize=$(file_size "$fname")
407 - res=$?
408 - if ! test $res -eq 0; then
409 - if ! test -e "$fname"; then
410 - continue;
411 - fi
412 - echo "failed to get filesize" >&2
413 - return $res
414 - fi
415 - total=$(expr "$total" + "$fsize")
416 - res=$?
417 - if ! test $res -eq 0; then
418 - echo "filesize not a number: $fsize" >&2
419 - return $res
420 - fi
421 - done
422 - echo "$total" ) # do not remove this subshell
423 -}
424 -
401 test_check_peerid() {
402 peeridlen=$(echo "$1" | tr -dC "[:alnum:]" | wc -c | tr -d " ") &&
403 test "$peeridlen" = "46" || {
test/sharness/t0080-repo.sh
+3 -5
@@ -50,8 +50,7 @@ test_expect_success "'ipfs pin rm' output looks good" '
50 test_expect_success "ipfs repo gc fully reverse ipfs add (part 1)" '
51 ipfs repo gc &&
52 random 100000 41 >gcfile &&
53 - expected="$(directory_size "$IPFS_PATH/blocks")" &&
54 - find "$IPFS_PATH/blocks" -type f &&
53 + find "$IPFS_PATH/blocks" -type f | sort -u > expected_blocks &&
54 hash=$(ipfs add -q gcfile) &&
55 ipfs pin rm -r $hash &&
56 ipfs repo gc
@@ -60,9 +59,8 @@ test_expect_success "ipfs repo gc fully reverse ipfs add (part 1)" '
59 test_kill_ipfs_daemon
60
61 test_expect_success "ipfs repo gc fully reverse ipfs add (part 2)" '
63 - actual=$(directory_size "$IPFS_PATH/blocks") &&
64 - { test "$actual" -eq "$expected" || test_fsh echo "$actual != $expected"; } &&
65 - { test "$actual" -gt "0" || test_fsh echo "not($actual > 0)"; }
62 + find "$IPFS_PATH/blocks" -type f | sort -u > actual_blocks &&
63 + test_cmp expected_blocks actual_blocks
64 '
65
66 test_launch_ipfs_daemon --offline