tests: use centralize MD5 generation functions

This commit is contained in:
Moritz Bunkus 2021-07-06 14:48:39 +02:00
parent b0bbcc7a87
commit 0a96f4a19b
No known key found for this signature in database
GPG Key ID: 74AF00ADF2E32C85
2 changed files with 5 additions and 22 deletions

View File

@ -10,19 +10,6 @@ class Test
@tmp_num_mutex = Mutex.new
@commands = Array.new
@debug_commands = Array.new
# install md5 handler
if $is_macos
@md5 = lambda do |name|
@debug_commands << "/sbin/md5 #{name}"
`/sbin/md5 #{name}`.chomp.gsub(/.*=\s*/, "")
end
else
@md5 = lambda do |name|
@debug_commands << "md5sum #{name}"
`md5sum #{name}`.chomp.gsub(/\s+.*/, "")
end
end
end
def description
@ -90,7 +77,7 @@ class Test
end
def hash_file(name)
@md5.call name
md5 name
end
def hash_tmp(erase = true)

View File

@ -41,14 +41,10 @@ class String
end
end
# install md5 handler
if $is_macos
def md5 name
`/sbin/md5 #{name}`.chomp.gsub(/.*=\s*/, "")
end
else
def md5 name
`md5sum #{name}`.chomp.gsub(/\s+.*/, "")
def md5 name
case
when $is_macos then `/sbin/md5 #{name}`.chomp.gsub(/.*=\s*/, "")
else `md5sum #{name}`.chomp.gsub(/\s+.*/, "")
end
end