import select
from optparse import OptionParser
+CMD_ARGS=[]
+CMD = "./parser"
+#CMD="as3compile"
+CMD_ARGS=["-o","abc.swf"]
+
def check(s):
row = None
ok = 0
if "/" not in line:
return 0
i = line.index('/')
- nr,len = int(line[3:i]),int(line[i+1:])
+ try:
+ nr,len = int(line[3:i]),int(line[i+1:])
+ except ValueError:
+ return 0
if nr<1 or nr>len:
return 0
if not row:
output += os.read(fi, 8192)
if "[exit]" in output:
break
+ if "rror" in output:
+ break
ret = p.poll()
if ret is not None:
break
class Cache:
def __init__(self, filename):
+ self.filename = filename
self.filename_milestone = filename+"_milestone"
try:
- self.filename2status = marshal.load(open(filename, "rb"))
+ self.filename2status = marshal.load(open(self.filename, "rb"))
except IOError:
self.filename2status = {}
try:
- self.milestone = marshal.load(open(filename, "rb"))
+ self.milestone = marshal.load(open(self.filename_milestone, "rb"))
except IOError:
- self.milstone = {}
+ self.milestone = {}
def parse_args(self):
parser = OptionParser()
parser.add_option("-d", "--diff", dest="diff", help="Only run tests that failed the last time",action="store_true")
- parser.add_option("-a", "--all", dest="all", help="Run all tests (also tests expected fail)",action="store_true")
+ parser.add_option("-a", "--all", dest="all", help="Run all tests (also tests expected to fail)",action="store_true")
parser.add_option("-t", "--tag", dest="tag", help="Mark the current pass/fail statistic as milestone",action="store_true")
(options, args) = parser.parse_args()
+
+ if args and args[0]=="add":
+ self.all = 1
+ self.tag = 1
+ self.milestone[args[1]] = "ok"
+ self.filename2status = self.milestone
+ self.save()
+ sys.exit(0)
+
self.__dict__.update(options.__dict__)
self.runtime = 1
if self.tag:
self.runtime = 5 # allow more time if we're tagging this state
self.checknum=-1
+ self.checkfile=None
if len(args):
- self.checknum = int(args[0])
+ try:
+ self.checknum = int(args[0])
+ except ValueError:
+ self.checkfile = args[0]
@staticmethod
def load(filename):
return Cache(filename)
- def save(self, filename):
- fi = open(filename, "wb")
+ def save(self):
+ fi = open(self.filename, "wb")
marshal.dump(self.filename2status, fi)
fi.close()
if self.tag:
fi.close()
def highlight(self, nr, filename):
+ if self.checkfile and filename==self.checkfile:
+ return 1
return self.checknum==nr
def skip_file(self, nr, filename):
if self.checknum>=0 and nr!=self.checknum:
return 1
- if not self.all and self.milestone[filename]!="ok":
+ if self.checkfile and filename!=self.checkfile:
+ return 1
+ if not self.all and self.milestone.get(filename,"new")!="ok":
return 1
- if self.diff and self.filename2status[filename]=="ok":
+ if self.diff and self.filename2status(filename,"new")=="ok":
return 1
return 0
def compile(self):
try: os.unlink("abc.swf");
except: pass
- ret,output = runcmd("./parser",[self.file],wait=cache.runtime)
+ ret,output = runcmd(CMD,CMD_ARGS+[self.file],wait=cache.runtime)
self.compile_error = 0
self.compile_output = output
self.exit_status = 0
nr = Suite(cache, "err").run(nr)
nr = Suite(cache, "ok").run(nr)
-cache.save(".tests.cache")
+cache.save()