Files
Beslan 0ef1717155
Some checks failed
Basic Checks / license-check (push) Has been cancelled
Basic Checks / include-check (push) Has been cancelled
Basic Checks / style-check (push) Has been cancelled
Basic Checks / docs-check (push) Has been cancelled
Basic Checks / python-tests (push) Has been cancelled
Basic Checks / pin-validation (push) Has been cancelled
Basic Checks / cmake-checks (push) Has been cancelled
Basic Checks / frozen-tools-check (push) Has been cancelled
Publish or Update docker image for head of branch / prepare-tags (push) Has been cancelled
Release or update docker image for a released mbed-os version / prepare-tags (push) Has been cancelled
Publish or Update docker image for head of branch / build-container (push) Has been cancelled
Publish or Update docker image for head of branch / test-container (linux/amd64) (push) Has been cancelled
Publish or Update docker image for head of branch / test-container (linux/arm64) (push) Has been cancelled
Publish or Update docker image for head of branch / deploy-container (push) Has been cancelled
Release or update docker image for a released mbed-os version / build-container (push) Has been cancelled
Release or update docker image for a released mbed-os version / test-container (linux/amd64) (push) Has been cancelled
Release or update docker image for a released mbed-os version / test-container (linux/arm64) (push) Has been cancelled
Release or update docker image for a released mbed-os version / deploy-container (push) Has been cancelled
Prune temporary docker images / prune-images (push) Has been cancelled
Mirror mbed-os-6.15.0
2026-07-10 18:42:39 +03:00

49 lines
1.3 KiB
Python

#!/usr/bin/env python
import re
import sys
import subprocess
import os
import yaml
def generate(test):
with open('replacements.yml') as file:
replacements = yaml.load(file)
lines = []
for line in re.split('(?<=[;{}])\n', test.read()):
for pattern, replacement in replacements:
line = re.sub(pattern, replacement, line, 0, re.DOTALL | re.MULTILINE)
match = re.match('(?: *\n)*( *)(.*)=>(.*);', line, re.DOTALL | re.MULTILINE)
if match:
tab, test, expect = match.groups()
lines.append(tab+'res = {test};'.format(test=test.strip()))
lines.append(tab+'TEST_ASSERT_EQUAL({expect}, res);'.format(
name=re.match('\w*', test.strip()).group(),
expect=expect.strip()))
else:
lines.append(line)
lines = lines[:-1]
with open('template_subunit.fmt') as file:
template = file.read()
with open('main.cpp', 'a') as file:
file.write(template.format(
test=('\n'.join(
4*' '+line.replace('\n', '\n'+4*' ')
for line in lines))))
def main(test=None):
if test and not test.startswith('-'):
with open(test) as file:
generate(file)
else:
generate(sys.stdin)
if __name__ == "__main__":
main(*sys.argv[1:])