solidity/scripts/isolateTests.py

25 lines
630 B
Python
Raw Normal View History

2016-09-30 11:09:45 +00:00
#!/usr/bin/python
#
# This script reads C++ source files and writes all
# multi-line strings into individual files.
# This can be used to extract the Solidity test cases
2016-10-10 20:04:11 +00:00
# into files for e.g. fuzz testing as
# scripts/isolateTests.py tests/libsolidity/SolidityEndToEndTest.cpp
2016-09-30 11:09:45 +00:00
import sys
lines = sys.stdin.read().split('\n')
inside = False
tests = []
for l in lines:
if inside:
if l.strip().endswith(')";'):
inside = False
else:
tests[-1] += l + '\n'
else:
if l.strip().endswith('R"('):
inside = True
tests += ['']
for i in range(len(tests)):
open('test%d.sol' % i, 'w').write(tests[i])