Improved testing and fixed a warning thus found

This commit is contained in:
Elmom 2010-09-30 09:22:54 +03:00
parent d650715b6f
commit 55bd2607c8
3 changed files with 35 additions and 26 deletions

View file

@ -1,4 +1,4 @@
import py, re, os, signal, time
import py, re, os, signal, time, commands
from subprocess import Popen, PIPE
mod_re = (r"\bmodule\s+(", r")\s*\(\s*")
@ -30,9 +30,10 @@ def collect_test_modules(dirpath=None):
class Timeout(Exception): pass
def call_openscad(path, stlpath, timeout=1):
try:
command = ['openscad', '-s', str(stlpath), str(path)]
print command
if timeout:
try:
proc = Popen(command,
stdout=PIPE, stderr=PIPE, close_fds=True)
calltime = time.time()
@ -53,3 +54,9 @@ def call_openscad(path, stlpath, timeout=1):
pass
return (proc.returncode,) + proc.communicate()
else:
output = commands.getstatusoutput(" ".join(command))
return output + ('', '')
def parse_output(text):
pass

View file

@ -30,10 +30,11 @@ use <%s>
print code
f.write(code)
f.flush
output = call_openscad(path=fpath, stlpath=stlpath, timeout=5)
output = call_openscad(path=fpath, stlpath=stlpath, timeout=0)
print output
assert output[0] is 0
assert "warning" or "error" not in output[2].strip().lowercase()
for s in ("warning", "error"):
assert s not in output[2].strip().lower()
assert len(stlpath.readlines()) > 2
def test_file_compile(modpath):
@ -41,7 +42,8 @@ def test_file_compile(modpath):
output = call_openscad(path=modpath, stlpath=stlpath)
print output
assert output[0] is 0
assert "warning" or "error" not in output[2].strip().lowercase()
for s in ("warning", "error"):
assert s not in output[2].strip().lower()
assert len(stlpath.readlines()) == 2

View file

@ -5,7 +5,7 @@
* Dual licenced under Creative Commons Attribution-Share Alike 3.0 and LGPL2 or later
*/
<units.scad>
include <units.scad>
function distance(a, b) = sqrt( (a[0] - b[0])*(a[0] - b[0]) +
(a[1] - b[1])*(a[1] - b[1]) +