-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: fix "invert" commands in sharness tests #9652
base: master
Are you sure you want to change the base?
Conversation
@guseggert From your work on sharness tests, could you advise which tests we should investigate more? And which we'll drop soon? I'm quite confident with the fix on t0118 because it reveals an error, so I know the new test is correct, |
95a63f1
to
13c0a29
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@laurentsenta is this still something you want to do? If so, I think below miss &&
, and that is why error produces false-positive.
I'll update this PR. @lidel I think we still want to finish these, and maybe forbid the use of the The tests here used echo "A\nB\nERROR" | grep -v "ERROR"
echo $? # success because A anb B matches the regexp. |
13c0a29
to
9c12716
Compare
3251f6f
to
e5400f7
Compare
test/sharness/t0140-swarm.sh
Outdated
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kept it but that //
looks like a typo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch! Yes, it looks like copy&paste bug of sorts 🙈
Anyway, the test was broken because after #8177 we should test both addresses added via Announce
and AppendAnnounce
(so we need two specimens):
-noAnnounceCfg='["/ip4/1.2.3.4/tcp/1234"]'
+noAnnounceCfg='["/ip4/1.2.3.4/tcp/1234", "/ip4/10.20.30.40/tcp/4321"]'
Local test passed because other code filtered out non-LAN addr, but second one would fail, if we had no typo 🤯
I've pushed fix in 038e56d and should be green now 🤞
bab2d7d
to
f22738e
Compare
@laurentsenta yes, banning use of |
Many tests assume that
grep --invert-match "X" FILE
meansBut the command actually means:
Which is wrong in most cases.
test_should_not_contain
instead.grep -v
, it's confusing maintainers.Example:
kubo/test/sharness/t0140-swarm.sh
Lines 95 to 109 in 3bcc89b
Test's Intent:
"/ip4/1.2.3.4/tcp/1234"
to the listNoAnnounce
,But the command
grep -v "/ip4/1.2.3.4/tcp/1234" actual
succeeds even if the file contains/ip4/1.2.3.4/tcp/1234
:Which means that the assertion is a no-op.
suspects matching
ack -l 'grep.*-v'
:Relates to #9651