diff options
author | chriseth <chris@ethereum.org> | 2018-07-10 04:47:34 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-10 04:47:34 +0800 |
commit | f6edb7fb8f3f86f527d20bbe7b0e55d2c560ba90 (patch) | |
tree | 4a8a67ee71e946258c802daf684014bdac1fff66 /scripts | |
parent | ab99893396f9f237d40af1417723c9e83b9291d5 (diff) | |
parent | 5640eba3827c56d1865f8643505714c4afaff1e3 (diff) | |
download | dexon-solidity-f6edb7fb8f3f86f527d20bbe7b0e55d2c560ba90.tar.gz dexon-solidity-f6edb7fb8f3f86f527d20bbe7b0e55d2c560ba90.tar.zst dexon-solidity-f6edb7fb8f3f86f527d20bbe7b0e55d2c560ba90.zip |
Merge pull request #4434 from mattaereal/patch-4
Update isolate_tests.py
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/isolate_tests.py | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/scripts/isolate_tests.py b/scripts/isolate_tests.py index 82dff1e0..1f913504 100755 --- a/scripts/isolate_tests.py +++ b/scripts/isolate_tests.py @@ -10,7 +10,7 @@ import sys import re import os import hashlib -from os.path import join +from os.path import join, isfile def extract_test_cases(path): lines = open(path, 'rb').read().splitlines() @@ -77,24 +77,31 @@ def write_cases(tests): for test in tests: open('test_%s.sol' % hashlib.sha256(test).hexdigest(), 'wb').write(test) + +def extract_and_write(f, path): + if docs: + cases = extract_docs_cases(path) + else: + if f.endswith('.sol'): + cases = [open(path, 'r').read()] + else: + cases = extract_test_cases(path) + write_cases(cases) + if __name__ == '__main__': path = sys.argv[1] docs = False if len(sys.argv) > 2 and sys.argv[2] == 'docs': docs = True - for root, subdirs, files in os.walk(path): - if '_build' in subdirs: - subdirs.remove('_build') - if 'compilationTests' in subdirs: - subdirs.remove('compilationTests') - for f in files: - path = join(root, f) - if docs: - cases = extract_docs_cases(path) - else: - if f.endswith(".sol"): - cases = [open(path, "r").read()] - else: - cases = extract_test_cases(path) - write_cases(cases) + if isfile(path): + extract_and_write(path, path) + else: + for root, subdirs, files in os.walk(path): + if '_build' in subdirs: + subdirs.remove('_build') + if 'compilationTests' in subdirs: + subdirs.remove('compilationTests') + for f in files: + path = join(root, f) + extract_and_write(f, path) |