Bug 786463 - Add TEST-START and TEST-END to output, r=mdas, DONTBUILD because NPOTB
authorJonathan Griffin <jgriffin@mozilla.com>
Wed, 29 Aug 2012 10:39:11 -0700
changeset 103800 616ff690fdc3549206135f1a701d18c2eb3d904f
parent 103799 24d9bb3d88f7b9916c8381523836572ecb85227e
child 103801 cff8f040f821edc1d368e1434703c0fe0e0334f9
push id23377
push useremorley@mozilla.com
push dateThu, 30 Aug 2012 10:30:05 +0000
treeherdermozilla-central@1b0b56afa33a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmdas, DONTBUILD
bugs786463
milestone18.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 786463 - Add TEST-START and TEST-END to output, r=mdas, DONTBUILD because NPOTB
testing/marionette/client/marionette/marionette_test.py
testing/marionette/client/marionette/runtests.py
testing/marionette/marionette-actors.js
--- a/testing/marionette/client/marionette/marionette_test.py
+++ b/testing/marionette/client/marionette/marionette_test.py
@@ -85,22 +85,36 @@ permissions.forEach(function (perm) {
         if self.marionette.session is not None:
             self.loglines = self.marionette.get_logs()
             self.perfdata = self.marionette.get_perf_data()
             self.marionette.delete_session()
         self.marionette = None
 
 class MarionetteTestCase(CommonTestCase):
 
-    def __init__(self, marionette_weakref, methodName='runTest', **kwargs):
+    def __init__(self, marionette_weakref, methodName='runTest',
+                 filepath='', **kwargs):
         self._marionette_weakref = marionette_weakref
         self.marionette = None
         self.extra_emulator_index = -1
+        self.methodName = methodName
+        self.filepath = filepath
         CommonTestCase.__init__(self, methodName, **kwargs)
 
+    def setUp(self):
+        CommonTestCase.setUp(self)
+        self.marionette.execute_script("log('TEST-START: %s:%s')" % 
+                                       (self.filepath, self.methodName))
+
+    def tearDown(self):
+        self.marionette.set_context("content")
+        self.marionette.execute_script("log('TEST-END: %s:%s')" % 
+                                       (self.filepath, self.methodName))
+        CommonTestCase.tearDown(self)
+
     def get_new_emulator(self):
         self.extra_emulator_index += 1
         if len(self.marionette.extra_emulators) == self.extra_emulator_index:
             qemu  = Marionette(emulator=self.marionette.emulator.arch,
                                emulatorBinary=self.marionette.emulator.binary,
                                homedir=self.marionette.homedir,
                                baseurl=self.marionette.baseurl,
                                noWindow=self.marionette.noWindow)
@@ -122,16 +136,17 @@ class MarionetteJSTestCase(CommonTestCas
         self.jsFile = jsFile
         self._marionette_weakref = marionette_weakref
         self.marionette = None
         CommonTestCase.__init__(self, methodName)
 
     def runTest(self):
         if self.marionette.session is None:
             self.marionette.start_session()
+        self.marionette.execute_script("log('TEST-START: %s');" % self.jsFile)
         f = open(self.jsFile, 'r')
         js = f.read()
         args = []
 
         # if this is a browser_ test, prepend head.js to it
         if os.path.basename(self.jsFile).startswith('browser_'):
             local_head = open(os.path.join(os.path.dirname(__file__), 'tests', 'head.js'), 'r')
             js = local_head.read() + js
@@ -192,11 +207,12 @@ class MarionetteJSTestCase(CommonTestCas
         except ScriptTimeoutException:
             if 'timeout' in self.jsFile:
                 # expected exception
                 pass
             else:
                 self.loglines = self.marionette.get_logs()
                 raise
 
+        self.marionette.execute_script("log('TEST-END: %s');" % self.jsFile)
 
 
 
--- a/testing/marionette/client/marionette/runtests.py
+++ b/testing/marionette/client/marionette/runtests.py
@@ -390,17 +390,19 @@ class MarionetteTestRunner(object):
             test_mod = imp.load_source(mod_name, filepath)
 
             for name in dir(test_mod):
                 obj = getattr(test_mod, name)
                 if (isinstance(obj, (type, types.ClassType)) and
                     issubclass(obj, unittest.TestCase)):
                     testnames = testloader.getTestCaseNames(obj)
                     for testname in testnames:
-                        suite.addTest(obj(weakref.ref(self.marionette), methodName=testname))
+                        suite.addTest(obj(weakref.ref(self.marionette),
+                                      methodName=testname,
+                                      filepath=filepath))
 
         elif file_ext == '.js':
             suite.addTest(MarionetteJSTestCase(weakref.ref(self.marionette), jsFile=filepath))
 
         if suite.countTestCases():
             results = MarionetteTextTestRunner(verbosity=3).run(suite)
             self.results.append(results)
 
--- a/testing/marionette/marionette-actors.js
+++ b/testing/marionette/marionette-actors.js
@@ -629,17 +629,20 @@ MarionetteDriverActor.prototype = {
       if (aRequest.timeout) {
         this.executeWithCallback(aRequest, aRequest.timeout);
       }
       else {
         this.execute(aRequest, true);
       }
     }
     else {
-      this.sendAsync("executeJSScript", {value:aRequest.value, args:aRequest.args, timeout:aRequest.timeout});
+      this.sendAsync("executeJSScript", { value:aRequest.value,
+                                          args:aRequest.args,
+                                          newSandbox:aRequest.newSandbox,
+                                          timeout:aRequest.timeout });
    }
   },
 
   /**
    * This function is used by executeAsync and executeJSScript to execute a script
    * in a sandbox. 
    * 
    * For executeJSScript, it will return a message only when the finish() method is called.