2020-10-19 08:02:57 +00:00
|
|
|
#!/usr/bin/env python3
|
2014-08-06 19:46:28 +00:00
|
|
|
from __future__ import print_function
|
2014-07-30 15:50:38 +00:00
|
|
|
import glob
|
|
|
|
import json
|
|
|
|
import os
|
|
|
|
import subprocess
|
2020-10-19 08:02:57 +00:00
|
|
|
|
2014-07-30 15:50:38 +00:00
|
|
|
for testfile in glob.glob("*.json"):
|
|
|
|
testdoc = json.load(open(testfile))
|
|
|
|
for test in testdoc["tests"]:
|
|
|
|
if "lambda" in test["data"]:
|
|
|
|
continue
|
2020-10-19 08:02:57 +00:00
|
|
|
|
2014-07-30 15:50:38 +00:00
|
|
|
open('data', 'w').write(json.dumps(test["data"]))
|
|
|
|
open('template', 'w').write(test["template"])
|
2014-08-02 01:46:00 +00:00
|
|
|
if "partials" in test:
|
|
|
|
open('partials', 'w').write(json.dumps(test["partials"]))
|
|
|
|
else:
|
|
|
|
open('partials', 'w').write("{}")
|
2020-10-19 08:02:57 +00:00
|
|
|
|
2023-07-02 21:39:55 +00:00
|
|
|
if os.name == 'nt':
|
|
|
|
ret = subprocess.check_output("mustachetest.exe").decode('utf8')
|
|
|
|
else:
|
|
|
|
ret = subprocess.check_output('./mustachetest').decode('utf8')
|
2014-08-06 19:46:28 +00:00
|
|
|
print(testfile, test["name"])
|
2020-10-19 08:02:57 +00:00
|
|
|
|
2014-07-30 15:50:38 +00:00
|
|
|
if ret != test["expected"]:
|
2014-08-02 01:46:00 +00:00
|
|
|
if 'partials' in test:
|
2020-10-19 08:02:57 +00:00
|
|
|
print('Partials:', json.dumps(test["partials"]))
|
|
|
|
print('Data: ', json.dumps(test["data"]))
|
|
|
|
print('Template: ', test["template"])
|
|
|
|
print('Expected:', repr(test["expected"]))
|
|
|
|
print('Actual:', repr(ret))
|
2014-08-01 21:30:36 +00:00
|
|
|
assert ret == test["expected"]
|
2020-10-19 08:02:57 +00:00
|
|
|
|
2014-07-30 15:50:38 +00:00
|
|
|
os.unlink('data')
|
|
|
|
os.unlink('template')
|
2014-08-02 01:46:00 +00:00
|
|
|
os.unlink('partials')
|