strongwind r26 - in trunk: . resources strongwind



Author: jtai
Date: Wed Oct  8 22:22:52 2008
New Revision: 26
URL: http://svn.gnome.org/viewvc/strongwind?rev=26&view=rev

Log:
2008-10-08  Jonathan Tai  <jon tgpsolutions com>

	* strongwind/procedurelogger.py:
	* resources/procedures.xsl:
	Keep track of how long it takes for a test to run (#555286, Brian G. Merrell)


Modified:
   trunk/ChangeLog
   trunk/resources/procedures.xsl
   trunk/strongwind/procedurelogger.py

Modified: trunk/resources/procedures.xsl
==============================================================================
--- trunk/resources/procedures.xsl	(original)
+++ trunk/resources/procedures.xsl	Wed Oct  8 22:22:52 2008
@@ -12,6 +12,69 @@
         <span id="testName"><xsl:value-of select="test/name"/></span><br/>
         <span id="documentName">Strongwind Test Script</span><br/>
         <span id="testDescription"><xsl:value-of select="test/description"/></span><br/>
+        <xsl:comment>Convert the number of seconds it took the test to run into
+        days, hours, minutes, and seconds</xsl:comment>
+        <xsl:variable name="numDays" select="floor(number(test/time) div 86400)"/>
+        <xsl:variable name="tmpSec1" select="number(test/time) mod 86400"/>
+        <xsl:variable name="numHours" select="floor($tmpSec1 div 3600)"/>
+        <xsl:variable name="tmpSec2" select="$tmpSec1 mod 3600"/>
+        <xsl:variable name="numMinutes" select="floor($tmpSec2 div 60)"/>
+        <xsl:variable name="numSeconds" select="format-number(number(test/time) mod 60, '#.#')"/>
+        <xsl:comment>Finished converting</xsl:comment>
+        <span id="testTimeText">Estimated Run Time: </span>
+        <xsl:if test="$numDays > 0">
+            <span id="days"><xsl:value-of select="$numDays"/></span>
+          <xsl:choose>
+            <xsl:when test="$numDays = 1">
+              <span id="timeDays"> Day</span>
+            </xsl:when>
+            <xsl:otherwise>
+              <span id="timeDays"> Days</span>
+            </xsl:otherwise>
+          </xsl:choose>
+          <xsl:if test="($numHours > 0) or ($numMinutes > 0) or ($numSeconds > 0)">
+            <span>, </span>
+          </xsl:if>
+        </xsl:if>
+        <xsl:if test="$numHours > 0">
+            <span id="hours"><xsl:value-of select="$numHours"/></span>
+          <xsl:choose>
+            <xsl:when test="$numHours = 1">
+              <span id="timeHours"> Hour</span>
+            </xsl:when>
+            <xsl:otherwise>
+              <span id="timeHours"> Hours</span>
+            </xsl:otherwise>
+          </xsl:choose>
+          <xsl:if test="($numMinutes > 0) or ($numSeconds > 0)">
+            <span>, </span>
+          </xsl:if>
+        </xsl:if>
+        <xsl:if test="$numMinutes > 0">
+            <span id="minutes"><xsl:value-of select="$numMinutes"/></span>
+          <xsl:choose>
+            <xsl:when test="$numMinutes = 1">
+              <span id="timeMinutes"> Minute</span>
+            </xsl:when>
+            <xsl:otherwise>
+              <span id="timeMinutes"> Minutes</span>
+            </xsl:otherwise>
+          </xsl:choose>
+          <xsl:if test="$numSeconds > 0">
+            <span>, </span>
+          </xsl:if>
+        </xsl:if>
+        <xsl:if test="$numSeconds > 0">
+            <span id="seconds"><xsl:value-of select="$numSeconds"/></span>
+          <xsl:choose>
+            <xsl:when test="numSeconds = 1">
+              <span id="timeSeconds"> Second</span>
+            </xsl:when>
+            <xsl:otherwise>
+              <span id="timeSeconds"> Seconds</span>
+            </xsl:otherwise>
+          </xsl:choose>
+        </xsl:if><br/>
       </p>
 
       <hr/>

Modified: trunk/strongwind/procedurelogger.py
==============================================================================
--- trunk/strongwind/procedurelogger.py	(original)
+++ trunk/strongwind/procedurelogger.py	Wed Oct  8 22:22:52 2008
@@ -42,6 +42,7 @@
 
 import os
 import sys
+import time
 
 try:
     import yaml
@@ -70,13 +71,15 @@
 import watchdog
 
 
-
 _procedures = []
 _actionBuffer = ''
 _expectedResultBuffer = ''
 
 _oldParents = []
 
+_start_time = time.time()
+
+
 # roles we want to search up the tree for
 _containerParentRoles = [
     pyatspi.ROLE_APPLICATION,
@@ -247,6 +250,9 @@
     'Save logged actions and expected results to an XML file'
 
     global _expectedResultBuffer
+    global _start_time
+
+    elapsed_time = time.time() - _start_time
 
     try:
         _expectedResultBuffer += ''.join(traceback.format_exception(sys.last_type, sys.last_value, sys.last_traceback))
@@ -282,6 +288,8 @@
         if config.TAKE_SCREENSHOTS:
             ET.SubElement(step, 'screenshot').text = p[2]
 
+    ET.SubElement(root, 'time').text = str(elapsed_time)
+
     assert os.path.isdir(config.OUTPUT_DIR)
 
     file = open(os.path.join(config.OUTPUT_DIR, 'procedures.xml'), 'w')
@@ -290,8 +298,6 @@
     ET.ElementTree(root).write(file)
     file.close()
 
-
-
 def _getTestInfo():
     "Inspect the file being executed to determine the test's name, description, and parameters"
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]