Files
swift-mirror/test/Inputs/process_fine_grained_swiftdeps.py
Saleem Abdulrasool 3bf039bfec tests: replace shell with python for portability
Replace the process_fine_grained_swiftdeps.sh with a python equivalent
(which also preserves the horrendous handling of YAML and even
"faithfully" replicates the horrible global variables).  This enables a
number of tests on Windows although the instigating macro test is not
yet enabled due to the need for further tweaks to the tests.
2023-09-03 11:49:31 -07:00

31 lines
761 B
Python

import os
import re
import subprocess
import sys
output = subprocess.run([
sys.argv[1],
"--to-yaml",
"--input-filename={}".format(sys.argv[2]),
"--output-filename=-"
], stdout=subprocess.PIPE)
entries = []
k = a = c = n = s = p = ''
for line in output.stdout.decode('utf-8').split('\n'):
if 'kind:' in line:
k = line.split()[1]
if 'aspect:' in line:
a = line.split()[1]
if 'context:' in line:
c = line.split()[1]
if 'name:' in line:
n = ' '.join(line.split()[1:])
if 'sequenceNumber:' in line:
s = line.split()[1]
if 'isProvides:' in line:
p = line.split()[1]
entries.append(' '.join([k, a, c, n, p]))
entries.sort()
print('\n'.join(entries))