Skip to content

Commit

Permalink
Merge pull request #80 from lsst/tickets/DM-13608
Browse files Browse the repository at this point in the history
DM-13608: Do not rely on locale when using diff
  • Loading branch information
gcomoretto committed Mar 1, 2018
2 parents 4c2273e + 827d387 commit ee511c3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
13 changes: 11 additions & 2 deletions scripts/newinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
amidiff=$?

if [[ $amidiff == *differ ]]; then
if [[ $amidiff = 1 ]] ; then
n8l::print_error "$(cat <<-EOF
!!! This script differs from the official version on the distribution
server. If this is not intentional, get the current version from here:
${NEWINSTALL_URL}
EOF
)"
else
if [[ $amidiff != 0 ]] ; then
n8l::print_error "$(cat <<-EOF
!!! There is an error in comparing the official version with the local
copy of the script.
EOF
)"
fi
fi

set -e
Expand Down
22 changes: 19 additions & 3 deletions spec/unit/n8l/up2date_check_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

context 'script matches master' do
it 'prints nothing' do
stubbed_env.stub_command('diff').outputs('notta')
stubbed_env.stub_command('diff').returns_exitstatus(0)

out, err, status = stubbed_env.execute_function(
'scripts/newinstall.sh',
Expand All @@ -24,7 +24,7 @@

context 'script out of sync with master' do
it 'prints a non-fatal warning' do
stubbed_env.stub_command('diff').outputs('differ')
stubbed_env.stub_command('diff').returns_exitstatus(1)

out, err, status = stubbed_env.execute_function(
'scripts/newinstall.sh',
Expand All @@ -36,5 +36,21 @@
expect(out).to eq('')
expect(err).to match(/This script differs from the official version/)
end
end # script matches master
end # script out of sync with master

context 'unknown error comparing source against master' do
it 'prints a non-fatal warning' do
stubbed_env.stub_command('diff').returns_exitstatus(2)

out, err, status = stubbed_env.execute_function(
'scripts/newinstall.sh',
func,
{ 'CURL' => 'true' },
)

expect(status.exitstatus).to be 0
expect(out).to eq('')
expect(err).to match(/There is an error in comparing/)
end
end # unknown error comparing source against master
end

0 comments on commit ee511c3

Please sign in to comment.