From df2d1c77ae13f09f2dd941638cf44ecdda9938d8 Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Mon, 9 Jun 2025 15:50:59 +0200 Subject: [PATCH] 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 Co-authored-by: Andrew Gillis <11790789+gammazero@users.noreply.github.com> --- test/sharness/t0046-id-hash.sh | 6 ++++-- test/sharness/t0060-daemon.sh | 2 +- test/sharness/t0080-repo.sh | 12 ++++++------ test/sharness/t0140-swarm.sh | 30 +++++++++++++++--------------- 4 files changed, 26 insertions(+), 24 deletions(-) diff --git a/test/sharness/t0046-id-hash.sh b/test/sharness/t0046-id-hash.sh index 7dfc73d09..878b7228d 100755 --- a/test/sharness/t0046-id-hash.sh +++ b/test/sharness/t0046-id-hash.sh @@ -25,7 +25,8 @@ test_expect_success "ipfs add succeeds with identity hash" ' ' test_expect_success "content not actually added" ' - ipfs refs local | fgrep -q -v $HASH + ipfs refs local > locals && + test_should_not_contain $HASH locals ' test_expect_success "but can fetch it anyway" ' @@ -98,7 +99,8 @@ test_expect_success "ipfs add succeeds with identity hash and --nocopy" ' ' test_expect_success "content not actually added (filestore enabled)" ' - ipfs refs local | fgrep -q -v $HASH + ipfs refs local > locals && + test_should_not_contain $HASH locals ' test_expect_success "but can fetch it anyway (filestore enabled)" ' diff --git a/test/sharness/t0060-daemon.sh b/test/sharness/t0060-daemon.sh index 5dbbd852f..a160a8988 100755 --- a/test/sharness/t0060-daemon.sh +++ b/test/sharness/t0060-daemon.sh @@ -195,7 +195,7 @@ TEST_ULIMIT_PRESET=1 test_launch_ipfs_daemon test_expect_success "daemon raised its fd limit" ' - grep -v "setting file descriptor limit" actual_daemon > /dev/null + test_should_not_contain "setting file descriptor limit" actual_daemon ' test_expect_success "daemon actually can handle 2048 file descriptors" ' diff --git a/test/sharness/t0080-repo.sh b/test/sharness/t0080-repo.sh index 5031af830..1059e8b93 100755 --- a/test/sharness/t0080-repo.sh +++ b/test/sharness/t0080-repo.sh @@ -30,7 +30,7 @@ test_expect_success "'ipfs repo gc' succeeds" ' ' test_expect_success "'ipfs repo gc' looks good (patch root)" ' - grep -v "removed $HASH" gc_out_actual + test_should_not_contain "removed $HASH" gc_out_actual ' test_expect_success "'ipfs repo gc' doesn't remove file" ' @@ -284,11 +284,11 @@ test_expect_success "'ipfs repo stat --size-only' succeeds" ' ' test_expect_success "repo stats came out correct for --size-only" ' - grep "RepoSize" repo-stats-size-only && - grep "StorageMax" repo-stats-size-only && - grep -v "RepoPath" repo-stats-size-only && - grep -v "NumObjects" repo-stats-size-only && - grep -v "Version" repo-stats-size-only + test_should_contain "RepoSize" repo-stats-size-only && + test_should_contain "StorageMax" repo-stats-size-only && + test_should_not_contain "RepoPath" repo-stats-size-only && + test_should_not_contain "NumObjects" repo-stats-size-only && + test_should_not_contain "Version" repo-stats-size-only ' test_expect_success "'ipfs repo version' succeeds" ' diff --git a/test/sharness/t0140-swarm.sh b/test/sharness/t0140-swarm.sh index d65831d3e..37bb44b64 100755 --- a/test/sharness/t0140-swarm.sh +++ b/test/sharness/t0140-swarm.sh @@ -58,9 +58,9 @@ test_launch_ipfs_daemon test_expect_success 'Addresses.Announce affects addresses' ' ipfs swarm addrs local >actual && - grep "/ip4/1.2.3.4/tcp/1234" actual && + test_should_contain "/ip4/1.2.3.4/tcp/1234" actual && ipfs id -f"" | xargs -n1 echo >actual && - grep "/ip4/1.2.3.4/tcp/1234" actual + test_should_contain "/ip4/1.2.3.4/tcp/1234" actual ' test_kill_ipfs_daemon @@ -81,18 +81,18 @@ test_launch_ipfs_daemon test_expect_success 'Addresses.AppendAnnounce is applied on top of Announce' ' ipfs swarm addrs local >actual && - grep "/ip4/1.2.3.4/tcp/1234" actual && - grep "/dnsaddr/dynamic.example.com" actual && - grep "/ip4/10.20.30.40/tcp/4321" actual && + test_should_contain "/ip4/1.2.3.4/tcp/1234" actual && + test_should_contain "/dnsaddr/dynamic.example.com" actual && + test_should_contain "/ip4/10.20.30.40/tcp/4321" actual && ipfs id -f"" | xargs -n1 echo | tee actual && - grep "/ip4/1.2.3.4/tcp/1234/p2p" actual && - grep "/dnsaddr/dynamic.example.com/p2p/" actual && - grep "/ip4/10.20.30.40/tcp/4321/p2p/" actual + test_should_contain "/ip4/1.2.3.4/tcp/1234/p2p" actual && + test_should_contain "/dnsaddr/dynamic.example.com/p2p/" actual && + test_should_contain "/ip4/10.20.30.40/tcp/4321/p2p/" actual ' test_kill_ipfs_daemon -noAnnounceCfg='["/ip4/1.2.3.4/tcp/1234"]' +noAnnounceCfg='["/ip4/1.2.3.4/tcp/1234", "/ip4/10.20.30.40/tcp/4321"]' test_expect_success "test_config_set succeeds" " ipfs config --json Addresses.NoAnnounce '$noAnnounceCfg' " @@ -101,11 +101,11 @@ test_launch_ipfs_daemon test_expect_success "Addresses.NoAnnounce affects addresses from Announce and AppendAnnounce" ' ipfs swarm addrs local >actual && - grep -v "/ip4/1.2.3.4/tcp/1234" actual && - grep -v "/ip4/10.20.30.40/tcp/4321" actual && + test_should_not_contain "/ip4/1.2.3.4/tcp/1234" actual && + test_should_not_contain "/ip4/10.20.30.40/tcp/4321" actual && ipfs id -f"" | xargs -n1 echo >actual && - grep -v "/ip4/1.2.3.4/tcp/1234" actual && - grep -v "//ip4/10.20.30.40/tcp/4321" actual + test_should_not_contain "/ip4/1.2.3.4/tcp/1234" actual && + test_should_not_contain "/ip4/10.20.30.40/tcp/4321" actual ' test_kill_ipfs_daemon @@ -119,9 +119,9 @@ test_launch_ipfs_daemon test_expect_success "Addresses.NoAnnounce with /ipcidr affects addresses" ' ipfs swarm addrs local >actual && - grep -v "/ip4/1.2.3.4/tcp/1234" actual && + test_should_not_contain "/ip4/1.2.3.4/tcp/1234" actual && ipfs id -f"" | xargs -n1 echo >actual && - grep -v "/ip4/1.2.3.4/tcp/1234" actual + test_should_not_contain "/ip4/1.2.3.4/tcp/1234" actual ' test_kill_ipfs_daemon