diff options
author | chriseth <chris@ethereum.org> | 2017-03-23 03:19:20 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2017-03-23 16:56:17 +0800 |
commit | b18aea315d2e5c12ff6aa7cbf24d559e0523e778 (patch) | |
tree | ddd5d94ce3ae8cca9faadbd1cbae2148851cfadd /scripts | |
parent | b28aefe28c183b307b162cea1536f3027a780952 (diff) | |
download | dexon-solidity-b18aea315d2e5c12ff6aa7cbf24d559e0523e778.tar dexon-solidity-b18aea315d2e5c12ff6aa7cbf24d559e0523e778.tar.gz dexon-solidity-b18aea315d2e5c12ff6aa7cbf24d559e0523e778.tar.bz2 dexon-solidity-b18aea315d2e5c12ff6aa7cbf24d559e0523e778.tar.lz dexon-solidity-b18aea315d2e5c12ff6aa7cbf24d559e0523e778.tar.xz dexon-solidity-b18aea315d2e5c12ff6aa7cbf24d559e0523e778.tar.zst dexon-solidity-b18aea315d2e5c12ff6aa7cbf24d559e0523e778.zip |
Isolate test cases from all tests and store under hash.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/isolate_tests.py | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/scripts/isolate_tests.py b/scripts/isolate_tests.py index 9bb52f4c..a1d1c75c 100755 --- a/scripts/isolate_tests.py +++ b/scripts/isolate_tests.py @@ -8,10 +8,12 @@ import sys import re - +import os +import hashlib +from os.path import join def extract_cases(path): - lines = open(path).read().splitlines() + lines = open(path, 'rb').read().splitlines() inside = False delimiter = '' @@ -33,16 +35,14 @@ def extract_cases(path): return tests -def write_cases(tests, start=0): - for i, test in enumerate(tests, start=start): - open('test%d.sol' % i, 'w').write(test) - +def write_cases(tests): + for test in tests: + open('test_%s.sol' % hashlib.sha256(test).hexdigest(), 'wb').write(test) if __name__ == '__main__': - files = sys.argv[1:] + path = sys.argv[1] - i = 0 - for path in files: - cases = extract_cases(path) - write_cases(cases, start=i) - i += len(cases) + for root, dir, files in os.walk(path): + for f in files: + cases = extract_cases(join(root, f)) + write_cases(cases) |