git subrepo clone --branch=20.41.6 git@github.com:ETLCPP/etl.git components/etl
subrepo: subdir: "components/etl" merged: "be5537ec" upstream: origin: "git@github.com:ETLCPP/etl.git" branch: "20.41.6" commit: "be5537ec" git-subrepo: version: "0.4.9" origin: "???" commit: "???"
This commit is contained in:
parent
931c4def56
commit
11c24647ea
1296 changed files with 801882 additions and 0 deletions
45
components/etl/scripts/generator_test.py
Normal file
45
components/etl/scripts/generator_test.py
Normal file
|
@ -0,0 +1,45 @@
|
|||
import subprocess
|
||||
from os.path import abspath
|
||||
from pathlib import Path
|
||||
import filecmp
|
||||
|
||||
root_path = Path(abspath(__file__)).parent.parent
|
||||
generator_folder = root_path/"include" / "etl" / "generators"
|
||||
|
||||
# Create folder where generator outputs can go for purpose of comparison
|
||||
test_folder = root_path / "build" / "generator_tmp"
|
||||
test_folder.mkdir(parents=True, exist_ok= True)
|
||||
|
||||
all_ok = True
|
||||
for generator in generator_folder.iterdir():
|
||||
if generator.suffix != ".h":
|
||||
continue
|
||||
generator_path = str(generator_folder / generator)
|
||||
output_name = generator.name[:-12] + ".h"
|
||||
output_path = str(test_folder / output_name)
|
||||
|
||||
cog_cmd = [
|
||||
"cog",
|
||||
"-d",
|
||||
"-e",
|
||||
f"-o{output_path}",
|
||||
"-DHandlers=16",
|
||||
"-DNTypes=16",
|
||||
"-DIsOneOf=16",
|
||||
generator_path
|
||||
]
|
||||
|
||||
subprocess.run(cog_cmd)
|
||||
|
||||
# Compare generator output against actual file output
|
||||
actual_path = str(generator_folder.parent / output_name)
|
||||
if not filecmp.cmp(actual_path, output_path):
|
||||
print(f"Generator for {output_name} does not match file contents")
|
||||
all_ok = False
|
||||
|
||||
if all_ok:
|
||||
print(f"\nAll generator tests passed\n")
|
||||
exit(0)
|
||||
else:
|
||||
print(f"\nGenerator tests failed\n")
|
||||
exit(1)
|
Loading…
Add table
Add a link
Reference in a new issue