Bug 602995: runtests harness: dir.asc_args files are not loaded in subdirectories (r=brbaker)
authorChris Peyer <cpeyer@adobe.com>
Tue, 12 Oct 2010 16:03:52 -0700
changeset 5350 59bedac94cf7dbf04a1de020fc10a23d2ecc0a14
parent 5349 177b2b24f6817095576c56df4a9863a6a64a0751
child 5351 e523f4426e835de155905ac095af95d084f96fe3
push id2938
push usercpeyer@adobe.com
push dateTue, 12 Oct 2010 23:36:35 +0000
reviewersbrbaker
bugs602995
Bug 602995: runtests harness: dir.asc_args files are not loaded in subdirectories (r=brbaker)
test/util/runtestBase.py
--- a/test/util/runtestBase.py
+++ b/test/util/runtestBase.py
@@ -238,17 +238,16 @@ class RuntestBase:
     def parseOptions(self):
         try:
             opts, self.args = getopt(argv[1:], self.options, self.longOptions )
         except:
             self.usage(2)
 
         if not self.args:
             self.args = ['.']
-
         for o, v in opts:
             if o in ('-v', '--verbose'):
                 self.verbose = True
             elif o in ('-h', '--help'):
                 self.usage(0)
             elif o in ('-E', '--avm'):
                 self.avm = v
             elif o in ('-a', '--asc'):
@@ -687,20 +686,22 @@ class RuntestBase:
                 settings.update(localSettings[root])
         return settings
 
     def istest(self,f, fileExtentions):
         return f.endswith(fileExtentions) and basename(f) != ('shell'+self.sourceExt) \
                and not f.endswith('Util'+self.sourceExt)
 
     def parents(self, d):
+        '''return a generator of the current dir and all parent directories up
+            to the test dir root'''
         while d != abspath(self.args[0]) and d != '':
             yield d
             d = dirname(d)
-        yield d
+        yield '.'   # yield the test dir root
 
     def parseTestConfig(self, dir):
         settings={}
         includes=[]
         names=None
         lines=[]
 
         if isfile(join(dir,self.testconfig)):
@@ -746,17 +747,17 @@ class RuntestBase:
 
         if isfile('./dir.asc_args'):  # load root dir.asc_args
             ascArgsList = parseArgStringToList(self.ascargs)
             ascArgsList = self.parseAscArgs(ascArgsList, './dir.asc_args', './')
             self.ascargs = ' '.join(ascArgsList)
 
 
         # Loads root asc_args file and modifies arglist accordingly
-        if isfile('./dir.java_args'):  # load root dir.asc_args
+        if isfile('./dir.java_args'):  # load root dir.java_args
             javaArgsList = parseArgStringToList(self.javaargs)
             javaArgsList = self.parseAscArgs(javaArgsList, './dir.java_args', './')
             self.javaargs = ' '.join(javaArgsList)
 
 
     ### Output / Printing functions ###
 
     def err_print(self, m):
@@ -888,18 +889,16 @@ class RuntestBase:
                 cmd += ' -jar %s' %  asc
             else:
                 cmd = asc
 
             ascargs += ' ' + ' '.join(extraArgs)
             ascArgList = parseArgStringToList(ascargs)
         
             for p in self.parents(dir):
-                if p=='':
-                    p='.'
                 shell = join(p,'shell'+self.sourceExt)
                 if isfile(shell):
                     ascArgList.append(' -in ' + shell)
                     break
             
             # 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')
             
@@ -930,17 +929,16 @@ class RuntestBase:
             
             cmd = '%s -j "%s" -a "%s"' % (self.abcasmRunner, self.java, ' '.join(javaArgList))
             
         elif as_file.endswith(self.executableExtensions):
             # directly executable file doesn't need to be compiled
             return
         
         try:
-            self.verbose_print('compiling: %s %s' % (cmd,as_file))
             (f,err,exitcode) = self.run_pipe('%s %s' % (cmd,as_file), outputCalls=outputCalls)
             if self.genAtsSwfs:
                 moveAtsSwf(dir,file, self.atsDir)
             
             return f+err
         except:
             raise
     
@@ -998,18 +996,16 @@ class RuntestBase:
                     # Not ideal - but we try to load a .java_args file, and if one is loaded, then we revert to compiling
                     # without ash, as there is no way to pass new java args to the already running ash process
                     javaArgList = []
                     javaArgList = self.loadArgsFile(javaArgList, dir, test, 'java_args')
                     if javaArgList:
                         self.compile_test(test)
                     else:
                         for p in self.parents(dir):
-                            if p=='':
-                                p='.'
                             shell = join(p,"shell.as")
                             if isfile(shell):
                                 arglist.append(' -in ' + shell)
                                 break
                         
                         # look for .asc_args files to specify dir / file level compile args
                         arglist = self.loadArgsFile(arglist, dir, test, 'asc_args')
 
@@ -1046,23 +1042,28 @@ class RuntestBase:
 
                     #print("%d remaining, %s" % (total,cmd))
         end_time = datetime.today()
 
     def loadArgsFile(self, arglist,dir,file, filetype='asc_args'):
         # It is possible that file is actually a partial path rooted to acceptance,
         # so make sure that we are only dealing with the actual filename
         file = split(file)[1]
-
-        if isfile('%s/dir.%s' % (dir, filetype)):  # dir takes precedence over root
-            arglist = self.parseAscArgs(arglist, '%s/dir.%s' % (dir, filetype), dir)
-
-        if file and isfile('%s/%s.%s' % (dir, file, filetype)):  # file takes precendence over directory
+        
+        # file takes precendence over directory
+        if file and isfile('%s/%s.%s' % (dir, file, filetype)):
             arglist = self.parseAscArgs(arglist, '%s/%s.%s' % (dir, file, filetype), dir)
-
+        else:   # dir takes precedence over root
+            # look for arg file in this or any parent dir (excluding root)
+            for d in self.parents(dir):
+                if d == '.':
+                    break   # don't parse the root args file
+                if isfile('%s/dir.%s' % (d, filetype)):
+                    arglist = self.parseAscArgs(arglist, '%s/dir.%s' % (d, filetype), d)
+                    break
         return arglist
 
 
     def parseAscArgs(self, currentArgList, ascArgFile, currentdir):
         # reads an .asc_args file and returns a tuple of the arg mode (override or merge) and a list of args
         f = open(ascArgFile,'r')
         while True: # skip comment lines
             ascargs = f.readline()