Browse files

Bug 679490 jetpack reports success for test runs that fail p=lsblakk …

…r=armenzg
  • Loading branch information...
1 parent 1653978 commit 5925107dd05b46ef924bd06c8a3593ea181cfbf5 @lsblakk lsblakk committed Sep 21, 2011
Showing with 55 additions and 1 deletion.
  1. +54 −1 buildfarm/utils/run_jetpack.py
  2. +1 −0 sut_tools/sut_lib.py
View
55 buildfarm/utils/run_jetpack.py
@@ -5,12 +5,60 @@
executable of whatever valid platform is passed.
"""
import os, sys, urllib, shutil, re
+import logging, subprocess
from optparse import OptionParser
SDK_TARBALL="addonsdk.tar.bz2"
POLLER_DIR="addonsdk-poller"
SDK_DIR="jetpack"
+log = logging.getLogger()
+# copied runCommand from tools/sut_tools/sut_lib.py
+def runCommand(cmd, env=None, logEcho=True):
+ """Execute the given command.
+ Sends to the logger all stdout and stderr output.
+ """
+ log.debug('calling [%s]' % ' '.join(cmd))
+
+ o = []
+ p = subprocess.Popen(cmd, env=env, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+
+ try:
+ for item in p.stdout:
+ o.append(item[:-1])
+ if logEcho:
+ log.debug(item[:-1])
+ p.wait()
+ except KeyboardInterrupt:
+ p.kill()
+ p.wait()
+
+ return p, o
+
+def emphasizeFailureText(text):
+ return '<em class="testfail">%s</em>' % text
+
+def summarizeJetpackTestLog(name, log):
+ infoRe = re.compile(r"(\d+) of (\d+) tests passed")
+ successCount = 0
+ failCount = 0
+ totalCount = 0
+ summary=""
+ for line in log:
+ m = infoRe.match(line)
+ if m:
+ successCount += int(m.group(1))
+ totalCount += int(m.group(2))
+ failCount = int(totalCount - successCount)
+ # Handle failCount.
+ failCountStr = str(failCount)
+ if failCount > 0:
+ failCountStr = emphasizeFailureText(failCountStr)
+ # Format the counts
+ summary = "%d/%d" % (totalCount, failCount)
+ # Return the summary.
+ return "TinderboxPrint:%s<br />%s\n" % (name, summary)
+
if __name__ == '__main__':
is_poller = False
untar_args=''
@@ -133,7 +181,12 @@
# Run it!
if sdkdir:
os.chdir(sdkdir)
- os.system('python bin/cfx --verbose testall -a firefox -b %s' % app_path)
+ args = ['python', 'bin/cfx', '--verbose', 'testall', '-a', 'firefox', '-b', app_path]
+ process, output = runCommand(args)
+ print '\n'.join(output)
+ if is_poller:
+ print summarizeJetpackTestLog("Jetpack",output)
+ sys.exit(process.returncode)
else:
print "SDK_DIR is either missing or invalid."
sys.exit(1)
View
1 sut_tools/sut_lib.py
@@ -36,6 +36,7 @@ def dumpException(msg):
log.debug(s[:-1])
log.debug('Traceback End')
+# copied runCommand to tools/buildfarm/utils/run_jetpack.py
def runCommand(cmd, env=None, logEcho=True):
"""Execute the given command.
Sends to the logger all stdout and stderr output.

0 comments on commit 5925107

Please sign in to comment.