aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/isolateTests.py
blob: fed779d37d6e4693057868d1f39ccb0bc867cb34 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/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
# into files for e.g. fuzz testing as
# scripts/isolateTests.py tests/libsolidity/SolidityEndToEndTest.cpp

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])