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 <lidel@lidel.org> Co-authored-by: Andrew Gillis <11790789+gammazero@users.noreply.github.com>
Laurent Senta committed
Jun 9, 2025 at 15:50 UTC
df2d1c77ae13f09f2dd941638cf44ecdda9938d8
4 files changed
+26
-24
test/sharness/t0046-id-hash.sh
+4
-2
@@ -25,7 +25,8 @@ test_expect_success "ipfs add succeeds with identity hash" '
25
'
26
27
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
30
'
31
32
test_expect_success "but can fetch it anyway" '
@@ -98,7 +99,8 @@ test_expect_success "ipfs add succeeds with identity hash and --nocopy" '
99
'
100
101
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
104
'
105
106
test_expect_success "but can fetch it anyway (filestore enabled)" '
test/sharness/t0060-daemon.sh
+1
-1
@@ -195,7 +195,7 @@ TEST_ULIMIT_PRESET=1
195
test_launch_ipfs_daemon
196
197
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
199
'
200
201
test_expect_success "daemon actually can handle 2048 file descriptors" '
test/sharness/t0080-repo.sh
+6
-6
@@ -30,7 +30,7 @@ test_expect_success "'ipfs repo gc' succeeds" '
30
'
31
32
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
34
'
35
36
test_expect_success "'ipfs repo gc' doesn't remove file" '
@@ -284,11 +284,11 @@ test_expect_success "'ipfs repo stat --size-only' succeeds" '
284
'
285
286
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
292
'
293
294
test_expect_success "'ipfs repo version' succeeds" '
test/sharness/t0140-swarm.sh
+15
-15
@@ -58,9 +58,9 @@ test_launch_ipfs_daemon
58
59
test_expect_success 'Addresses.Announce affects addresses' '
60
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 &&
62
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
64
'
65
66
test_kill_ipfs_daemon
@@ -81,18 +81,18 @@ test_launch_ipfs_daemon
81
82
test_expect_success 'Addresses.AppendAnnounce is applied on top of Announce' '
83
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 &&
87
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
91
'
92
93
test_kill_ipfs_daemon
94
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"]'
96
test_expect_success "test_config_set succeeds" "
97
ipfs config --json Addresses.NoAnnounce '$noAnnounceCfg'
98
"
@@ -101,11 +101,11 @@ test_launch_ipfs_daemon
101
102
test_expect_success "Addresses.NoAnnounce affects addresses from Announce and AppendAnnounce" '
103
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 &&
106
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
109
'
110
111
test_kill_ipfs_daemon
@@ -119,9 +119,9 @@ test_launch_ipfs_daemon
119
120
test_expect_success "Addresses.NoAnnounce with /ipcidr affects addresses" '
121
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 &&
123
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
125
'
126
127
test_kill_ipfs_daemon