mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #4434 from mattaereal/patch-4
Update isolate_tests.py
This commit is contained in:
commit
f6edb7fb8f
@ -10,7 +10,7 @@ import sys
|
|||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
import hashlib
|
import hashlib
|
||||||
from os.path import join
|
from os.path import join, isfile
|
||||||
|
|
||||||
def extract_test_cases(path):
|
def extract_test_cases(path):
|
||||||
lines = open(path, 'rb').read().splitlines()
|
lines = open(path, 'rb').read().splitlines()
|
||||||
@ -77,24 +77,31 @@ def write_cases(tests):
|
|||||||
for test in tests:
|
for test in tests:
|
||||||
open('test_%s.sol' % hashlib.sha256(test).hexdigest(), 'wb').write(test)
|
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__':
|
if __name__ == '__main__':
|
||||||
path = sys.argv[1]
|
path = sys.argv[1]
|
||||||
docs = False
|
docs = False
|
||||||
if len(sys.argv) > 2 and sys.argv[2] == 'docs':
|
if len(sys.argv) > 2 and sys.argv[2] == 'docs':
|
||||||
docs = True
|
docs = True
|
||||||
|
|
||||||
for root, subdirs, files in os.walk(path):
|
if isfile(path):
|
||||||
if '_build' in subdirs:
|
extract_and_write(path, path)
|
||||||
subdirs.remove('_build')
|
else:
|
||||||
if 'compilationTests' in subdirs:
|
for root, subdirs, files in os.walk(path):
|
||||||
subdirs.remove('compilationTests')
|
if '_build' in subdirs:
|
||||||
for f in files:
|
subdirs.remove('_build')
|
||||||
path = join(root, f)
|
if 'compilationTests' in subdirs:
|
||||||
if docs:
|
subdirs.remove('compilationTests')
|
||||||
cases = extract_docs_cases(path)
|
for f in files:
|
||||||
else:
|
path = join(root, f)
|
||||||
if f.endswith(".sol"):
|
extract_and_write(f, path)
|
||||||
cases = [open(path, "r").read()]
|
|
||||||
else:
|
|
||||||
cases = extract_test_cases(path)
|
|
||||||
write_cases(cases)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user