summaryrefslogtreecommitdiff
path: root/test-bugzilla-files/test-bugzilla-files.py
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2013-02-17 23:16:18 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2013-02-17 23:16:18 +0100
commit39ec29e0432b4a16f66aae71457807a6386096f2 (patch)
treee262b26244eef04ed84a56eef849876d983f2014 /test-bugzilla-files/test-bugzilla-files.py
parentf77e09c7faed8cb244e4a5c5373041652a4fb8d3 (diff)
fix some problems with test-bugzilla-files script
Diffstat (limited to 'test-bugzilla-files/test-bugzilla-files.py')
-rw-r--r--test-bugzilla-files/test-bugzilla-files.py80
1 files changed, 54 insertions, 26 deletions
diff --git a/test-bugzilla-files/test-bugzilla-files.py b/test-bugzilla-files/test-bugzilla-files.py
index f66a5e73..bcd33fc4 100644
--- a/test-bugzilla-files/test-bugzilla-files.py
+++ b/test-bugzilla-files/test-bugzilla-files.py
@@ -31,6 +31,7 @@ import subprocess
import sys
import time
import uuid
+import datetime
import signal
import threading
@@ -267,11 +268,12 @@ def loadFromURL(xContext, url, connection):
try:
xDoc = None
xDoc = xDesktop.loadComponentFromURL(url, "_blank", 0, loadProps)
- while True:
+ time_ = 0
+ while time_ < 30:
if xListener.layoutFinished:
- t.cancel()
return xDoc
print("delaying...")
+ time_ += 1
time.sleep(1)
except pyuno.getClass("com.sun.star.beans.UnknownPropertyException"):
xListener = None
@@ -298,42 +300,42 @@ def handleCrash(file):
# crashed_files.append(file)
# add here the remaining handling code for crashed files
-class Alarm(Exception):
- pass
-
def alarm_handler():
os.system("killall -9 soffice.bin")
class LoadFileTest:
- def __init__(self, file, stateNew):
+ def __init__(self, file, state):
self.file = file
- self.stateNew = stateNew
+ self.state = state
def run(self, xContext, connection):
print("Loading document: " + self.file)
t = None
try:
url = "file://" + quote(self.file)
xDoc = None
- t = threading.Timer(5, alarm_handler)
+ t = threading.Timer(40, alarm_handler)
t.start()
xDoc = loadFromURL(xContext, url, connection)
+ self.state.goodFiles.append(self.file)
except pyuno.getClass("com.sun.star.beans.UnknownPropertyException"):
print("caught UnknownPropertyException " + self.file)
if not t.is_alive():
- t.cancel()
print("TIMEOUT!")
- t.cancel()
- handleCrash(self.file)
- self.stateNew.badFiles.append(self.file)
+ self.state.timeoutFiles.append(self.file)
+ else:
+ t.cancel()
+ handleCrash(self.file)
+ self.state.badFiles.append(self.file)
connection.setUp()
except pyuno.getClass("com.sun.star.lang.DisposedException"):
print("caught DisposedException " + self.file)
if not t.is_alive():
print("TIMEOUT!")
+ self.state.timeoutFiles.append(self.file)
else:
t.cancel()
handleCrash(self.file)
- self.stateNew.badFiles.append(self.file)
+ self.state.badFiles.append(self.file)
connection.tearDown()
connection.setUp()
finally:
@@ -347,24 +349,50 @@ class State:
def __init__(self):
self.goodFiles = []
self.badFiles = []
- self.unknown = []
+ self.timeoutFiles = []
validFileExtensions = [ ".docx" , ".rtf", ".odt", ".doc" ]
+def writeReport(state, startTime):
+ goodFiles = open("goodFiles.log", "w")
+ goodFiles.write("All files tested which opened perfectly:\n")
+ goodFiles.write("Starttime: " + startTime.isoformat() +"\n")
+ for file in state.goodFiles:
+ goodFiles.write(file)
+ goodFiles.write("\n")
+ goodFiles.close()
+ badFiles = open("badFiles.log", "w")
+ badFiles.write("All files tested which crashed:\n")
+ badFiles.write("Starttime: " + startTime.isoformat() + "\n")
+ for file in state.badFiles:
+ badFiles.write(file)
+ badFiles.write("\n")
+ badFiles.close()
+ timeoutFiles = open("timeoutFiles.log", "w")
+ timeoutFiles.write("All files tested which timed out:\n")
+ timeoutFiles.write("Starttime: " + startTime.isoformat() + "\n")
+ for file in state.timeoutFiles:
+ timeoutFiles.write(file)
+ timeoutFiles.write("\n")
+ timeoutFiles.close()
+
+
+
def runLoadFileTests(opts, dirs):
- files = []
- for suffix in validFileExtensions:
- files.extend(getFiles(dirs, suffix))
- files.sort()
- stateNew = State() #create stateNew instance
- tests = (LoadFileTest(file, stateNew) for file in files)
- connection = PersistentConnection(opts)
- runConnectionTests(connection, simpleInvoke, tests)
- connection.tearDown()
- print(stateNew.goodFiles)
- print(stateNew.badFiles)
- print(stateNew.unknown)
+ startTime = datetime.datetime.now()
+ try:
+ files = []
+ for suffix in validFileExtensions:
+ files.extend(getFiles(dirs, suffix))
+ files.sort()
+ state = State()
+ tests = (LoadFileTest(file, state) for file in files)
+ connection = PersistentConnection(opts)
+ runConnectionTests(connection, simpleInvoke, tests)
+ connection.tearDown()
+ finally:
+ writeReport(state, startTime)
def parseArgs(argv):
(optlist,args) = getopt.getopt(argv[1:], "hr",