Index: test/mjsunit/testcfg.py |
diff --git a/test/mjsunit/testcfg.py b/test/mjsunit/testcfg.py |
index 5a2f31481edeb43d4130351bae600bb143b69c60..21139562e7bf539c64464f8180553a6e55279243 100644 |
--- a/test/mjsunit/testcfg.py |
+++ b/test/mjsunit/testcfg.py |
@@ -25,17 +25,88 @@ |
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
-import test |
import os |
-from os.path import join, dirname, exists |
import re |
-import tempfile |
+ |
+from testrunner.local import testsuite |
+from testrunner.objects import testcase |
FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)") |
FILES_PATTERN = re.compile(r"//\s+Files:(.*)") |
SELF_SCRIPT_PATTERN = re.compile(r"//\s+Env: TEST_FILE_NAME") |
+class MjsunitTestSuite(testsuite.TestSuite): |
+ |
+ def __init__(self, name, root): |
+ super(MjsunitTestSuite, self).__init__(name, root) |
+ |
+ def ListTests(self, context): |
+ tests = [] |
+ for dirname, dirs, files in os.walk(self.root): |
+ for dotted in [x for x in dirs if x.startswith('.')]: |
+ dirs.remove(dotted) |
+ dirs.sort() |
+ files.sort() |
+ for filename in files: |
+ if filename.endswith(".js") and filename != "mjsunit.js": |
+ testname = join(dirname[len(self.root) + 1:], filename[:-3]) |
+ test = testcase.TestCase(self, testname) |
+ tests.append(test) |
+ return tests |
+ |
+ def GetFlagsForTestCase(self, testcase, context): |
+ source = self.GetSourceForTest(testcase) |
+ flags = [] |
+ flags_match = re.findall(FLAGS_PATTERN, source) |
+ for match in flags_match: |
+ flags += match.strip().split() |
+ flags += context.mode_flags |
+ |
+ files_list = [] # List of file names to append to command arguments. |
+ files_match = FILES_PATTERN.search(source); |
+ # Accept several lines of 'Files:'. |
+ while True: |
+ if files_match: |
+ files_list += files_match.group(1).strip().split() |
+ files_match = FILES_PATTERN.search(source, files_match.end()) |
+ else: |
+ break |
+ files = [ os.path.normpath(os.path.join(self.root, '..', '..', f)) |
+ for f in files_list ] |
+ testfilename = os.path.join(self.root, testcase.path + self.suffix()) |
+ if SELF_SCRIPT_PATTERN.search(source): |
+ env = ["-e", "TEST_FILE_NAME=\"%s\"" % testfilename] |
+ files = env + files |
+ files.append(os.path.join(self.root, "mjsunit.js")) |
+ files.append(testfilename) |
+ |
+ flags += files |
+ if context.isolates: |
+ flags.append("--isolate") |
+ flags += files |
+ |
+ return testcase.flags + flags |
+ |
+ def GetSourceForTest(self, testcase): |
+ filename = os.path.join(self.root, testcase.path + self.suffix()) |
+ with open(filename) as f: |
+ return f.read() |
+ |
+ |
+def GetSuite(name, root): |
+ return MjsunitTestSuite(name, root) |
+ |
+ |
+# Deprecated definitions below. |
+# TODO(jkummerow): Remove when SCons is no longer supported. |
+ |
+ |
+from os.path import dirname, exists, join, normpath |
+import tempfile |
+import test |
+ |
+ |
class MjsunitTestCase(test.TestCase): |
def __init__(self, path, file, mode, context, config, isolates): |