Bug 3320696: copy .abc_ files to .abc so asc2 and asc3 compiles acceptance tests (r=brbaker,r=cpeyer)
authorDan Schaffer <Dan.Schaffer@adobe.com>
Thu, 04 Oct 2012 11:31:36 -0700
changeset 7560 b30f9228398aa8265657e67ea9c513d2387880b6
parent 7559 22eb6ca016af12c342fbcf283b6de23cf29ce550
child 7561 beba7ea689fec50cd476a4a25434d3fe6c95207e
push id4260
push userdschaffe@adobe.com
push dateFri, 05 Oct 2012 17:33:23 +0000
reviewersbrbaker, cpeyer
bugs3320696, 1120912
Bug 3320696: copy .abc_ files to .abc so asc2 and asc3 compiles acceptance tests (r=brbaker,r=cpeyer) CL@1120912
test/util/runtestBase.py
--- a/test/util/runtestBase.py
+++ b/test/util/runtestBase.py
@@ -1091,16 +1091,31 @@ class RuntestBase(object):
             if isfile(src): # Safe guard
                 shutil.copyfile(src, dest)
                 return
             count = count + 1
             sleep(1)
         # If we get this far, we will silently fail to copy the file. This will
         # allow the ADT call to produce its failure of not being able to open the abc file.
 
+    # fixAbcCommand
+    # cmd: a string of compiler arguments
+    # return: a string or compiler arguments with all files ended with .abc_ replaced with .abc
+    def fixAbcCommand(self,cmd):
+        newcmd=[]
+        for token in cmd.split():
+            if token.endswith('.abc_') and os.path.exists(os.getcwd()+'/'+token): # if token is a .abc_ file
+                tokenWithout_=token[:-1]
+                if not os.path.exists(os.getcwd()+'/'+tokenWithout_):
+                    shutil.copy(os.getcwd()+'/'+token,os.getcwd()+'/'+tokenWithout_)
+                newcmd.append(tokenWithout_)
+            else: # otherwise retain compiler parameters
+                newcmd.append(token)
+        return string.join(newcmd) # convert from array of string back to string
+
     def compile_test(self, as_file, extraArgs=[], outputCalls = None):
         self.checkExecutable(self.java, 'java must be on system path or --java must be set to java executable')
         asc, builtinabc, shellabc, ascargs = self.asc, self.builtinabc, self.shellabc, self.ascargs
         # if there is a .build file available (which is an executable script)
         # run that file instead of compiling with asc
         as_base = as_file[0:as_file.rfind('.')]
         if isfile(as_base+'.build'):
             (dir,file)=split(as_base)
@@ -1145,17 +1160,18 @@ class RuntestBase(object):
             # look for .asc_args files to specify dir / file level compile args, arglist is passed by ref
             ascArgList = self.loadArgsFile(ascArgList, dir, as_file, 'asc_args')
             
             (testdir, ext) = splitext(as_file)
                 
             cmd += ' -import %s' % builtinabc
             for arg in ascArgList:
                 cmd += ' %s' % arg
-            
+
+            cmd=self.fixAbcCommand(cmd)            
             # look for a subdirectory of the same name as the .as file
             # if it exists, import all of the files within that dir when
             # compiling the test
             deps = glob(join(testdir,'*.abc'))
             deps.sort()
             for util in deps + glob(join(dir,'*Util'+self.sourceExt)):
                 if self.osName == 'win' and not self.cygwin:
                     # don't escape $ when running windows python
@@ -1327,39 +1343,43 @@ class RuntestBase(object):
                         if exists(testdir+".abc"):
                             os.unlink(testdir+".abc")
 
                         if self.genAtsSwfs:
                             if search_file(test+'.avm_args', 'USES_SWFVERSION'):
                                 create_ats_swfversion_copy(test)
                                 as_file = test + '.swfversion'
                                 for swfversion in self.swfversions:
-                                    new_cmd = cmd + ' -swf 200,200,version=%s' % swfversion
+                                    new_cmd = cmd + ' -swf 200,200,version=%s %s' % (swfversion,test)
+                                    new_cmd=self.fixAbcCommand(new_cmd)
+
                                     self.debug_print('%s %s.swfversion' % (new_cmd,test))
                                     child.sendline('%s %s.swfversion' % (new_cmd,test))
                                     child.expect("\(ash\)")
                                     # rename the file to indicate which version it was compiled to
                                     # compiled filename is test.as.swfversion.abc
                                     file_noext, ext = splitext(file)
                                     new_filename = file_noext+'_v%s' % swfversion + '.swf'
                                     shutil.move(join(dir,file)+'.swfversion.swf', join(dir, new_filename))
                                     moveAtsSwf(dir,new_filename, self.atsDir)
                                 try:
                                     os.remove(join(dir,file)+'.swfversion')
                                     os.remove(join(dir,file)+'.swfversion.abc')
                                 except:
                                     pass
                             else:
                                 cmd += " -swf 200,200 %s" % test
+                                cmd=self.fixAbcCommand(cmd)
                                 self.debug_print(cmd)
                                 child.sendline(cmd)
                                 child.expect("\(ash\)")
                                 moveAtsSwf(dir,file, self.atsDir)
                         else:
                             cmd += " %s" % test
+                            cmd=self.fixAbcCommand(cmd)
                             child.sendline(cmd)
                             child.expect("\(ash\)")
 
                             if not exists(testdir+".abc"):
                                 print("ERROR: abc file %s.abc not created, cmd used to compile: %s" % (testdir,cmd))
                                 self.ashErrors.append("abc file %s.abc not created, cmd used to compile: %s" % (testdir,cmd))
 
                     total -= 1