5 # Run compiler unit tests
7 # Copyright (c) 2008 Matthias Kramm <kramm@quiss.org>
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
31 for line in s.split("\n"):
32 if line.startswith("[") and line.endswith("]"):
36 if not line.startswith("ok"):
38 if line.startswith("ok "):
42 nr,len = int(line[3:i]),int(line[i+1:])
58 def runcmd(cmd,args,wait):
59 #fo = open(tempfile, "wb")
61 p = subprocess.Popen([cmd] + args, executable=cmd, stdout=fo, stderr=fo)
63 for i in range(wait*10):
70 os.system("killall -9 "+cmd)
78 def __init__(self, nr, file):
81 self.flash_output = None
82 self.flash_error = None
83 self.compile_output = None
84 self.compile_error = None
86 if not self.compile_error:
90 try: os.unlink("abc.swf");
92 ret,output = runcmd("./parser",[self.file],wait=60)
93 self.compile_error = 0
94 self.compile_output = output
96 self.compile_error = 1
97 if not os.path.isfile("abc.swf"):
98 self.compile_error = 1
101 ret,output = runcmd("flashplayer",["abc.swf"],wait=1)
102 os.system("killall flashplayer")
103 self.flash_output = output
105 if not check(self.flash_output):
112 return (" "*(l-len(s))) + s
116 return s + (" "*(l-len(s)))
118 print r(str(self.nr),3)," ",
119 if self.compile_error:
123 if not self.flash_error:
130 def doprintlong(self):
131 print self.nr, self.file
132 print "================================"
133 print "compile:", (test.compile_error and "error" or "ok")
134 print test.compile_output
135 print "================================"
136 print "run:", (test.flash_error and "error" or "ok")
137 print test.flash_output
138 print "================================"
142 checknum = int(sys.argv[1])
144 for nr,file in sorted(enumerate(os.listdir("ok"))):
145 if not file.endswith(".as"):
147 file = os.path.join("ok", file)
148 if checknum>=0 and nr!=checknum: