-
Notifications
You must be signed in to change notification settings - Fork 10.4k
/
Copy pathsplit-generated-tests
executable file
·46 lines (38 loc) · 1.36 KB
/
split-generated-tests
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python
#
# This source file is part of the Swift.org open source project
#
# Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
# Licensed under Apache License v2.0 with Runtime Library Exception
#
# See http://swift.org/LICENSE.txt for license information
# See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
from __future__ import print_function
import sys
def main():
with open(sys.argv[1], 'r') as f:
content = f.readlines()
while len(content) != 0:
start_index = -1
end_index = -1
test_filename = ''
for i, line in enumerate(content):
if line.startswith('// Start of file: '):
test_filename = line[18:].strip()
start_index = i
break
if start_index == -1:
return 0
for i, line in enumerate(content):
if line.startswith('// End of file: '):
assert line[16:].strip() == test_filename
end_index = i
break
test_content = content[start_index+1:end_index]
with open(test_filename, 'w') as testFile:
for line in test_content:
if '###sourceLocation' not in line:
testFile.write(line)
content = content[end_index+1:]
if __name__ == "__main__":
sys.exit(main())