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
DM-13608: Do not rely on locale when using diff #80
Conversation
1375d6d
to
3527143
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.
It isn't clear on the ticket exactly what the problem is or why setting LANG resolves it. I'm guessing that diff is responding to the locale rather than curl. Either way, it would be fanatic to add a unit test to https://github.com/lsst/lsst/blob/master/spec/unit/n8l/up2date_check_spec.rb that demonstrates the problem by setting LANG to a value that reproduces the failure.
You usually see problems with LANG != C on non-ascii systems. It's always safer to set LANG=C, and we should just go ahead and do so.
I don't think it's worth the time to generate a test.
|
It is rather poor practice to use Regardless, a trivial unit test will prevent a future regression. |
Please write the unit test if it matters to you.
|
We spent a long time trying to write a test that would force diff to not use the word "differ" in the output but we failed. We even rebooted the mac into Italian and explicitly set |
@josh, it's not unicode that's the problem, it's that the message from |
If the message is different then we should fix the code to use an exit status (cmp can do that, can't diff?) rather than setting LANG (or the locale). I imagine that I can get you access to a machine that illustrates the problem.
|
@timj I completely agree with @PaulPrice's suggestion but that doesn't mean that there should not be a unit test that demonstrates there is no breakage in various locales, which would be useful regardless of how the check is implemented. At present, I don't see any explanation on how to even reproduce the problem. The comment on unicode locales was just an FYI. |
As I said, we tried to reproduce the problem but couldn't (and after an hour at it I decided it we were wasting our time -- Italian menus were interesting though). If you know what incantation is needed to trigger the issue on travis that would be great. |
@jhoblitt why is the code checking the string value from that command? I just checked and |
@jhoblitt can you think of a reason why we can't check |
@gcomoretto the new version is failing the test suite because one of the tests does an exact match on the warning message contents and for some reason the test is no longer triggering the message: |
@timj I'm not the author of that check, I merely preserved the original logic while trying to chop up the original script into a collection of smaller, hopefully testable, functions. I don't have any objection to testing for the exit status. |
@jhoblitt can you help out @gcomoretto with the ruby test code that's failing? We are trying to work out whether the ruby test is looking explicitly for "differ" which no longer appears. Thanks. |
scripts/newinstall.sh
Outdated
@@ -501,15 +501,24 @@ n8l::up2date_check() { | |||
set +e | |||
|
|||
local amidiff | |||
amidiff=$($CURL "$CURL_OPTS" -L "$NEWINSTALL_URL" | diff --brief - "$0") | |||
diff --brief "$0" <($CURL "$CURL_OPTS" -L "$NEWINSTALL_URL") > /dev/null |
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.
whitespace?
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, I corrected the missing tab. However I need some support for the ruby script.
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.
Sure, I'll take a look.
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.
Thank you very much
I've added a commit to the PR branch that updates the the rspec unit tests.
Assuming travis passes, this looks ready to merge but the commits probably should be squashed and the original commit message updated. |
d70d15a
to
a7d2b64
Compare
I rebased the PR on current master after the merge of #81 . |
a7d2b64
to
6d819ee
Compare
String output change with locale, using the exit status is more robust and easy to unit test.
6d819ee
to
827d387
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.
LGTM. Thanks for sticking with it.
Not tested locally, need to be verified by the originator of the issue.
@RobertLuptonTheGood can you please verify if it works.