Back to index

enigmail  1.4.3
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions
build.automationutils.ShutdownLeakLogger Class Reference

List of all members.

Public Member Functions

def __init__
def log
def parse

Public Attributes

 logger
 tests
 leakedWindows
 leakedDocShells
 currentTest
 seenShutdown

Static Public Attributes

int MAX_LEAK_COUNT = 121

Private Member Functions

def _logWindow
def _logDocShell
def _parseValue
def _parseLeakingTests
def _zipLeakedWindows

Detailed Description

Parses the mochitest run log when running a debug build, assigns all leaked
DOM windows (that are still around after test suite shutdown, despite running
the GC) to the tests that created them and prints leak statistics.

Definition at line 456 of file automationutils.py.


Constructor & Destructor Documentation

Definition at line 464 of file automationutils.py.

00464 
00465   def __init__(self, logger):
00466     self.logger = logger
00467     self.tests = []
00468     self.leakedWindows = {}
00469     self.leakedDocShells = set()
00470     self.currentTest = None
00471     self.seenShutdown = False


Member Function Documentation

def build.automationutils.ShutdownLeakLogger._logDocShell (   self,
  line 
) [private]

Definition at line 523 of file automationutils.py.

00523 
00524   def _logDocShell(self, line):
00525     created = line[:2] == "++"
00526     id = self._parseValue(line, "id")
00527 
00528     # log line has invalid format
00529     if not id:
00530       return
00531 
00532     if self.currentTest:
00533       docShells = self.currentTest["docShells"]
00534       if created:
00535         docShells.add(id)
00536       else:
00537         docShells.discard(id)
00538     elif self.seenShutdown and not created:
00539       self.leakedDocShells.add(id)

Here is the call graph for this function:

Here is the caller graph for this function:

def build.automationutils.ShutdownLeakLogger._logWindow (   self,
  line 
) [private]

Definition at line 506 of file automationutils.py.

00506 
00507   def _logWindow(self, line):
00508     created = line[:2] == "++"
00509     id = self._parseValue(line, "serial")
00510 
00511     # log line has invalid format
00512     if not id:
00513       return
00514 
00515     if self.currentTest:
00516       windows = self.currentTest["windows"]
00517       if created:
00518         windows.add(id)
00519       else:
00520         windows.discard(id)
00521     elif self.seenShutdown and not created:
00522       self.leakedWindows[id] = self._parseValue(line, "url")

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 545 of file automationutils.py.

00545 
00546   def _parseLeakingTests(self):
00547     leakingTests = []
00548 
00549     for test in self.tests:
00550       test["leakedWindows"] = [self.leakedWindows[id] for id in test["windows"] if id in self.leakedWindows]
00551       test["leakedDocShells"] = [id for id in test["docShells"] if id in self.leakedDocShells]
00552       test["leakCount"] = len(test["leakedWindows"]) + len(test["leakedDocShells"])
00553 
00554       if test["leakCount"]:
00555         leakingTests.append(test)
00556 
00557     return sorted(leakingTests, key=itemgetter("leakCount"), reverse=True)

Here is the caller graph for this function:

def build.automationutils.ShutdownLeakLogger._parseValue (   self,
  line,
  name 
) [private]

Definition at line 540 of file automationutils.py.

00540 
00541   def _parseValue(self, line, name):
00542     match = re.search("\[%s = (.+?)\]" % name, line)
00543     if match:
00544       return match.group(1)

Here is the caller graph for this function:

def build.automationutils.ShutdownLeakLogger._zipLeakedWindows (   self,
  leakedWindows 
) [private]

Definition at line 558 of file automationutils.py.

00558 
00559   def _zipLeakedWindows(self, leakedWindows):
00560     counts = []
00561     counted = set()
00562 
00563     for url in leakedWindows:
00564       if not url in counted:
00565         counts.append((url, leakedWindows.count(url)))
00566         counted.add(url)
00567 
00568     return sorted(counts, key=itemgetter(1), reverse=True)

Here is the caller graph for this function:

Definition at line 472 of file automationutils.py.

00472 
00473   def log(self, line):
00474     if line[2:11] == "DOMWINDOW":
00475       self._logWindow(line)
00476     elif line[2:10] == "DOCSHELL":
00477       self._logDocShell(line)
00478     elif line.startswith("TEST-START"):
00479       fileName = line.split(" ")[-1].strip().replace("chrome://mochitests/content/browser/", "")
00480       self.currentTest = {"fileName": fileName, "windows": set(), "docShells": set()}
00481     elif line.startswith("INFO TEST-END"):
00482       # don't track a test if no windows or docShells leaked
00483       if self.currentTest["windows"] or self.currentTest["docShells"]:
00484         self.tests.append(self.currentTest)
00485       self.currentTest = None
00486     elif line.startswith("INFO TEST-START | Shutdown"):
00487       self.seenShutdown = True

Here is the call graph for this function:

Definition at line 488 of file automationutils.py.

00488 
00489   def parse(self):
00490     leakingTests = self._parseLeakingTests()
00491 
00492     if leakingTests:
00493       totalWindows = sum(len(test["leakedWindows"]) for test in leakingTests)
00494       totalDocShells = sum(len(test["leakedDocShells"]) for test in leakingTests)
00495       msgType = "INFO" if totalWindows + totalDocShells <= self.MAX_LEAK_COUNT else "UNEXPECTED-FAIL"
00496       self.logger.info("TEST-%s | ShutdownLeaks | leaked %d DOMWindow(s) and %d DocShell(s) until shutdown", msgType, totalWindows, totalDocShells)
00497 
00498     for test in leakingTests:
00499       self.logger.info("\n[%s]", test["fileName"])
00500 
00501       for url, count in self._zipLeakedWindows(test["leakedWindows"]):
00502         self.logger.info("  %d window(s) [url = %s]", count, url)
00503 
00504       if test["leakedDocShells"]:
00505         self.logger.info("  %d docShell(s)", len(test["leakedDocShells"]))

Here is the call graph for this function:


Member Data Documentation

Definition at line 469 of file automationutils.py.

Definition at line 468 of file automationutils.py.

Definition at line 467 of file automationutils.py.

Definition at line 465 of file automationutils.py.

Definition at line 462 of file automationutils.py.

Definition at line 470 of file automationutils.py.

Definition at line 466 of file automationutils.py.


The documentation for this class was generated from the following file: