mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 10:27:46 +08:00
fix(sharness): use -Q option instead of pipe to tail cmd
This commit is contained in:
parent
3d9cb78ef1
commit
3f4e37f9ac
@ -259,12 +259,12 @@ test_add_cat_file() {
|
||||
mkdir test_current_dir/hello &&
|
||||
echo "World" > test_current_dir/hello/world &&
|
||||
( cd test_current_dir &&
|
||||
ipfs add -r . | tail -n1 > ../actual && cd ../ ) &&
|
||||
ipfs add -r -Q . > ../actual && cd ../ ) &&
|
||||
rm -r test_current_dir
|
||||
'
|
||||
|
||||
test_expect_success "ipfs add -r . output looks good" '
|
||||
echo "added QmZQWnfcqJ6hNkkPvrY9Q5X39GP3jUnUbAV4AbmbbR3Cb1 test_current_dir" > expected
|
||||
echo "QmZQWnfcqJ6hNkkPvrY9Q5X39GP3jUnUbAV4AbmbbR3Cb1" > expected
|
||||
test_cmp expected actual
|
||||
'
|
||||
|
||||
@ -274,12 +274,12 @@ test_add_cat_file() {
|
||||
mkdir test_current_dir/hello &&
|
||||
echo "World" > test_current_dir/hello/world &&
|
||||
( cd test_current_dir &&
|
||||
ipfs add -r ./ | tail -n1 > ../actual && cd ../ ) &&
|
||||
ipfs add -r -Q ./ > ../actual && cd ../ ) &&
|
||||
rm -r test_current_dir
|
||||
'
|
||||
|
||||
test_expect_success "ipfs add -r ./ output looks good" '
|
||||
echo "added QmZQWnfcqJ6hNkkPvrY9Q5X39GP3jUnUbAV4AbmbbR3Cb1 test_current_dir" > expected
|
||||
echo "QmZQWnfcqJ6hNkkPvrY9Q5X39GP3jUnUbAV4AbmbbR3Cb1" > expected
|
||||
test_cmp expected actual
|
||||
'
|
||||
|
||||
|
||||
@ -64,7 +64,7 @@ test_add_w() {
|
||||
test_expect_success "random-files generates test files" '
|
||||
random-files --seed 7547632 --files 5 --dirs 2 --depth 3 m &&
|
||||
echo "$add_w_m" >expected &&
|
||||
ipfs add -q -r m | tail -n1 >actual &&
|
||||
ipfs add -Q -r m >actual &&
|
||||
test_sort_cmp expected actual
|
||||
'
|
||||
|
||||
@ -120,7 +120,7 @@ test_add_w() {
|
||||
|
||||
# test -w -r m/* == -r m
|
||||
test_expect_success "ipfs add -w -r m/* == add -r m succeeds" '
|
||||
ipfs add -q -w -r m/* | tail -n1 >actual
|
||||
ipfs add -Q -w -r m/* >actual
|
||||
'
|
||||
|
||||
test_expect_success "ipfs add -w -r m/* == add -r m is correct" '
|
||||
@ -130,10 +130,10 @@ test_add_w() {
|
||||
|
||||
# test repeats together
|
||||
test_expect_success "ipfs add -w (repeats) succeeds" '
|
||||
ipfs add -q -w -r m/t_1wp-8a2/h3qpecj0 m/ha6f0x7su6/gnz66h \
|
||||
ipfs add -Q -w -r m/t_1wp-8a2/h3qpecj0 m/ha6f0x7su6/gnz66h \
|
||||
m/t_1wp-8a2/_jo7 m/4r93 m/t_1wp-8a2 m/t_1wp-8a2 m/4r93 \
|
||||
m/4r93 m/ha6f0x7su6/_rwujlf3qh_g08 \
|
||||
m/ha6f0x7su6/gnz66h/9cwudvacx | tail -n1 >actual
|
||||
m/ha6f0x7su6/gnz66h/9cwudvacx >actual
|
||||
'
|
||||
|
||||
test_expect_success "ipfs add -w (repeats) is correct" '
|
||||
|
||||
@ -18,8 +18,7 @@ test_expect_success "creating files succeeds" '
|
||||
|
||||
test_add_symlinks() {
|
||||
test_expect_success "ipfs add files succeeds" '
|
||||
ipfs add -q -r files >filehash_all &&
|
||||
tail -n 1 filehash_all >filehash_out
|
||||
ipfs add -Q -r files >filehash_out
|
||||
'
|
||||
|
||||
test_expect_success "output looks good" '
|
||||
@ -28,8 +27,7 @@ test_add_symlinks() {
|
||||
'
|
||||
|
||||
test_expect_success "ipfs add --cid-version=1 files succeeds" '
|
||||
ipfs add -q -r --cid-version=1 files >filehash_all &&
|
||||
tail -n 1 filehash_all >filehash_out
|
||||
ipfs add -Q -r --cid-version=1 files >filehash_out
|
||||
'
|
||||
|
||||
test_expect_success "output looks good" '
|
||||
|
||||
@ -14,23 +14,23 @@ test_expect_success "create some objects for testing diffs" '
|
||||
mkdir foo &&
|
||||
echo "stuff" > foo/bar &&
|
||||
mkdir foo/baz &&
|
||||
A=$(ipfs add -r -q foo | tail -n1) &&
|
||||
AR=$(ipfs add --raw-leaves -r -q foo | tail -n1) &&
|
||||
A=$(ipfs add -r -Q foo) &&
|
||||
AR=$(ipfs add --raw-leaves -r -Q foo) &&
|
||||
echo "more things" > foo/cat &&
|
||||
B=$(ipfs add -r -q foo | tail -n1) &&
|
||||
BR=$(ipfs add --raw-leaves -r -q foo | tail -n1) &&
|
||||
B=$(ipfs add -r -Q foo) &&
|
||||
BR=$(ipfs add --raw-leaves -r -Q foo) &&
|
||||
echo "nested" > foo/baz/dog &&
|
||||
C=$(ipfs add -r -q foo | tail -n1)
|
||||
CR=$(ipfs add --raw-leaves -r -q foo | tail -n1)
|
||||
C=$(ipfs add -r -Q foo)
|
||||
CR=$(ipfs add --raw-leaves -r -Q foo)
|
||||
echo "changed" > foo/bar &&
|
||||
D=$(ipfs add -r -q foo | tail -n1) &&
|
||||
DR=$(ipfs add --raw-leaves -r -q foo | tail -n1) &&
|
||||
D=$(ipfs add -r -Q foo) &&
|
||||
DR=$(ipfs add --raw-leaves -r -Q foo) &&
|
||||
echo "" > single_file &&
|
||||
SINGLE_FILE=$(ipfs add -r -q single_file | tail -n1) &&
|
||||
SINGLE_FILE_RAW=$(ipfs add --raw-leaves -r -q single_file | tail -n1) &&
|
||||
SINGLE_FILE=$(ipfs add -r -Q single_file) &&
|
||||
SINGLE_FILE_RAW=$(ipfs add --raw-leaves -r -Q single_file) &&
|
||||
mkdir empty_dir
|
||||
EMPTY_DIR=$(ipfs add -r -q empty_dir | tail -n1)
|
||||
EMPTY_DIR_RAW=$(ipfs add --raw-leaves -r -q empty_dir | tail -n1)
|
||||
EMPTY_DIR=$(ipfs add -r -Q empty_dir)
|
||||
EMPTY_DIR_RAW=$(ipfs add --raw-leaves -r -Q empty_dir)
|
||||
'
|
||||
|
||||
test_expect_success "diff against self is empty" '
|
||||
|
||||
@ -314,7 +314,7 @@ test_dag_cmd() {
|
||||
|
||||
test_expect_success "prepare dag-pb object" '
|
||||
echo foo > test_file &&
|
||||
HASH=$(ipfs add -wq test_file | tail -n1 | ipfs cid base32)
|
||||
HASH=$(ipfs add -wQ test_file | ipfs cid base32)
|
||||
'
|
||||
|
||||
test_expect_success "dag put with json dag-pb works" '
|
||||
|
||||
@ -175,11 +175,10 @@ test_expect_success "'ipfs refs --unique' is correct" '
|
||||
mkdir -p uniques &&
|
||||
echo "content1" > uniques/file1 &&
|
||||
echo "content1" > uniques/file2 &&
|
||||
ipfs add -r -q uniques > add_output &&
|
||||
ROOT=$(tail -n1 add_output) &&
|
||||
ROOT=$(ipfs add -r -Q uniques) &&
|
||||
ipfs refs --unique $ROOT >expected &&
|
||||
ipfs add -q uniques/file1 >unique_hash &&
|
||||
test_cmp expected unique_hash || test_fsh cat add_output
|
||||
test_cmp expected unique_hash
|
||||
'
|
||||
|
||||
test_expect_success "'ipfs refs --unique --recursive' is correct" '
|
||||
@ -188,12 +187,11 @@ test_expect_success "'ipfs refs --unique --recursive' is correct" '
|
||||
echo "c1" > a/b/f1 &&
|
||||
echo "c1" > a/b/c/f1 &&
|
||||
echo "c2" > a/b/c/f2 &&
|
||||
ipfs add -r -q a >add_output &&
|
||||
ROOT=$(tail -n1 add_output) &&
|
||||
ROOT=$(ipfs add -r -Q a) &&
|
||||
ipfs refs --unique --recursive $ROOT >refs_output &&
|
||||
wc -l refs_output | sed "s/^ *//g" >line_count &&
|
||||
echo "4 refs_output" >expected &&
|
||||
test_cmp expected line_count || test_fsh cat add_output || test_fsh cat refs_output
|
||||
test_cmp expected line_count || test_fsh cat refs_output
|
||||
'
|
||||
|
||||
test_expect_success "'ipfs refs --recursive (bigger)'" '
|
||||
@ -207,12 +205,11 @@ test_expect_success "'ipfs refs --recursive (bigger)'" '
|
||||
cp -r b b2 && mv b2 b/b2 &&
|
||||
cp -r b b3 && mv b3 b/b3 &&
|
||||
cp -r b b4 && mv b4 b/b4 &&
|
||||
ipfs add -r -q b >add_output &&
|
||||
hash=$(tail -n1 add_output) &&
|
||||
hash=$(ipfs add -r -Q b) &&
|
||||
ipfs refs -r "$hash" >refs_output &&
|
||||
wc -l refs_output | sed "s/^ *//g" >actual &&
|
||||
echo "79 refs_output" >expected &&
|
||||
test_cmp expected actual || test_fsh cat add_output || test_fsh cat refs_output
|
||||
test_cmp expected actual || test_fsh cat refs_output
|
||||
'
|
||||
|
||||
test_expect_success "'ipfs refs --unique --recursive (bigger)'" '
|
||||
|
||||
@ -94,11 +94,10 @@ test_expect_success "'ipfs add dir' succeeds" '
|
||||
echo "some text 6" >dir1/dir2/dir4/file6 &&
|
||||
echo "some text 2" >dir1/dir3/file2 &&
|
||||
echo "some text 5" >dir1/dir3/file5 &&
|
||||
ipfs add -q -r dir1 >actualall &&
|
||||
tail -n1 actualall >actual1 &&
|
||||
echo "$HASH_DIR1" >expected1 &&
|
||||
ipfs add -Q -r dir1 >actual &&
|
||||
echo "$HASH_DIR1" >expected &&
|
||||
ipfs repo gc && # remove the patch chaff
|
||||
test_cmp expected1 actual1
|
||||
test_cmp expected actual
|
||||
'
|
||||
|
||||
test_expect_success "objects are there" '
|
||||
@ -265,9 +264,9 @@ test_expect_success "test add nopin dir" '
|
||||
mkdir nopin_dir1 &&
|
||||
echo "some nopin text 1" >nopin_dir1/file1 &&
|
||||
echo "some nopin text 2" >nopin_dir1/file2 &&
|
||||
ipfs add -q -r --pin=false nopin_dir1 | tail -n1 >actual1 &&
|
||||
echo "$HASH_NOPINDIR" >expected1 &&
|
||||
test_cmp actual1 expected1 &&
|
||||
ipfs add -Q -r --pin=false nopin_dir1 >actual &&
|
||||
echo "$HASH_NOPINDIR" >expected &&
|
||||
test_cmp actual expected &&
|
||||
test_pin_flag "$HASH_NOPINDIR" direct false &&
|
||||
test_pin_flag "$HASH_NOPINDIR" indirect false &&
|
||||
test_pin_flag "$HASH_NOPINDIR" recursive false &&
|
||||
|
||||
@ -89,7 +89,7 @@ test_get_cmd() {
|
||||
touch dir/a &&
|
||||
mkdir -p dir/b &&
|
||||
echo "Hello, Worlds!" >dir/b/c &&
|
||||
HASH2=`ipfs add -r -q dir | tail -n 1` &&
|
||||
HASH2=`ipfs add -r -Q dir` &&
|
||||
ipfs get "$HASH2" >actual
|
||||
'
|
||||
|
||||
|
||||
@ -167,7 +167,7 @@ test_expect_success "test failure conditions of mutex pprof endpoint" '
|
||||
test_expect_success "setup index hash" '
|
||||
mkdir index &&
|
||||
echo "<p></p>" > index/index.html &&
|
||||
INDEXHASH=$(ipfs add -q -r index | tail -n1)
|
||||
INDEXHASH=$(ipfs add -Q -r index)
|
||||
echo index: $INDEXHASH
|
||||
'
|
||||
|
||||
|
||||
@ -46,7 +46,7 @@ run_random_dir_test() {
|
||||
'
|
||||
|
||||
test_expect_success "add those on node 0" '
|
||||
DIR_HASH=$(ipfsi 0 add -r -q foobar | tail -n1)
|
||||
DIR_HASH=$(ipfsi 0 add -r -Q foobar)
|
||||
'
|
||||
|
||||
check_dir_fetch 1 $DIR_HASH
|
||||
|
||||
@ -50,7 +50,7 @@ run_random_dir_test() {
|
||||
'
|
||||
|
||||
test_expect_success "add those on node 2" '
|
||||
DIR_HASH=$(ipfsi 2 add -r -q foobar | tail -n1)
|
||||
DIR_HASH=$(ipfsi 2 add -r -Q foobar)
|
||||
'
|
||||
|
||||
check_dir_fetch 0 $DIR_HASH
|
||||
|
||||
@ -9,9 +9,9 @@ test_init_ipfs
|
||||
test_expect_success "resolve: prepare files" '
|
||||
mkdir -p a/b &&
|
||||
echo "a/b/c" >a/b/c &&
|
||||
a_hash=$(ipfs add -q -r a | tail -n1) &&
|
||||
b_hash=$(ipfs add -q -r a/b | tail -n1) &&
|
||||
c_hash=$(ipfs add -q -r a/b/c | tail -n1) &&
|
||||
a_hash=$(ipfs add -Q -r a) &&
|
||||
b_hash=$(ipfs add -Q -r a/b) &&
|
||||
c_hash=$(ipfs add -Q -r a/b/c) &&
|
||||
a_hash_b32=$(cid-fmt -v 1 -b b %s $a_hash) &&
|
||||
b_hash_b32=$(cid-fmt -v 1 -b b %s $b_hash) &&
|
||||
c_hash_b32=$(cid-fmt -v 1 -b b %s $c_hash)
|
||||
|
||||
@ -86,7 +86,7 @@ test_expect_success 'add test objects' '
|
||||
HASH_FOO=$(ipfsi 0 add -q --offline --pin=false f1) &&
|
||||
HASH_BAR=$(ipfsi 0 add -q --offline --pin=false f2) &&
|
||||
HASH_BAZ=$(ipfsi 0 add -q --offline f3) &&
|
||||
HASH_BAR_DIR=$(ipfsi 0 add -q --offline -w f2 | tail -1)
|
||||
HASH_BAR_DIR=$(ipfsi 0 add -Q --offline -w f2)
|
||||
'
|
||||
|
||||
findprovs_empty '$HASH_FOO'
|
||||
|
||||
@ -18,7 +18,7 @@ create_files() {
|
||||
echo cats > stuff_test/a &&
|
||||
echo dogs > stuff_test/b &&
|
||||
echo giraffes > stuff_test/c &&
|
||||
DIR1=$(ipfs add -r "$@" -q stuff_test | tail -n1)
|
||||
DIR1=$(ipfs add -r "$@" -Q stuff_test)
|
||||
}
|
||||
|
||||
verify_path_exists() {
|
||||
|
||||
@ -47,7 +47,7 @@ test_expect_success "add directory with direct pin" '
|
||||
mkdir mydir/ &&
|
||||
echo "hello world!" > mydir/hello.txt &&
|
||||
FILE_UNPINNED=$(ipfs add --pin=false -q -r mydir/hello.txt) &&
|
||||
DIR_PINNED=$(ipfs add --pin=false -q -r mydir | tail -n1) &&
|
||||
DIR_PINNED=$(ipfs add --pin=false -Q -r mydir) &&
|
||||
ipfs add --pin=false -r mydir &&
|
||||
ipfs pin add --recursive=false $DIR_PINNED &&
|
||||
ipfs cat $FILE_UNPINNED
|
||||
|
||||
@ -19,7 +19,7 @@ test_expect_success "set up test data" '
|
||||
test_add_large_dir() {
|
||||
exphash="$1"
|
||||
test_expect_success "ipfs add on very large directory succeeds" '
|
||||
ipfs add -r -q testdata | tail -n1 > sharddir_out &&
|
||||
ipfs add -r -Q testdata > sharddir_out &&
|
||||
echo "$exphash" > sharddir_exp &&
|
||||
test_cmp sharddir_exp sharddir_out
|
||||
'
|
||||
@ -96,7 +96,7 @@ test_kill_ipfs_daemon
|
||||
test_add_large_dir_v1() {
|
||||
exphash="$1"
|
||||
test_expect_success "ipfs add (CIDv1) on very large directory succeeds" '
|
||||
ipfs add -r -q --cid-version=1 testdata | tail -n1 > sharddir_out &&
|
||||
ipfs add -r -Q --cid-version=1 testdata > sharddir_out &&
|
||||
echo "$exphash" > sharddir_exp &&
|
||||
test_cmp sharddir_exp sharddir_out
|
||||
'
|
||||
@ -119,7 +119,7 @@ test_kill_ipfs_daemon
|
||||
|
||||
test_list_incomplete_dir() {
|
||||
test_expect_success "ipfs add (CIDv1) on very large directory with sha3 succeeds" '
|
||||
ipfs add -r -q --cid-version=1 --hash=sha3-256 --pin=false testdata | tail -n1 > sharddir_out &&
|
||||
ipfs add -r -Q --cid-version=1 --hash=sha3-256 --pin=false testdata > sharddir_out &&
|
||||
largeSHA3dir=$(cat sharddir_out)
|
||||
'
|
||||
|
||||
|
||||
@ -39,7 +39,7 @@ assert_repo_size_greater_than() {
|
||||
|
||||
test_filestore_adds() {
|
||||
test_expect_success "nocopy add succeeds" '
|
||||
HASH=$(ipfs add --raw-leaves --nocopy -r -q somedir | tail -n1)
|
||||
HASH=$(ipfs add --raw-leaves --nocopy -r -Q somedir)
|
||||
'
|
||||
|
||||
test_expect_success "nocopy add has right hash" '
|
||||
|
||||
@ -67,7 +67,7 @@ IPFS_CMD="ipfs"
|
||||
|
||||
test_filestore_adds() {
|
||||
test_expect_success "$IPFS_CMD add nocopy add succeeds" '
|
||||
HASH=$($IPFS_CMD add --raw-leaves --nocopy -r -q somedir | tail -n1)
|
||||
HASH=$($IPFS_CMD add --raw-leaves --nocopy -r -Q somedir)
|
||||
'
|
||||
|
||||
test_expect_success "nocopy add has right hash" '
|
||||
|
||||
Loading…
Reference in New Issue
Block a user