[Libreoffice-commits] .: 2 commits - test-bugzilla-files/test-bugzilla-files.py
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Sun Feb 17 09:07:03 PST 2013
test-bugzilla-files/test-bugzilla-files.py | 88 +++++++++++++++--------------
1 file changed, 46 insertions(+), 42 deletions(-)
New commits:
commit f77e09c7faed8cb244e4a5c5373041652a4fb8d3
Author: jorendc <joren.libreoffice at telenet.be>
Date: Sun Dec 30 02:50:18 2012 +0100
add Class State which creates 3 lists that we need to compare later
Conflicts:
test-bugzilla-files/test-bugzilla-files.py
diff --git a/test-bugzilla-files/test-bugzilla-files.py b/test-bugzilla-files/test-bugzilla-files.py
index 62122a5..f66a5e7 100644
--- a/test-bugzilla-files/test-bugzilla-files.py
+++ b/test-bugzilla-files/test-bugzilla-files.py
@@ -149,12 +149,10 @@ class OfficeConnection:
print("...done")
# except com.sun.star.lang.DisposedException:
except pyuno.getClass("com.sun.star.beans.UnknownPropertyException"):
- print("caught UnknownPropertyException")
- print("crashed")
+ print("caught UnknownPropertyException while TearDown")
pass # ignore, also means disposed
except pyuno.getClass("com.sun.star.lang.DisposedException"):
- print("caught DisposedException")
- print("crashed")
+ print("caught DisposedException while TearDown")
pass # ignore
else:
self.soffice.terminate()
@@ -292,12 +290,12 @@ def loadFromURL(xContext, url, connection):
if xListener:
xGEB.removeDocumentEventListener(xListener)
-def handleCrash(file, crashed_files):
+def handleCrash(file):
print("File: " + file + " crashed")
crashLog = open("crashlog.txt", "a")
crashLog.write('Crash:' + file + '\n')
crashLog.close()
- crashed_files.append(file)
+# crashed_files.append(file)
# add here the remaining handling code for crashed files
class Alarm(Exception):
@@ -307,9 +305,9 @@ def alarm_handler():
os.system("killall -9 soffice.bin")
class LoadFileTest:
- def __init__(self, file, crashed_files):
+ def __init__(self, file, stateNew):
self.file = file
- self.crashed_files = crashed_files
+ self.stateNew = stateNew
def run(self, xContext, connection):
print("Loading document: " + self.file)
t = None
@@ -325,7 +323,8 @@ class LoadFileTest:
t.cancel()
print("TIMEOUT!")
t.cancel()
- handleCrash(self.file, self.crashed_files)
+ handleCrash(self.file)
+ self.stateNew.badFiles.append(self.file)
connection.setUp()
except pyuno.getClass("com.sun.star.lang.DisposedException"):
print("caught DisposedException " + self.file)
@@ -333,7 +332,8 @@ class LoadFileTest:
print("TIMEOUT!")
else:
t.cancel()
- handleCrash(self.file, self.crashed_files)
+ handleCrash(self.file)
+ self.stateNew.badFiles.append(self.file)
connection.tearDown()
connection.setUp()
finally:
@@ -342,6 +342,13 @@ class LoadFileTest:
if xDoc:
xDoc.close(True)
print("...done with: " + self.file)
+
+class State:
+ def __init__(self):
+ self.goodFiles = []
+ self.badFiles = []
+ self.unknown = []
+
validFileExtensions = [ ".docx" , ".rtf", ".odt", ".doc" ]
@@ -350,13 +357,14 @@ def runLoadFileTests(opts, dirs):
for suffix in validFileExtensions:
files.extend(getFiles(dirs, suffix))
files.sort()
- crashed_files = []
- tests = (LoadFileTest(file, crashed_files) for file in files)
+ stateNew = State() #create stateNew instance
+ tests = (LoadFileTest(file, stateNew) for file in files)
connection = PersistentConnection(opts)
-# connection = PerTestConnection(opts)
runConnectionTests(connection, simpleInvoke, tests)
connection.tearDown()
- print(crashed_files)
+ print(stateNew.goodFiles)
+ print(stateNew.badFiles)
+ print(stateNew.unknown)
def parseArgs(argv):
(optlist,args) = getopt.getopt(argv[1:], "hr",
commit 482bb1ae3cf7fdc7a3dfc30bfd371c95f09b8a65
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sun Feb 17 18:01:57 2013 +0100
get the timeout working
diff --git a/test-bugzilla-files/test-bugzilla-files.py b/test-bugzilla-files/test-bugzilla-files.py
index 7bf87d1..62122a5 100644
--- a/test-bugzilla-files/test-bugzilla-files.py
+++ b/test-bugzilla-files/test-bugzilla-files.py
@@ -33,6 +33,7 @@ import time
import uuid
import signal
+import threading
try:
from urllib.parse import quote
except ImportError:
@@ -164,8 +165,6 @@ class OfficeConnection:
if ret != 0:
raise Exception("Exit status indicates failure: " + str(ret))
# return ret
- def kill(self):
- os.system("killall -9 soffice.bin")
class PerTestConnection:
def __init__(self, args):
@@ -209,10 +208,6 @@ class PersistentConnection:
self.connection.tearDown()
finally:
self.connection = None
- def kill(self):
- if self.connection:
- os.system("killall -9 soffice.bin")
- self.connection = None
def simpleInvoke(connection, test):
try:
@@ -272,26 +267,14 @@ def loadFromURL(xContext, url, connection):
"com.sun.star.frame.GlobalEventBroadcaster", xContext)
xGEB.addDocumentEventListener(xListener)
try:
-# we need to check if this method returns after loading or after invoking the loading
-# depending on this we might need to put a timeout around it
xDoc = None
- try:
- signal.signal(signal.SIGALRM, alarm_handler)
- signal.alarm(10)
- xDoc = xDesktop.loadComponentFromURL(url, "_blank", 0, loadProps)
- while True:
- if xListener.layoutFinished:
- signal.alarm(0) # reset the alarm
- return xDoc
- print("delaying...")
- time.sleep(1)
- except Alarm:
- print("timeout: no OnLayoutFinished received")
- print("file not loaded in time: " + url)
- connection.kill()
- xListener = None
- connection.setUp()
- return None
+ xDoc = xDesktop.loadComponentFromURL(url, "_blank", 0, loadProps)
+ while True:
+ if xListener.layoutFinished:
+ t.cancel()
+ return xDoc
+ print("delaying...")
+ time.sleep(1)
except pyuno.getClass("com.sun.star.beans.UnknownPropertyException"):
xListener = None
raise # means crashed, handle it later
@@ -320,9 +303,8 @@ def handleCrash(file, crashed_files):
class Alarm(Exception):
pass
-def alarm_handler(signum, frame):
+def alarm_handler():
os.system("killall -9 soffice.bin")
- raise Alarm
class LoadFileTest:
def __init__(self, file, crashed_files):
@@ -330,19 +312,33 @@ class LoadFileTest:
self.crashed_files = crashed_files
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.start()
xDoc = loadFromURL(xContext, url, connection)
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.crashed_files)
connection.setUp()
except pyuno.getClass("com.sun.star.lang.DisposedException"):
print("caught DisposedException " + self.file)
- handleCrash(self.file, self.crashed_files)
+ if not t.is_alive():
+ print("TIMEOUT!")
+ else:
+ t.cancel()
+ handleCrash(self.file, self.crashed_files)
+ connection.tearDown()
connection.setUp()
finally:
+ if t.is_alive():
+ t.cancel()
if xDoc:
xDoc.close(True)
print("...done with: " + self.file)
@@ -359,8 +355,8 @@ def runLoadFileTests(opts, dirs):
connection = PersistentConnection(opts)
# connection = PerTestConnection(opts)
runConnectionTests(connection, simpleInvoke, tests)
+ connection.tearDown()
print(crashed_files)
- os.system("killall -9 soffice.bin")
def parseArgs(argv):
(optlist,args) = getopt.getopt(argv[1:], "hr",
More information about the Libreoffice-commits
mailing list