Bug 1277770 - look for jit-test directives in directives.txt. r=jonco
authorLars T Hansen <lhansen@mozilla.com>
Tue, 08 Nov 2016 16:53:05 +0100
changeset 351944 788c788561b43fc079572b32d75e7f2f1f13cd41
parent 351943 560a32f9d49fe46e9d64d77b8efd7f69ef0ead64
child 351945 2fc79743f58e1b73655879551448e0152a122d19
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjonco
bugs1277770
milestone52.0a1
Bug 1277770 - look for jit-test directives in directives.txt. r=jonco
js/src/tests/lib/jittests.py
--- a/js/src/tests/lib/jittests.py
+++ b/js/src/tests/lib/jittests.py
@@ -164,25 +164,50 @@ class JitTest:
             variants = variants + [ opts + join_opts for opts in variants ];
 
         # For each list of jit flags, make a copy of the test.
         return [self.copy_and_extend_jitflags(v) for v in variants]
 
 
     COOKIE = '|jit-test|'
     CacheDir = JS_CACHE_DIR
+    Directives = {}
+
+    @classmethod
+    def find_directives(cls, file_name):
+        meta = ''
+        line = open(file_name).readline()
+        i = line.find(cls.COOKIE)
+        if i != -1:
+            meta = ';' + line[i + len(cls.COOKIE):].strip('\n')
+        return meta
 
     @classmethod
     def from_file(cls, path, options):
         test = cls(path)
 
-        line = open(path).readline()
-        i = line.find(cls.COOKIE)
-        if i != -1:
-            meta = line[i + len(cls.COOKIE):].strip('\n')
+        # If directives.txt exists in the test's directory then it may
+        # contain metainformation that will be catenated with
+        # whatever's in the test file.  The form of the directive in
+        # the directive file is the same as in the test file.  Only
+        # the first line is considered, just as for the test file.
+
+        dir_meta = ''
+        dir_name = os.path.dirname(path)
+        if dir_name in cls.Directives:
+            dir_meta = cls.Directives[dir_name]
+        else:
+            meta_file_name = os.path.join(dir_name, "directives.txt")
+            if os.path.exists(meta_file_name):
+                dir_meta = cls.find_directives(meta_file_name)
+            cls.Directives[dir_name] = dir_meta
+
+        meta = cls.find_directives(path)
+        if meta != '' or dir_meta != '':
+            meta = meta + dir_meta
             parts = meta.split(';')
             for part in parts:
                 part = part.strip()
                 if not part:
                     continue
                 name, _, value = part.partition(':')
                 if value:
                     value = value.strip()