mirror of
https://github.com/ETLCPP/etl.git
synced 2026-10-28 18:07:10 +08:00
Generator test
This commit is contained in:
parent
a2e02d8dfa
commit
c2ceca3d8f
42
scripts/generator_test.py
Normal file
42
scripts/generator_test.py
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
import subprocess
|
||||||
|
from os.path import abspath
|
||||||
|
from pathlib import Path
|
||||||
|
import filecmp
|
||||||
|
|
||||||
|
root_path = Path(abspath(__file__)).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 not all_ok:
|
||||||
|
exit(1)
|
||||||
|
exit(0)
|
||||||
Loading…
x
Reference in New Issue
Block a user