Skip to content

Commit

Permalink
tests: just use the sha1sum implemented in Ruby
Browse files Browse the repository at this point in the history
The output of SHA1 command-line tools is too unstable and
I'm more comfortable with Ruby 1.9 encoding support than
I was in 2009.

Jeremy Evans noted the output of "openssl sha1" has
changed since I last used it.
  • Loading branch information
Eric Wong committed Nov 15, 2011
1 parent 2fd5910 commit c4c880c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
8 changes: 1 addition & 7 deletions t/bin/sha1sum.rb
@@ -1,12 +1,6 @@
#!/usr/bin/env ruby
# -*- encoding: binary -*-

# Reads from stdin and outputs the SHA1 hex digest of the input this is
# ONLY used as a last resort, our test code will try to use sha1sum(1),
# openssl(1), or gsha1sum(1) before falling back to using this. We try
# all options first because we have a strong and healthy distrust of our
# Ruby abilities in general, and *especially* when it comes to
# understanding (and trusting the implementation of) Ruby 1.9 encoding.
# Reads from stdin and outputs the SHA1 hex digest of the input

require 'digest/sha1'
$stdout.sync = $stderr.sync = true
Expand Down
8 changes: 1 addition & 7 deletions t/test-lib.sh
Expand Up @@ -100,11 +100,5 @@ unicorn_wait_start () {
}

rsha1 () {
_cmd="$(which sha1sum 2>/dev/null || :)"
test -n "$_cmd" || _cmd="$(which openssl 2>/dev/null || :) sha1"
test "$_cmd" != " sha1" || _cmd="$(which gsha1sum 2>/dev/null || :)"

# last resort, see comments in sha1sum.rb for reasoning
test -n "$_cmd" || _cmd=sha1sum.rb
expr "$($_cmd)" : '\([a-f0-9]\{40\}\)'
sha1sum.rb
}

0 comments on commit c4c880c

Please sign in to comment.