fix(sharness): use -Q option instead of pipe to tail cmd
Lucas Molas committed
Nov 3, 2021 at 11:01 UTC
3f4e37f9acbd09ab9289cafa90471d6120cf8a52
18 files changed
+50
-56
test/sharness/t0040-add-and-cat.sh
+4
-4
@@ -259,12 +259,12 @@ test_add_cat_file() {
259
mkdir test_current_dir/hello &&
260
echo "World" > test_current_dir/hello/world &&
261
( cd test_current_dir &&
262
- ipfs add -r . | tail -n1 > ../actual && cd ../ ) &&
262
+ ipfs add -r -Q . > ../actual && cd ../ ) &&
263
rm -r test_current_dir
264
'
265
266
test_expect_success "ipfs add -r . output looks good" '
267
- echo "added QmZQWnfcqJ6hNkkPvrY9Q5X39GP3jUnUbAV4AbmbbR3Cb1 test_current_dir" > expected
267
+ echo "QmZQWnfcqJ6hNkkPvrY9Q5X39GP3jUnUbAV4AbmbbR3Cb1" > expected
268
test_cmp expected actual
269
'
270
@@ -274,12 +274,12 @@ test_add_cat_file() {
274
mkdir test_current_dir/hello &&
275
echo "World" > test_current_dir/hello/world &&
276
( cd test_current_dir &&
277
- ipfs add -r ./ | tail -n1 > ../actual && cd ../ ) &&
277
+ ipfs add -r -Q ./ > ../actual && cd ../ ) &&
278
rm -r test_current_dir
279
'
280
281
test_expect_success "ipfs add -r ./ output looks good" '
282
- echo "added QmZQWnfcqJ6hNkkPvrY9Q5X39GP3jUnUbAV4AbmbbR3Cb1 test_current_dir" > expected
282
+ echo "QmZQWnfcqJ6hNkkPvrY9Q5X39GP3jUnUbAV4AbmbbR3Cb1" > expected
283
test_cmp expected actual
284
'
285
test/sharness/t0043-add-w.sh
+4
-4
@@ -64,7 +64,7 @@ test_add_w() {
64
test_expect_success "random-files generates test files" '
65
random-files --seed 7547632 --files 5 --dirs 2 --depth 3 m &&
66
echo "$add_w_m" >expected &&
67
- ipfs add -q -r m | tail -n1 >actual &&
67
+ ipfs add -Q -r m >actual &&
68
test_sort_cmp expected actual
69
'
70
@@ -120,7 +120,7 @@ test_add_w() {
120
121
# test -w -r m/* == -r m
122
test_expect_success "ipfs add -w -r m/* == add -r m succeeds" '
123
- ipfs add -q -w -r m/* | tail -n1 >actual
123
+ ipfs add -Q -w -r m/* >actual
124
'
125
126
test_expect_success "ipfs add -w -r m/* == add -r m is correct" '
@@ -130,10 +130,10 @@ test_add_w() {
130
131
# test repeats together
132
test_expect_success "ipfs add -w (repeats) succeeds" '
133
- ipfs add -q -w -r m/t_1wp-8a2/h3qpecj0 m/ha6f0x7su6/gnz66h \
133
+ ipfs add -Q -w -r m/t_1wp-8a2/h3qpecj0 m/ha6f0x7su6/gnz66h \
134
m/t_1wp-8a2/_jo7 m/4r93 m/t_1wp-8a2 m/t_1wp-8a2 m/4r93 \
135
m/4r93 m/ha6f0x7su6/_rwujlf3qh_g08 \
136
- m/ha6f0x7su6/gnz66h/9cwudvacx | tail -n1 >actual
136
+ m/ha6f0x7su6/gnz66h/9cwudvacx >actual
137
'
138
139
test_expect_success "ipfs add -w (repeats) is correct" '
test/sharness/t0044-add-symlink.sh
+2
-4
@@ -18,8 +18,7 @@ test_expect_success "creating files succeeds" '
18
19
test_add_symlinks() {
20
test_expect_success "ipfs add files succeeds" '
21
- ipfs add -q -r files >filehash_all &&
22
- tail -n 1 filehash_all >filehash_out
21
+ ipfs add -Q -r files >filehash_out
22
'
23
24
test_expect_success "output looks good" '
@@ -28,8 +27,7 @@ test_add_symlinks() {
27
'
28
29
test_expect_success "ipfs add --cid-version=1 files succeeds" '
31
- ipfs add -q -r --cid-version=1 files >filehash_all &&
32
- tail -n 1 filehash_all >filehash_out
30
+ ipfs add -Q -r --cid-version=1 files >filehash_out
31
'
32
33
test_expect_success "output looks good" '
test/sharness/t0052-object-diff.sh
+12
-12
@@ -14,23 +14,23 @@ test_expect_success "create some objects for testing diffs" '
14
mkdir foo &&
15
echo "stuff" > foo/bar &&
16
mkdir foo/baz &&
17
- A=$(ipfs add -r -q foo | tail -n1) &&
18
- AR=$(ipfs add --raw-leaves -r -q foo | tail -n1) &&
17
+ A=$(ipfs add -r -Q foo) &&
18
+ AR=$(ipfs add --raw-leaves -r -Q foo) &&
19
echo "more things" > foo/cat &&
20
- B=$(ipfs add -r -q foo | tail -n1) &&
21
- BR=$(ipfs add --raw-leaves -r -q foo | tail -n1) &&
20
+ B=$(ipfs add -r -Q foo) &&
21
+ BR=$(ipfs add --raw-leaves -r -Q foo) &&
22
echo "nested" > foo/baz/dog &&
23
- C=$(ipfs add -r -q foo | tail -n1)
24
- CR=$(ipfs add --raw-leaves -r -q foo | tail -n1)
23
+ C=$(ipfs add -r -Q foo)
24
+ CR=$(ipfs add --raw-leaves -r -Q foo)
25
echo "changed" > foo/bar &&
26
- D=$(ipfs add -r -q foo | tail -n1) &&
27
- DR=$(ipfs add --raw-leaves -r -q foo | tail -n1) &&
26
+ D=$(ipfs add -r -Q foo) &&
27
+ DR=$(ipfs add --raw-leaves -r -Q foo) &&
28
echo "" > single_file &&
29
- SINGLE_FILE=$(ipfs add -r -q single_file | tail -n1) &&
30
- SINGLE_FILE_RAW=$(ipfs add --raw-leaves -r -q single_file | tail -n1) &&
29
+ SINGLE_FILE=$(ipfs add -r -Q single_file) &&
30
+ SINGLE_FILE_RAW=$(ipfs add --raw-leaves -r -Q single_file) &&
31
mkdir empty_dir
32
- EMPTY_DIR=$(ipfs add -r -q empty_dir | tail -n1)
33
- EMPTY_DIR_RAW=$(ipfs add --raw-leaves -r -q empty_dir | tail -n1)
32
+ EMPTY_DIR=$(ipfs add -r -Q empty_dir)
33
+ EMPTY_DIR_RAW=$(ipfs add --raw-leaves -r -Q empty_dir)
34
'
35
36
test_expect_success "diff against self is empty" '
test/sharness/t0053-dag.sh
+1
-1
@@ -314,7 +314,7 @@ test_dag_cmd() {
314
315
test_expect_success "prepare dag-pb object" '
316
echo foo > test_file &&
317
- HASH=$(ipfs add -wq test_file | tail -n1 | ipfs cid base32)
317
+ HASH=$(ipfs add -wQ test_file | ipfs cid base32)
318
'
319
320
test_expect_success "dag put with json dag-pb works" '
test/sharness/t0080-repo.sh
+6
-9
@@ -175,11 +175,10 @@ test_expect_success "'ipfs refs --unique' is correct" '
175
mkdir -p uniques &&
176
echo "content1" > uniques/file1 &&
177
echo "content1" > uniques/file2 &&
178
- ipfs add -r -q uniques > add_output &&
179
- ROOT=$(tail -n1 add_output) &&
178
+ ROOT=$(ipfs add -r -Q uniques) &&
179
ipfs refs --unique $ROOT >expected &&
180
ipfs add -q uniques/file1 >unique_hash &&
182
- test_cmp expected unique_hash || test_fsh cat add_output
181
+ test_cmp expected unique_hash
182
'
183
184
test_expect_success "'ipfs refs --unique --recursive' is correct" '
@@ -188,12 +187,11 @@ test_expect_success "'ipfs refs --unique --recursive' is correct" '
187
echo "c1" > a/b/f1 &&
188
echo "c1" > a/b/c/f1 &&
189
echo "c2" > a/b/c/f2 &&
191
- ipfs add -r -q a >add_output &&
192
- ROOT=$(tail -n1 add_output) &&
190
+ ROOT=$(ipfs add -r -Q a) &&
191
ipfs refs --unique --recursive $ROOT >refs_output &&
192
wc -l refs_output | sed "s/^ *//g" >line_count &&
193
echo "4 refs_output" >expected &&
196
- test_cmp expected line_count || test_fsh cat add_output || test_fsh cat refs_output
194
+ test_cmp expected line_count || test_fsh cat refs_output
195
'
196
197
test_expect_success "'ipfs refs --recursive (bigger)'" '
@@ -207,12 +205,11 @@ test_expect_success "'ipfs refs --recursive (bigger)'" '
205
cp -r b b2 && mv b2 b/b2 &&
206
cp -r b b3 && mv b3 b/b3 &&
207
cp -r b b4 && mv b4 b/b4 &&
210
- ipfs add -r -q b >add_output &&
211
- hash=$(tail -n1 add_output) &&
208
+ hash=$(ipfs add -r -Q b) &&
209
ipfs refs -r "$hash" >refs_output &&
210
wc -l refs_output | sed "s/^ *//g" >actual &&
211
echo "79 refs_output" >expected &&
215
- test_cmp expected actual || test_fsh cat add_output || test_fsh cat refs_output
212
+ test_cmp expected actual || test_fsh cat refs_output
213
'
214
215
test_expect_success "'ipfs refs --unique --recursive (bigger)'" '
test/sharness/t0081-repo-pinning.sh
+6
-7
@@ -94,11 +94,10 @@ test_expect_success "'ipfs add dir' succeeds" '
94
echo "some text 6" >dir1/dir2/dir4/file6 &&
95
echo "some text 2" >dir1/dir3/file2 &&
96
echo "some text 5" >dir1/dir3/file5 &&
97
- ipfs add -q -r dir1 >actualall &&
98
- tail -n1 actualall >actual1 &&
99
- echo "$HASH_DIR1" >expected1 &&
97
+ ipfs add -Q -r dir1 >actual &&
98
+ echo "$HASH_DIR1" >expected &&
99
ipfs repo gc && # remove the patch chaff
101
- test_cmp expected1 actual1
100
+ test_cmp expected actual
101
'
102
103
test_expect_success "objects are there" '
@@ -265,9 +264,9 @@ test_expect_success "test add nopin dir" '
264
mkdir nopin_dir1 &&
265
echo "some nopin text 1" >nopin_dir1/file1 &&
266
echo "some nopin text 2" >nopin_dir1/file2 &&
268
- ipfs add -q -r --pin=false nopin_dir1 | tail -n1 >actual1 &&
269
- echo "$HASH_NOPINDIR" >expected1 &&
270
- test_cmp actual1 expected1 &&
267
+ ipfs add -Q -r --pin=false nopin_dir1 >actual &&
268
+ echo "$HASH_NOPINDIR" >expected &&
269
+ test_cmp actual expected &&
270
test_pin_flag "$HASH_NOPINDIR" direct false &&
271
test_pin_flag "$HASH_NOPINDIR" indirect false &&
272
test_pin_flag "$HASH_NOPINDIR" recursive false &&
test/sharness/t0090-get.sh
+1
-1
@@ -89,7 +89,7 @@ test_get_cmd() {
89
touch dir/a &&
90
mkdir -p dir/b &&
91
echo "Hello, Worlds!" >dir/b/c &&
92
- HASH2=`ipfs add -r -q dir | tail -n 1` &&
92
+ HASH2=`ipfs add -r -Q dir` &&
93
ipfs get "$HASH2" >actual
94
'
95
test/sharness/t0110-gateway.sh
+1
-1
@@ -167,7 +167,7 @@ test_expect_success "test failure conditions of mutex pprof endpoint" '
167
test_expect_success "setup index hash" '
168
mkdir index &&
169
echo "<p></p>" > index/index.html &&
170
- INDEXHASH=$(ipfs add -q -r index | tail -n1)
170
+ INDEXHASH=$(ipfs add -Q -r index)
171
echo index: $INDEXHASH
172
'
173
test/sharness/t0125-twonode.sh
+1
-1
@@ -46,7 +46,7 @@ run_random_dir_test() {
46
'
47
48
test_expect_success "add those on node 0" '
49
- DIR_HASH=$(ipfsi 0 add -r -q foobar | tail -n1)
49
+ DIR_HASH=$(ipfsi 0 add -r -Q foobar)
50
'
51
52
check_dir_fetch 1 $DIR_HASH
test/sharness/t0130-multinode.sh
+1
-1
@@ -50,7 +50,7 @@ run_random_dir_test() {
50
'
51
52
test_expect_success "add those on node 2" '
53
- DIR_HASH=$(ipfsi 2 add -r -q foobar | tail -n1)
53
+ DIR_HASH=$(ipfsi 2 add -r -Q foobar)
54
'
55
56
check_dir_fetch 0 $DIR_HASH
test/sharness/t0160-resolve.sh
+3
-3
@@ -9,9 +9,9 @@ test_init_ipfs
9
test_expect_success "resolve: prepare files" '
10
mkdir -p a/b &&
11
echo "a/b/c" >a/b/c &&
12
- a_hash=$(ipfs add -q -r a | tail -n1) &&
13
- b_hash=$(ipfs add -q -r a/b | tail -n1) &&
14
- c_hash=$(ipfs add -q -r a/b/c | tail -n1) &&
12
+ a_hash=$(ipfs add -Q -r a) &&
13
+ b_hash=$(ipfs add -Q -r a/b) &&
14
+ c_hash=$(ipfs add -Q -r a/b/c) &&
15
a_hash_b32=$(cid-fmt -v 1 -b b %s $a_hash) &&
16
b_hash_b32=$(cid-fmt -v 1 -b b %s $b_hash) &&
17
c_hash_b32=$(cid-fmt -v 1 -b b %s $c_hash)
test/sharness/t0175-reprovider.sh
+1
-1
@@ -86,7 +86,7 @@ test_expect_success 'add test objects' '
86
HASH_FOO=$(ipfsi 0 add -q --offline --pin=false f1) &&
87
HASH_BAR=$(ipfsi 0 add -q --offline --pin=false f2) &&
88
HASH_BAZ=$(ipfsi 0 add -q --offline f3) &&
89
- HASH_BAR_DIR=$(ipfsi 0 add -q --offline -w f2 | tail -1)
89
+ HASH_BAR_DIR=$(ipfsi 0 add -Q --offline -w f2)
90
'
91
92
findprovs_empty '$HASH_FOO'
test/sharness/t0250-files-api.sh
+1
-1
@@ -18,7 +18,7 @@ create_files() {
18
echo cats > stuff_test/a &&
19
echo dogs > stuff_test/b &&
20
echo giraffes > stuff_test/c &&
21
- DIR1=$(ipfs add -r "$@" -q stuff_test | tail -n1)
21
+ DIR1=$(ipfs add -r "$@" -Q stuff_test)
22
}
23
24
verify_path_exists() {
test/sharness/t0252-files-gc.sh
+1
-1
@@ -47,7 +47,7 @@ test_expect_success "add directory with direct pin" '
47
mkdir mydir/ &&
48
echo "hello world!" > mydir/hello.txt &&
49
FILE_UNPINNED=$(ipfs add --pin=false -q -r mydir/hello.txt) &&
50
- DIR_PINNED=$(ipfs add --pin=false -q -r mydir | tail -n1) &&
50
+ DIR_PINNED=$(ipfs add --pin=false -Q -r mydir) &&
51
ipfs add --pin=false -r mydir &&
52
ipfs pin add --recursive=false $DIR_PINNED &&
53
ipfs cat $FILE_UNPINNED
test/sharness/t0260-sharding.sh
+3
-3
@@ -19,7 +19,7 @@ test_expect_success "set up test data" '
19
test_add_large_dir() {
20
exphash="$1"
21
test_expect_success "ipfs add on very large directory succeeds" '
22
- ipfs add -r -q testdata | tail -n1 > sharddir_out &&
22
+ ipfs add -r -Q testdata > sharddir_out &&
23
echo "$exphash" > sharddir_exp &&
24
test_cmp sharddir_exp sharddir_out
25
'
@@ -96,7 +96,7 @@ test_kill_ipfs_daemon
96
test_add_large_dir_v1() {
97
exphash="$1"
98
test_expect_success "ipfs add (CIDv1) on very large directory succeeds" '
99
- ipfs add -r -q --cid-version=1 testdata | tail -n1 > sharddir_out &&
99
+ ipfs add -r -Q --cid-version=1 testdata > sharddir_out &&
100
echo "$exphash" > sharddir_exp &&
101
test_cmp sharddir_exp sharddir_out
102
'
@@ -119,7 +119,7 @@ test_kill_ipfs_daemon
119
120
test_list_incomplete_dir() {
121
test_expect_success "ipfs add (CIDv1) on very large directory with sha3 succeeds" '
122
- ipfs add -r -q --cid-version=1 --hash=sha3-256 --pin=false testdata | tail -n1 > sharddir_out &&
122
+ ipfs add -r -Q --cid-version=1 --hash=sha3-256 --pin=false testdata > sharddir_out &&
123
largeSHA3dir=$(cat sharddir_out)
124
'
125
test/sharness/t0270-filestore.sh
+1
-1
@@ -39,7 +39,7 @@ assert_repo_size_greater_than() {
39
40
test_filestore_adds() {
41
test_expect_success "nocopy add succeeds" '
42
- HASH=$(ipfs add --raw-leaves --nocopy -r -q somedir | tail -n1)
42
+ HASH=$(ipfs add --raw-leaves --nocopy -r -Q somedir)
43
'
44
45
test_expect_success "nocopy add has right hash" '
test/sharness/t0271-filestore-utils.sh
+1
-1
@@ -67,7 +67,7 @@ IPFS_CMD="ipfs"
67
68
test_filestore_adds() {
69
test_expect_success "$IPFS_CMD add nocopy add succeeds" '
70
- HASH=$($IPFS_CMD add --raw-leaves --nocopy -r -q somedir | tail -n1)
70
+ HASH=$($IPFS_CMD add --raw-leaves --nocopy -r -Q somedir)
71
'
72
73
test_expect_success "nocopy add has right hash" '