2010-07-26 12:56:02 -05:00
|
|
|
import py
|
|
|
|
|
2010-07-26 09:35:32 -05:00
|
|
|
from openscad_utils import *
|
|
|
|
|
2010-08-26 03:05:04 -05:00
|
|
|
|
|
|
|
temppath = py.test.ensuretemp('MCAD')
|
|
|
|
|
2010-07-26 09:35:32 -05:00
|
|
|
def pytest_generate_tests(metafunc):
|
2010-07-26 12:56:02 -05:00
|
|
|
if "modpath" in metafunc.funcargnames:
|
2010-08-26 03:05:04 -05:00
|
|
|
for fpath, modnames in collect_test_modules().items():
|
2010-09-29 12:27:53 -05:00
|
|
|
#os.system("cp %s %s/" % (fpath, temppath))
|
2010-08-26 03:05:04 -05:00
|
|
|
if "modname" in metafunc.funcargnames:
|
2010-07-26 12:56:02 -05:00
|
|
|
for modname in modnames:
|
|
|
|
metafunc.addcall(funcargs=dict(modname=modname, modpath=fpath))
|
2010-08-26 03:05:04 -05:00
|
|
|
else:
|
2010-07-26 12:56:02 -05:00
|
|
|
metafunc.addcall(funcargs=dict(modpath=fpath))
|
2010-07-26 09:35:32 -05:00
|
|
|
|
|
|
|
|
2010-08-26 06:19:49 -05:00
|
|
|
def test_module_compile(modname, modpath):
|
|
|
|
tempname = modpath.basename + '-' + modname + '.scad'
|
2010-07-26 12:56:02 -05:00
|
|
|
fpath = temppath.join(tempname)
|
|
|
|
stlpath = temppath.join(tempname + ".stl")
|
|
|
|
f = fpath.open('w')
|
2010-09-29 12:27:53 -05:00
|
|
|
code = """
|
2010-07-26 12:56:02 -05:00
|
|
|
//generated testfile
|
2010-08-26 06:19:49 -05:00
|
|
|
use <%s>
|
2010-07-26 12:56:02 -05:00
|
|
|
|
2010-08-26 03:05:04 -05:00
|
|
|
%s();
|
2010-09-29 12:27:53 -05:00
|
|
|
""" % (modpath, modname)
|
|
|
|
print code
|
|
|
|
f.write(code)
|
2010-07-26 12:56:02 -05:00
|
|
|
f.flush
|
2010-09-30 01:22:54 -05:00
|
|
|
output = call_openscad(path=fpath, stlpath=stlpath, timeout=0)
|
2010-07-26 12:56:02 -05:00
|
|
|
print output
|
|
|
|
assert output[0] is 0
|
2010-09-30 01:22:54 -05:00
|
|
|
for s in ("warning", "error"):
|
|
|
|
assert s not in output[2].strip().lower()
|
2010-07-26 12:56:02 -05:00
|
|
|
assert len(stlpath.readlines()) > 2
|
|
|
|
|
2010-08-26 06:19:49 -05:00
|
|
|
def test_file_compile(modpath):
|
|
|
|
stlpath = temppath.join(modpath.basename + "-test.stl")
|
2010-07-26 12:56:02 -05:00
|
|
|
output = call_openscad(path=modpath, stlpath=stlpath)
|
|
|
|
print output
|
|
|
|
assert output[0] is 0
|
2010-09-30 01:22:54 -05:00
|
|
|
for s in ("warning", "error"):
|
|
|
|
assert s not in output[2].strip().lower()
|
2010-08-26 03:05:04 -05:00
|
|
|
assert len(stlpath.readlines()) == 2
|
2010-07-26 12:56:02 -05:00
|
|
|
|
|
|
|
|