Bug 1496238 - Part 1: Allow runtime BinAST testing with jit_tests. (r=jorendorff)
authorEric Faust <efausbmo@gmail.com>
Tue, 09 Oct 2018 14:17:43 -0700
changeset 496108 105ad7200afcc1ed4429dfae3f0a62e29925db02
parent 496107 4e07d3243403123217539ce6d328641daa0513da
child 496109 4d07362984d4e00ef10251fa54e652426d87bfcf
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs1496238
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1496238 - Part 1: Allow runtime BinAST testing with jit_tests. (r=jorendorff)
js/src/shell/js.cpp
js/src/tests/lib/jittests.py
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -10342,16 +10342,18 @@ main(int argc, char** argv, char** envp)
     op.setDescriptionWidth(72);
     op.setHelpWidth(80);
     op.setVersion(JS_GetImplementationVersion());
 
     if (!op.addMultiStringOption('f', "file", "PATH", "File path to run")
         || !op.addMultiStringOption('m', "module", "PATH", "Module path to run")
 #if defined(JS_BUILD_BINAST)
         || !op.addMultiStringOption('B', "binast", "PATH", "BinAST path to run")
+#else
+        || !op.addMultiStringOption('B', "binast", "", "No-op")
 #endif // JS_BUILD_BINAST
         || !op.addMultiStringOption('e', "execute", "CODE", "Inline code to run")
         || !op.addBoolOption('i', "shell", "Enter prompt after running code")
         || !op.addBoolOption('c', "compileonly", "Only compile, don't run (syntax checking mode)")
         || !op.addBoolOption('w', "warnings", "Emit warnings")
         || !op.addBoolOption('W', "nowarnings", "Don't emit warnings")
         || !op.addBoolOption('s', "strict", "Check strictness")
         || !op.addBoolOption('D', "dump-bytecode", "Dump bytecode with exec count for all scripts")
--- a/js/src/tests/lib/jittests.py
+++ b/js/src/tests/lib/jittests.py
@@ -141,16 +141,17 @@ class JitTest:
         self.test_join = []
         # Errors to expect and consider passing
         self.expect_error = ''
         # Exit status to expect from shell
         self.expect_status = 0
         # Exit status or error output.
         self.expect_crash = False
         self.is_module = False
+        self.is_binast = False
         # Reflect.stringify implementation to test
         self.test_reflect_stringify = None
 
         # Expected by the test runner. Always true for jit-tests.
         self.enable = True
 
     def copy(self):
         t = JitTest(self.path)
@@ -167,16 +168,17 @@ class JitTest:
         t.test_also = self.test_also
         t.test_join = self.test_join
         t.expect_error = self.expect_error
         t.expect_status = self.expect_status
         t.expect_crash = self.expect_crash
         t.test_reflect_stringify = self.test_reflect_stringify
         t.enable = True
         t.is_module = self.is_module
+        t.is_binast = self.is_binast
         return t
 
     def copy_and_extend_jitflags(self, variant):
         t = self.copy()
         t.jitflags.extend(variant)
         return t
 
     def copy_variants(self, variants):
@@ -220,17 +222,26 @@ class JitTest:
         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)
+        file_extension = os.path.splitext(path)[1]
+        if file_extension == '.binjs':
+            # BinAST does not have an inline comment format, so it's hard
+            # to parse file-by-file directives. In future, we can look for
+            # an adjacent test-specific directives file, if we want.
+            meta = ''
+            test.is_binast = True
+        else:
+            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(':')
@@ -335,16 +346,20 @@ class JitTest:
         cmd += list(set(self.jitflags))
         for expr in exprs:
             cmd += ['-e', expr]
         for inc in self.other_includes:
             cmd += ['-f', libdir + inc]
         if self.is_module:
             cmd += ['--module-load-path', moduledir]
             cmd += ['--module', path]
+        elif self.is_binast:
+            # In builds with BinAST, this will run the test file. In builds without,
+            # It's a no-op and the tests will silently pass.
+            cmd += ['-B', path]
         elif self.test_reflect_stringify is None:
             cmd += ['-f', path]
         else:
             cmd += ['--', self.test_reflect_stringify, "--check", path]
 
         if self.valgrind:
             cmd = self.VALGRIND_CMD + cmd
 
@@ -364,17 +379,17 @@ class JitTest:
 def find_tests(substring=None):
     ans = []
     for dirpath, dirnames, filenames in os.walk(TEST_DIR):
         dirnames.sort()
         filenames.sort()
         if dirpath == '.':
             continue
         for filename in filenames:
-            if not filename.endswith('.js'):
+            if not (filename.endswith('.js') or filename.endswith('.binjs')):
                 continue
             if filename in ('shell.js', 'browser.js'):
                 continue
             test = os.path.join(dirpath, filename)
             if substring is None \
                or substring in os.path.relpath(test, TEST_DIR):
                 ans.append(test)
     return ans