X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fas3%2Fruntests.py;h=2912be46e7f3c916d3fb58825164fe2c03e6de5a;hb=d2bcd477230b4ac8d7e69fc253d94250b13eb37a;hp=213638dff9ed8f7d08892de1bc9d18e4b434fdcf;hpb=d73dce3d59fcb13a825bed5821cc84b39a51c730;p=swftools.git diff --git a/lib/as3/runtests.py b/lib/as3/runtests.py index 213638d..2912be4 100644 --- a/lib/as3/runtests.py +++ b/lib/as3/runtests.py @@ -25,6 +25,7 @@ import os import time import subprocess import marshal +import select from optparse import OptionParser def check(s): @@ -58,22 +59,30 @@ def check(s): return 0 def runcmd(cmd,args,wait): - #fo = open(tempfile, "wb") - fo= os.tmpfile() + #fo = os.tmpfile() + fi,fo = os.pipe() + fo = os.fdopen(fo, "wb") p = subprocess.Popen([cmd] + args, executable=cmd, stdout=fo, stderr=fo) ret = -1 + output = "" for i in range(wait*10): + if fi in select.select([fi],[],[], 0.01)[0]: + output += os.read(fi, 8192) + if "[exit]" in output: + break ret = p.poll() if ret is not None: break time.sleep(0.1) else: os.kill(p.pid, 9) - os.system("killall -9 "+cmd) - - fo.seek(0) - output = fo.read() + os.system("killall -9 %s >/dev/null 2>/dev/null" % cmd) fo.close() + + if fi in select.select([fi],[],[], 0.01)[0]: + output += os.read(fi, 8192) + + os.close(fi) return ret,output class Cache: @@ -128,11 +137,13 @@ class TestBase: def compile(self): try: os.unlink("abc.swf"); except: pass - ret,output = runcmd("./parser",[self.file],wait=60) + ret,output = runcmd("./parser",[self.file],wait=1) self.compile_error = 0 self.compile_output = output + self.exit_status = 0 if ret: self.compile_output += "\nExit status %d" % (-ret) + self.exit_status = -ret self.compile_error = 1 return 0 if not os.path.isfile("abc.swf"): @@ -154,11 +165,14 @@ class TestBase: print self.r(str(self.nr),3)," ", if self.compile_error: if self.dorun: - print "err"," - ", + if self.exit_status == 11: + print "crash"," - ", + else: + print "err "," - ", else: - print "err"," ", + print "err "," ", else: - print "ok ", + print "ok ", if self.dorun: if not self.flash_error: print "ok ", @@ -239,7 +253,7 @@ cache = Cache.load(".tests.cache") cache.parse_args() nr = 0 -nr = Suite(cache, "err").run(nr) +#nr = Suite(cache, "err").run(nr) nr = Suite(cache, "ok").run(nr) cache.save(".tests.cache")