Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Commit

Permalink
don't swallow errors when testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Grosse committed Oct 7, 2016
1 parent 53caf1c commit de42c6e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
3 changes: 1 addition & 2 deletions enjarify/hashtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@

for bits in range(256):
opts = options.Options(*[bool(bits & (1 << b)) for b in range(8)])
classes, errors = translate(rawdex, opts=opts)
assert not errors
classes, errors = translate(rawdex, opts=opts, allowErrors=False)

for cls in classes.values():
print('{:08b}'.format(bits), hashlib.sha256(cls).hexdigest())
Expand Down
4 changes: 3 additions & 1 deletion enjarify/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def read(fname, mode='rb'):
with open(fname, mode) as f:
return f.read()

def translate(data, opts, classes=None, errors=None):
def translate(data, opts, classes=None, errors=None, allowErrors=True):
dex = parsedex.DexFile(data)
classes = collections.OrderedDict() if classes is None else classes
errors = collections.OrderedDict() if errors is None else errors
Expand All @@ -38,6 +38,8 @@ def translate(data, opts, classes=None, errors=None):
class_data = writeclass.toClassFile(cls, opts)
classes[unicode_name] = class_data
except Exception:
if not allowErrors:
raise
errors[unicode_name] = traceback.format_exc()

if not (len(classes) + len(errors)) % 1000:
Expand Down
3 changes: 1 addition & 2 deletions enjarify/runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ def executeTest(name, opts):
print('running test', name)
dir = os.path.join('tests', name)
rawdex = read(os.path.join(dir, 'classes.dex'), 'rb')
classes, errors = translate(rawdex, opts=opts)
assert not errors
classes, errors = translate(rawdex, opts=opts, allowErrors=False)

classes.update(STUB_FILES)
writeToJar('out.jar', classes)
Expand Down

0 comments on commit de42c6e

Please sign in to comment.