Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1609)

Unified Diff: mojo/tools/mopy/transitive_hash.py

Issue 718773002: Make mojob.py test succeed on Windows. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: mojo/tools/mopy/transitive_hash.py
diff --git a/mojo/tools/mopy/transitive_hash.py b/mojo/tools/mopy/transitive_hash.py
index 6864ae394dcd14e866c80b590037459b7af993aa..48b6a60b21898fafd36a8c5a7bd41ef18168a3fb 100644
--- a/mojo/tools/mopy/transitive_hash.py
+++ b/mojo/tools/mopy/transitive_hash.py
@@ -2,7 +2,9 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import hashlib
import logging
+import platform
import subprocess
import sys
@@ -27,16 +29,26 @@ def _memoize(f):
return Memoize().__getitem__
@_memoize
-def _file_hash(filename):
- """Returns a string representing the hash of the given file."""
- _logging.debug("Hashing %s ...", filename)
- rv = subprocess.check_output(['sha256sum', '-b', filename]).split(None, 1)[0]
- _logging.debug(" => %s", rv)
- return rv
+def _file_hash(filename):
+ """Returns a string representing the hash of the given file."""
+ _logging.debug("Hashing %s ...", filename)
+ with open(filename, mode='rb') as f:
+ m = hashlib.sha256()
+ while True:
+ block = f.read(4096)
+ if not block:
+ break
+ m.update(block)
+ _logging.debug(" => %s", m.hexdigest())
+ return m.hexdigest()
@_memoize
def _get_dependencies(filename):
"""Returns a list of filenames for files that the given file depends on."""
+ if platform.system() == 'Windows':
+ # There's no ldd on Windows. We can try to bundle or require depends, but
+ # given that we're not supporting component build this seems low priority.
+ return []
_logging.debug("Getting dependencies for %s ...", filename)
lines = subprocess.check_output(['ldd', filename]).splitlines()
rv = []
« mojo/tools/mojob.py ('K') | « mojo/tools/mojob.py ('k') | mojo/tools/test_runner.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698