chore: Switch to this repository from predecessor
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
9ecfa63f58
commit
7b00b01856
23 changed files with 733 additions and 32 deletions
36
bin/extract_tests.xsh
Normal file
36
bin/extract_tests.xsh
Normal file
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/env xonsh
|
||||
|
||||
import re
|
||||
|
||||
#### Set Parameters
|
||||
# Should be a list of Path objects:
|
||||
TEST_LIST = pg`tests/*.spt`
|
||||
|
||||
# Should be the top-level directory for all extracted tests:
|
||||
# (there will be one subdirectory per item in TEST_LIST)
|
||||
DESTINATION = 'tests/extracted'
|
||||
|
||||
# Extension for extracted files:
|
||||
EXT = 'fos'
|
||||
|
||||
# Extension for expectations:
|
||||
EXP = 'expect'
|
||||
|
||||
for path in TEST_LIST:
|
||||
destdir = pf"{DESTINATION}/{path.stem}"
|
||||
mkdir -p @(destdir)
|
||||
contents = path.read_text()
|
||||
tests = re.split(r'test\s*(.+?)\s*\[\[.*?\n', contents)[1:]
|
||||
testit = iter(tests)
|
||||
for name, details in zip(testit, testit):
|
||||
em = re.search(r'\n\s*\]\]', details)
|
||||
if not em: continue
|
||||
example = details[:em.start()+1]
|
||||
expath = destdir / f"{name}.{EXT}"
|
||||
expath.write_text(example)
|
||||
echo Wrote @(expath)
|
||||
xm = re.search(r'/\*\*\s+writes.*?\n([\s\S]*?)\*\*/', details[em.end():])
|
||||
if xm:
|
||||
xpath = destdir / f"{name}.{EXP}"
|
||||
xpath.write_text(xm[1])
|
||||
echo " ...and" @(xpath)
|
Loading…
Add table
Add a link
Reference in a new issue