Merge pull request #1 from openscad/master

Minor changes to testing framework (by kintel)
This commit is contained in:
Elmo 2011-09-28 23:26:16 -07:00
commit f313545c3e
4 changed files with 13 additions and 8 deletions

View file

@ -1,5 +1,5 @@
import py
import os.path
from openscad_utils import *
@ -8,12 +8,14 @@ temppath = py.test.ensuretemp('MCAD')
def pytest_generate_tests(metafunc):
if "modpath" in metafunc.funcargnames:
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))
if "modname" in metafunc.funcargnames:
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:
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):

View file

@ -1,4 +1,4 @@
import py, re, os, signal, time, commands
import py, re, os, signal, time, commands, sys
from subprocess import Popen, PIPE
mod_re = (r"\bmodule\s+(", r")\s*\(\s*")
@ -30,7 +30,9 @@ def collect_test_modules(dirpath=None):
class Timeout(Exception): pass
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
if timeout:
try:

View file

@ -1,15 +1,16 @@
import py
import os.path
dirpath = py.path.local("./")
def pytest_generate_tests(metafunc):
if "filename" in metafunc.funcargnames:
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'):
name = fpath.basename
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):
README = dirpath.join('README').read()

View file

@ -56,7 +56,7 @@ module test_triangles()
// Generate a bunch of triangles by angle
for (i = [1:85/5])
{
translate([i*7, 20, i*7])
translate([i*7, 22, i*7])
{
a_triangle(i*5, 10, 5);
}