Merge pull request #1 from openscad/master
Minor changes to testing framework (by kintel)
This commit is contained in:
commit
f313545c3e
|
@ -1,5 +1,5 @@
|
||||||
import py
|
import py
|
||||||
|
import os.path
|
||||||
from openscad_utils import *
|
from openscad_utils import *
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,12 +8,14 @@ temppath = py.test.ensuretemp('MCAD')
|
||||||
def pytest_generate_tests(metafunc):
|
def pytest_generate_tests(metafunc):
|
||||||
if "modpath" in metafunc.funcargnames:
|
if "modpath" in metafunc.funcargnames:
|
||||||
for fpath, modnames in collect_test_modules().items():
|
for fpath, modnames in collect_test_modules().items():
|
||||||
|
basename = os.path.splitext(os.path.split(str(fpath))[1])[0]
|
||||||
#os.system("cp %s %s/" % (fpath, temppath))
|
#os.system("cp %s %s/" % (fpath, temppath))
|
||||||
if "modname" in metafunc.funcargnames:
|
if "modname" in metafunc.funcargnames:
|
||||||
for modname in modnames:
|
for modname in modnames:
|
||||||
metafunc.addcall(funcargs=dict(modname=modname, modpath=fpath))
|
print modname
|
||||||
|
metafunc.addcall(id=basename+"/"+modname, funcargs=dict(modname=modname, modpath=fpath))
|
||||||
else:
|
else:
|
||||||
metafunc.addcall(funcargs=dict(modpath=fpath))
|
metafunc.addcall(id=os.path.split(str(fpath))[1], funcargs=dict(modpath=fpath))
|
||||||
|
|
||||||
|
|
||||||
def test_module_compile(modname, modpath):
|
def test_module_compile(modname, modpath):
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import py, re, os, signal, time, commands
|
import py, re, os, signal, time, commands, sys
|
||||||
from subprocess import Popen, PIPE
|
from subprocess import Popen, PIPE
|
||||||
|
|
||||||
mod_re = (r"\bmodule\s+(", r")\s*\(\s*")
|
mod_re = (r"\bmodule\s+(", r")\s*\(\s*")
|
||||||
|
@ -30,7 +30,9 @@ def collect_test_modules(dirpath=None):
|
||||||
class Timeout(Exception): pass
|
class Timeout(Exception): pass
|
||||||
|
|
||||||
def call_openscad(path, stlpath, timeout=5):
|
def call_openscad(path, stlpath, timeout=5):
|
||||||
command = ['openscad', '-s', str(stlpath), str(path)]
|
if sys.platform == 'darwin': exe = 'OpenSCAD.app/Contents/MacOS/OpenSCAD'
|
||||||
|
else: exe = 'openscad'
|
||||||
|
command = [exe, '-s', str(stlpath), str(path)]
|
||||||
print command
|
print command
|
||||||
if timeout:
|
if timeout:
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
import py
|
import py
|
||||||
|
import os.path
|
||||||
|
|
||||||
dirpath = py.path.local("./")
|
dirpath = py.path.local("./")
|
||||||
|
|
||||||
def pytest_generate_tests(metafunc):
|
def pytest_generate_tests(metafunc):
|
||||||
if "filename" in metafunc.funcargnames:
|
if "filename" in metafunc.funcargnames:
|
||||||
for fpath in dirpath.visit('*.scad'):
|
for fpath in dirpath.visit('*.scad'):
|
||||||
metafunc.addcall(funcargs=dict(filename=fpath.basename))
|
metafunc.addcall(id=fpath.basename, funcargs=dict(filename=fpath.basename))
|
||||||
for fpath in dirpath.visit('*.py'):
|
for fpath in dirpath.visit('*.py'):
|
||||||
name = fpath.basename
|
name = fpath.basename
|
||||||
if not (name.startswith('test_') or name.startswith('_')):
|
if not (name.startswith('test_') or name.startswith('_')):
|
||||||
metafunc.addcall(funcargs=dict(filename=fpath.basename))
|
metafunc.addcall(id=fpath.basename, funcargs=dict(filename=fpath.basename))
|
||||||
|
|
||||||
def test_README(filename):
|
def test_README(filename):
|
||||||
README = dirpath.join('README').read()
|
README = dirpath.join('README').read()
|
||||||
|
|
|
@ -56,7 +56,7 @@ module test_triangles()
|
||||||
// Generate a bunch of triangles by angle
|
// Generate a bunch of triangles by angle
|
||||||
for (i = [1:85/5])
|
for (i = [1:85/5])
|
||||||
{
|
{
|
||||||
translate([i*7, 20, i*7])
|
translate([i*7, 22, i*7])
|
||||||
{
|
{
|
||||||
a_triangle(i*5, 10, 5);
|
a_triangle(i*5, 10, 5);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue