Skip to content

Commit df2d1c7

Browse files
laurentsentalidelgammazero
authored
test: fix "invert" commands in sharness tests (#9652)
* test: fix the grep in t0046 * test: fix grep -v in t0140 * test: Addresses.NoAnnounce overides AppendAnnounce * fix t0080-repo.sh * fix t0060.sh --------- Co-authored-by: Marcin Rataj <[email protected]> Co-authored-by: Andrew Gillis <[email protected]>
1 parent 4dd0990 commit df2d1c7

File tree

4 files changed

+26
-24
lines changed

4 files changed

+26
-24
lines changed

test/sharness/t0046-id-hash.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ test_expect_success "ipfs add succeeds with identity hash" '
2525
'
2626

2727
test_expect_success "content not actually added" '
28-
ipfs refs local | fgrep -q -v $HASH
28+
ipfs refs local > locals &&
29+
test_should_not_contain $HASH locals
2930
'
3031

3132
test_expect_success "but can fetch it anyway" '
@@ -98,7 +99,8 @@ test_expect_success "ipfs add succeeds with identity hash and --nocopy" '
9899
'
99100

100101
test_expect_success "content not actually added (filestore enabled)" '
101-
ipfs refs local | fgrep -q -v $HASH
102+
ipfs refs local > locals &&
103+
test_should_not_contain $HASH locals
102104
'
103105

104106
test_expect_success "but can fetch it anyway (filestore enabled)" '

test/sharness/t0060-daemon.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ TEST_ULIMIT_PRESET=1
195195
test_launch_ipfs_daemon
196196

197197
test_expect_success "daemon raised its fd limit" '
198-
grep -v "setting file descriptor limit" actual_daemon > /dev/null
198+
test_should_not_contain "setting file descriptor limit" actual_daemon
199199
'
200200

201201
test_expect_success "daemon actually can handle 2048 file descriptors" '

test/sharness/t0080-repo.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ test_expect_success "'ipfs repo gc' succeeds" '
3030
'
3131

3232
test_expect_success "'ipfs repo gc' looks good (patch root)" '
33-
grep -v "removed $HASH" gc_out_actual
33+
test_should_not_contain "removed $HASH" gc_out_actual
3434
'
3535

3636
test_expect_success "'ipfs repo gc' doesn't remove file" '
@@ -284,11 +284,11 @@ test_expect_success "'ipfs repo stat --size-only' succeeds" '
284284
'
285285

286286
test_expect_success "repo stats came out correct for --size-only" '
287-
grep "RepoSize" repo-stats-size-only &&
288-
grep "StorageMax" repo-stats-size-only &&
289-
grep -v "RepoPath" repo-stats-size-only &&
290-
grep -v "NumObjects" repo-stats-size-only &&
291-
grep -v "Version" repo-stats-size-only
287+
test_should_contain "RepoSize" repo-stats-size-only &&
288+
test_should_contain "StorageMax" repo-stats-size-only &&
289+
test_should_not_contain "RepoPath" repo-stats-size-only &&
290+
test_should_not_contain "NumObjects" repo-stats-size-only &&
291+
test_should_not_contain "Version" repo-stats-size-only
292292
'
293293

294294
test_expect_success "'ipfs repo version' succeeds" '

test/sharness/t0140-swarm.sh

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ test_launch_ipfs_daemon
5858

5959
test_expect_success 'Addresses.Announce affects addresses' '
6060
ipfs swarm addrs local >actual &&
61-
grep "/ip4/1.2.3.4/tcp/1234" actual &&
61+
test_should_contain "/ip4/1.2.3.4/tcp/1234" actual &&
6262
ipfs id -f"<addrs>" | xargs -n1 echo >actual &&
63-
grep "/ip4/1.2.3.4/tcp/1234" actual
63+
test_should_contain "/ip4/1.2.3.4/tcp/1234" actual
6464
'
6565

6666
test_kill_ipfs_daemon
@@ -81,18 +81,18 @@ test_launch_ipfs_daemon
8181

8282
test_expect_success 'Addresses.AppendAnnounce is applied on top of Announce' '
8383
ipfs swarm addrs local >actual &&
84-
grep "/ip4/1.2.3.4/tcp/1234" actual &&
85-
grep "/dnsaddr/dynamic.example.com" actual &&
86-
grep "/ip4/10.20.30.40/tcp/4321" actual &&
84+
test_should_contain "/ip4/1.2.3.4/tcp/1234" actual &&
85+
test_should_contain "/dnsaddr/dynamic.example.com" actual &&
86+
test_should_contain "/ip4/10.20.30.40/tcp/4321" actual &&
8787
ipfs id -f"<addrs>" | xargs -n1 echo | tee actual &&
88-
grep "/ip4/1.2.3.4/tcp/1234/p2p" actual &&
89-
grep "/dnsaddr/dynamic.example.com/p2p/" actual &&
90-
grep "/ip4/10.20.30.40/tcp/4321/p2p/" actual
88+
test_should_contain "/ip4/1.2.3.4/tcp/1234/p2p" actual &&
89+
test_should_contain "/dnsaddr/dynamic.example.com/p2p/" actual &&
90+
test_should_contain "/ip4/10.20.30.40/tcp/4321/p2p/" actual
9191
'
9292

9393
test_kill_ipfs_daemon
9494

95-
noAnnounceCfg='["/ip4/1.2.3.4/tcp/1234"]'
95+
noAnnounceCfg='["/ip4/1.2.3.4/tcp/1234", "/ip4/10.20.30.40/tcp/4321"]'
9696
test_expect_success "test_config_set succeeds" "
9797
ipfs config --json Addresses.NoAnnounce '$noAnnounceCfg'
9898
"
@@ -101,11 +101,11 @@ test_launch_ipfs_daemon
101101

102102
test_expect_success "Addresses.NoAnnounce affects addresses from Announce and AppendAnnounce" '
103103
ipfs swarm addrs local >actual &&
104-
grep -v "/ip4/1.2.3.4/tcp/1234" actual &&
105-
grep -v "/ip4/10.20.30.40/tcp/4321" actual &&
104+
test_should_not_contain "/ip4/1.2.3.4/tcp/1234" actual &&
105+
test_should_not_contain "/ip4/10.20.30.40/tcp/4321" actual &&
106106
ipfs id -f"<addrs>" | xargs -n1 echo >actual &&
107-
grep -v "/ip4/1.2.3.4/tcp/1234" actual &&
108-
grep -v "//ip4/10.20.30.40/tcp/4321" actual
107+
test_should_not_contain "/ip4/1.2.3.4/tcp/1234" actual &&
108+
test_should_not_contain "/ip4/10.20.30.40/tcp/4321" actual
109109
'
110110

111111
test_kill_ipfs_daemon
@@ -119,9 +119,9 @@ test_launch_ipfs_daemon
119119

120120
test_expect_success "Addresses.NoAnnounce with /ipcidr affects addresses" '
121121
ipfs swarm addrs local >actual &&
122-
grep -v "/ip4/1.2.3.4/tcp/1234" actual &&
122+
test_should_not_contain "/ip4/1.2.3.4/tcp/1234" actual &&
123123
ipfs id -f"<addrs>" | xargs -n1 echo >actual &&
124-
grep -v "/ip4/1.2.3.4/tcp/1234" actual
124+
test_should_not_contain "/ip4/1.2.3.4/tcp/1234" actual
125125
'
126126

127127
test_kill_ipfs_daemon

0 commit comments

Comments
 (0)