-
-
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
sharness: replace POSIX prereq with STD_ERR_MSG #2392
Conversation
Again "No output has been received in the last 10m0s, ..." errors with Travis on OSX. |
Actually there is also this error in the go tests:
|
@@ -45,7 +45,7 @@ test "$TEST_EXPENSIVE" = 1 && test_set_prereq EXPENSIVE | |||
test "$TEST_NO_DOCKER" != 1 && type docker && test_set_prereq DOCKER | |||
|
|||
TEST_OS=$(uname -s | tr [a-z] [A-Z]) | |||
test expr "$TEST_OS" : "CYGWIN_NT" >/dev/null && test_set_prereq POSIX | |||
expr "$TEST_OS" : "CYGWIN_NT" >/dev/null || test_set_prereq STD_ERR_MSG |
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.
Could we have a little comment here explaining what this does and why it's necessary?
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.
Nitpick 2: can we use a more specific name than STD_ERR_MSG
? It seems like this is being used to capture a very specific output difference.
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.
"not windows error message" basically. I think STD_ERR_MSG
is fine, could probably just add a comment about it
License: MIT Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
3758bb5
to
00e0340
Compare
test expr "$TEST_OS" : "CYGWIN_NT" >/dev/null && test_set_prereq POSIX | ||
|
||
# Set a prereq as error messages are often different on Windows/Cygwin | ||
expr "$TEST_OS" : "CYGWIN_NT" >/dev/null || test_set_prereq STD_ERR_MSG |
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.
Can we invert this to be more informative? Set CYGWIN_ERROR_MSGS
if we're on Windows+Cygwin?
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.
@noffle we could do that, but if we skip some tests we are more likely to skip tests on Windows/Cygwin or other non standard platforms, so a STD_ERR_MSG prereq is more likely to be useful than a CYGWIN_ERROR_MSGS prereq.
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.
"standard platform" is sort of a vague statement. If Cygwin is explicitly the special case, I'd much rather read a test that was concrete about why it was branching:
if test_have_prereq CYGWIN; then
init_err_msg="Error: mkdir $IPFS_PATH: The system cannot find the path specified."
else
init_err_msg="Error: failed to take lock at $IPFS_PATH: permission denied"
fi
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.
@noffle the idea is that outside Linux/MacOS the error messages can be very different.
Also testing error messages is not very useful and makes tests harder to port as we can see with Cygwin/Windows. Hence Git for example is not testing error messages much if at all.
If people start to port IPFS to exotic platforms, especially platforms where there is no tool like Travis or Appveyor that we can use online, it could be very difficult to add tests that check error messages, because they will fail on those exotic platform as people who have no access to these exotic platforms cannot know what the error message will be on those platforms.
So I think we should not try to be very picky about this, and having a STD_ERR_MSG prereq that we can easily stick to the tests that check error messages is the right tool.
I think I was even too zealous when I added this part:
+# Under Windows/Cygwin the error message is different,
+# so we use the STD_ERR_MSG prereq.
+if test_have_prereq STD_ERR_MSG; then
+ init_err_msg="Error: failed to take lock at $IPFS_PATH: permission denied"
+else
+ init_err_msg="Error: mkdir $IPFS_PATH: The system cannot find the path specified."
+fi
I should just have sticked STD_ERR_MSG to the test and be done with it. Now it's not a problem as long as people don't port to exotic platforms, so we can wait for that to happen and take another look at this at that time.
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.
@noffle about "standard"/"STD", I am ok with finding another name for that. Previously I used "POSIX", so perhaps "POSIX_ERR_MSG" is better, otherwise I am open to suggestions.
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 don't want to look for a FreeBSD system to test on right now, as I don't think many FreeBSD users have asked for help with running IPFS. And should we also find out for OpenBSD, NetBSD and so on?
This is exactly the point I'm trying to make: let's use LINUX_OR_OSX
because we don't know at this moment whether any other platforms give compatible error messages or not. Let's name things and act based on what behaviours we know, not what we suspect.
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.
(Sorry @chriscool not trying to bikeshed your work, I've just seen this pattern play out before where vague or inaccurate names for globals or config bits are chosen and people lose hours in the future.)
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.
So what about a name like "LINUX_LIKE_ERRORS"?
I think this is both more descriptive than "STD_ERR_MSG" and more future proof than "LINUX_OR_OSX".
Also I like that it is specific to errors because when differences are not specific to errors we should not use a prereq but instead do something like what we do in do_umount()
in "test-lib.sh":
do_umount() {
if [ "$(uname -s)" = "Linux" ]; then
fusermount -u "$1"
else
umount "$1"
fi
}
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.
Which platforms are "Linux-like" though? If we don't know and can't quantify it (are BSDs?), then we probably shouldn't claim that it's so.
Also I like that it is specific to errors because when differences are not specific to errors we should not use a prereq but instead do something like what we do in do_umount()
Agreed. Since these are just platforms checks ("are we NOT cygwin?"), let's just use if
statements like your example above. This prereq seems like an unnecessary semantic abstraction if all we're doing is wanting to know if we're on cygwin or not.
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.
Which platforms are "Linux-like" though? If we don't know and can't quantify it (are BSDs?), then we probably shouldn't claim that it's so.
As I see it, we are not claiming anything by calling a prereq "LINUX_LIKE_ERRORS". What do you think we are claiming?
If we later learn that another OS doesn't pass some tests that have this prereq, then we can just avoid setting this prereq when we are on this OS.
What I want is not just to know if we are on Cygwin or not. What I want is a way to easily avoid error message checking tests on platforms/OSes that give different error messages.
For example if the prereq is named NOT_CYGWIN and we later find that another OS, let say HAIKU also gives different error messages I don't want to have to add another NOT_HAIKU prereq to all the error checking tests.
Circle CI fails with:
|
@chriscool filed an issue for that failure here: #2400 It appears to be unrelated though, is this PR ready to go? |
@whyrusleeping please wait a bit more until hopefully the name issue is resolved. |
The naming discussion is non-blocking: please feel free to go ahead and merge if this is blocking other work or making CI redder than it need be. 👍 |
Yeah @whyrusleeping please merge this as is. |
sharness: replace POSIX prereq with STD_ERR_MSG
This fixes some previous mistakes I made and replaces PR #2368