Add log of same files and sha1 hash of unique files to versionstest
authorTakayuki MATSUOKA <takayuki.matsuoka@gmail.com>
Fri, 15 May 2015 14:21:52 +0000 (23:21 +0900)
committerTakayuki MATSUOKA <takayuki.matsuoka@gmail.com>
Wed, 20 May 2015 10:59:33 +0000 (19:59 +0900)
test/test-lz4-versions.py

index b6ed126..f92fa96 100644 (file)
@@ -6,6 +6,7 @@ import filecmp
 import os
 import shutil
 import sys
+import hashlib
 
 repo_url = 'https://github.com/Cyan4973/lz4.git'
 tmp_dir_name = 'test/lz4test'
@@ -37,6 +38,11 @@ def get_git_tags():
     tags = stdout.decode('utf-8').split()
     return tags
 
+# http://stackoverflow.com/a/19711609/2132223
+def sha1_of_file(filepath):
+    with open(filepath, 'rb') as f:
+        return hashlib.sha1(f.read()).hexdigest()
+
 if __name__ == '__main__':
     error_code = 0
     base_dir = os.getcwd() + '/..'           # /path/to/lz4
@@ -102,6 +108,7 @@ if __name__ == '__main__':
                 continue
             if filecmp.cmp(lz4, lz4t):
                 os.remove(lz4t)
+                print('{} == {}'.format(lz4, lz4t))
 
     print('Enumerate only different compressed files')
     lz4s = sorted(glob.glob('*.lz4'))
@@ -128,6 +135,10 @@ if __name__ == '__main__':
         else:
             os.remove(dec)
 
+    lz4s = sorted(glob.glob('*.lz4'))
+    for lz4 in lz4s:
+        print('{}   {}'.format(sha1_of_file(lz4), lz4))
+
     if error_code != 0:
         print('ERROR')