Author: [EMAIL PROTECTED]
Date: Thu Sep 25 05:38:34 2008
New Revision: 375

Added:
    branches/bleeding_edge/test/mjsunit/bugs/bug-86.js
    branches/bleeding_edge/test/mjsunit/bugs/bug-87.js
Modified:
    branches/bleeding_edge/samples/shell.cc
    branches/bleeding_edge/tools/test.py

Log:
- Added support for warnings on unused test rules.
- Added automatic loading of test suites


Modified: branches/bleeding_edge/samples/shell.cc
==============================================================================
--- branches/bleeding_edge/samples/shell.cc     (original)
+++ branches/bleeding_edge/samples/shell.cc     Thu Sep 25 05:38:34 2008
@@ -73,6 +73,14 @@
        continue;
      } else if (strncmp(str, "--", 2) == 0) {
        printf("Warning: unknown flag %s.\n", str);
+    } else if (strcmp(str, "-e") == 0 && i + 1 < argc) {
+      // Execute argument given to -e option directly
+      v8::HandleScope handle_scope;
+      v8::Handle<v8::String> file_name = v8::String::New("unnamed");
+      v8::Handle<v8::String> source = v8::String::New(argv[i + 1]);
+      if (!ExecuteString(source, file_name, false, true))
+        return 1;
+      i++;
      } else {
        // Use all other arguments as names of files to load and run.
        v8::HandleScope handle_scope;

Added: branches/bleeding_edge/test/mjsunit/bugs/bug-86.js
==============================================================================
--- (empty file)
+++ branches/bleeding_edge/test/mjsunit/bugs/bug-86.js  Thu Sep 25 05:38:34  
2008
@@ -0,0 +1,17 @@
+var aList = [1, 2, 3];
+var loopCount = 0;
+var leftThroughFinally = false;
+for (x in aList) {
+  leftThroughFinally = false;
+  try {
+    throw "ex1";
+  } catch(er1) {
+    loopCount += 1;
+  } finally {
+    enteredFinally = true;
+    continue;
+  }
+  leftThroughFinally = false;
+}
+assertEquals(loopCount, 3);
+assertTrue(enteredFinally);

Added: branches/bleeding_edge/test/mjsunit/bugs/bug-87.js
==============================================================================
--- (empty file)
+++ branches/bleeding_edge/test/mjsunit/bugs/bug-87.js  Thu Sep 25 05:38:34  
2008
@@ -0,0 +1,2 @@
+assertTrue((/(?:)/g).global);
+assertTrue((/(?:)/\u0067).global);

Modified: branches/bleeding_edge/tools/test.py
==============================================================================
--- branches/bleeding_edge/tools/test.py        (original)
+++ branches/bleeding_edge/tools/test.py        Thu Sep 25 05:38:34 2008
@@ -30,7 +30,7 @@
  import imp
  import optparse
  import os
-from os.path import join, dirname, abspath, basename
+from os.path import join, dirname, abspath, basename, isdir
  import platform
  import re
  import signal
@@ -59,6 +59,17 @@
      self.total = len(self.cases)
      self.failed_tests = [ ]

+  def PrintFailureHeader(self, test):
+    if test.IsNegative():
+      negative_marker = '[negative] '
+    else:
+      negative_marker = ''
+    print "=== %(label)s %(negative)s===" % {
+      'label': test.GetLabel(),
+      'negative': negative_marker
+    }
+    print "Path: %s" % "/".join(test.path)
+
    def Run(self):
      self.Starting()
      for test in self.cases:
@@ -96,7 +107,7 @@
    def Done(self):
      print
      for failed in self.failed_tests:
-      print "=== %s (%s) ===" %  
(failed.test.GetLabel(), "/".join(failed.test.path))
+      self.PrintFailureHeader(failed.test)
        if failed.output.stderr:
          print "--- stderr ---"
          print failed.output.stderr.strip()
@@ -164,7 +175,8 @@

    def HasRun(self, output):
      if output.UnexpectedOutput():
-      print "=== %s (%s) ===" %  
(output.test.GetLabel(), "/".join(output.test.path))
+      self.ClearLine(self.last_status_length)
+      self.PrintFailureHeader(output.test)
        print "Command: %s" % EscapeCommand(output.command)
        stdout = output.output.stdout.strip()
        if len(stdout):
@@ -828,6 +840,7 @@
      all_rules = reduce(list.__add__, [s.rules for s in sections], [])
      unused_rules = set(all_rules)
      result = [ ]
+    all_outcomes = set([])
      for case in cases:
        matches = [ r for r in all_rules if r.Contains(case.path) ]
        outcomes = set([])
@@ -837,8 +850,9 @@
        if not outcomes:
          outcomes = [PASS]
        case.outcomes = outcomes
+      all_outcomes = all_outcomes.union(outcomes)
        result.append(ClassifiedTest(case, outcomes))
-    return (result, list(unused_rules))
+    return (result, list(unused_rules), all_outcomes)


  class Section(object):
@@ -955,6 +969,8 @@
    result.add_option("--special-command", default=None)
    result.add_option("--cat", help="Print the source of the tests",
        default=False, action="store_true")
+  result.add_option("--warn-unused", help="Report unused rules",
+      default=False, action="store_true")
    return result


@@ -1047,6 +1063,10 @@
  BUILT_IN_TESTS = ['mjsunit', 'cctest']


+def GetSuites(test_root):
+  return [ f for f in os.listdir(test_root) if isdir(join(test_root, f)) ]
+
+
  def Main():
    parser = BuildOptions()
    (options, args) = parser.parse_args()
@@ -1055,7 +1075,8 @@
      return 1

    workspace = abspath(join(dirname(sys.argv[0]), '..'))
-  repositories = [TestRepository(join(workspace, 'test', name)) for name  
in BUILT_IN_TESTS]
+  suites = GetSuites(join(workspace, 'test'))
+  repositories = [TestRepository(join(workspace, 'test', name)) for name  
in suites]
    repositories += [TestRepository(a) for a in options.suite]

    root = LiteralTestSuite(repositories)
@@ -1092,6 +1113,7 @@
    all_cases = [ ]
    all_unused = [ ]
    unclassified_tests = [ ]
+  globally_unused_rules = None
    for path in paths:
      for mode in options.mode:
        env = {
@@ -1101,7 +1123,11 @@
        }
        test_list = root.ListTests([], path, context, mode)
        unclassified_tests += test_list
-      (cases, unused_rules) = config.ClassifyTests(test_list, env)
+      (cases, unused_rules, all_outcomes) =  
config.ClassifyTests(test_list, env)
+      if globally_unused_rules is None:
+        globally_unused_rules = set(unused_rules)
+      else:
+        globally_unused_rules =  
globally_unused_rules.intersection(unused_rules)
        all_cases += cases
        all_unused.append(unused_rules)

@@ -1118,8 +1144,9 @@
        print "--- end source: %s ---" % test.GetLabel()
      return 0

-#  for rule in unused_rules:
-#    print "Rule for '%s' was not used." % '/'.join([str(s) for s in  
rule.path])
+  if options.warn_unused:
+    for rule in globally_unused_rules:
+      print "Rule for '%s' was not used." % '/'.join([str(s) for s in  
rule.path])

    if options.report:
      PrintReport(all_cases)

--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to