[Libreoffice-commits] dev-tools.git: 2 commits - test-bugzilla-files/control.py test-bugzilla-files/test-bugzilla-files.py

Markus Mohrhard markus.mohrhard at googlemail.com
Thu Apr 18 22:29:01 PDT 2013


 test-bugzilla-files/control.py             |   77 +++++++++++++++++++++++++
 test-bugzilla-files/test-bugzilla-files.py |   89 ++++++++++++++++++++---------
 2 files changed, 141 insertions(+), 25 deletions(-)

New commits:
commit 7de19cc2e1d2684517c5c5698de3c3a066218ad9
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Fri Apr 19 07:26:00 2013 +0200

    add my script controling the test-bugzilla-files script

diff --git a/test-bugzilla-files/control.py b/test-bugzilla-files/control.py
new file mode 100755
index 0000000..05a6df9
--- /dev/null
+++ b/test-bugzilla-files/control.py
@@ -0,0 +1,77 @@
+#!/usr/bin/env python
+
+import os
+import sys
+import subprocess
+import getopt
+
+dirs = [ "doc", "docx", "fods", "fodt", "ods", "odt", "rtf", "xls", "xlsx" ]
+
+calc = [ "fods", "ods", "xls", "xlsx" ]
+
+writer = [ "doc", "docx", "fodt", "odt", "rtf" ]
+
+impress = [ "ppt", "pptx", "odp", "fodp" ]
+
+draw = [ "odg", "fodg" ]
+
+reverse = [ "wpd", "vsd", "pub", "cdr", "vdx" ]
+
+def get_execute_scripts(opts):
+    top_dir = os.getcwd()
+    valid_dirs = []
+    if "--writer" in opts:
+        valid_dirs.extend( [ os.path.join(top_dir, dir) for dir in writer if os.path.isdir(os.path.join(top_dir,dir)) ] )
+    if "--calc" in opts:
+        valid_dirs.extend( [ os.path.join(top_dir, dir) for dir in calc if os.path.isdir(os.path.join(top_dir,dir)) ] )
+    if "--impress" in opts:
+        valid_dirs.extend( [ os.path.join(top_dir, dir) for dir in impress if os.path.isdir(os.path.join(top_dir,dir)) ] )
+    if "--draw" in opts:
+        valid_dirs.extend( [ os.path.join(top_dir, dir) for dir in draw if os.path.isdir(os.path.join(top_dir,dir)) ] )
+    if "--reverse" in opts:
+        valid_dirs.extend( [ os.path.join(top_dir, dir) for dir in reverse if os.path.isdir(os.path.join(top_dir,dir)) ] )
+    #print valid_dirs
+    valid_execute_files = { dir: os.path.join(dir, "execute.sh") for dir in valid_dirs if os.path.isfile(os.path.join(dir, "execute.sh")) }
+    #print valid_execute_files
+    return valid_execute_files
+
+def execute_scripts(opts):
+    valid_execute_scripts = get_execute_scripts(opts)
+    for dir, file in valid_execute_scripts.iteritems():
+        print("start script in " + dir)
+        command = "nohup " + file
+        os.chdir(dir)
+        print(file)
+        print(os.getcwd())
+        subprocess.Popen("nohup ./execute.sh&", shell=True)
+        pass
+
+def parseArgs(argv):
+    (optlist,args) = getopt.getopt(argv[1:], "h",
+                        ["help", "calc", "writer", "impress", "draw", "reverse"])
+    #    print optlist
+    return (dict(optlist), args)
+
+def usage():
+    message = """usage: {program} [option]"
+-h | --help: print usage information
+--calc: test calc files
+--writer: test writer files
+--impress: test impress files
+--draw: test draw files
+--reverse: test reverse engineered file formats"""
+    print(message.format(program = (os.path.basename(sys.argv[0]))))
+
+if __name__ == "__main__":
+    print(sys.argv)
+    (opts,args) = parseArgs(sys.argv)
+    if "-h" in opts or "--help" in opts:
+        usage()
+        sys.exit()
+    elif len(opts) == 0:
+        usage()
+        sys.exit()
+    elif "--writer" in opts or "--calc" in opts or "--impress" in opts or "--draw" in opts or "--reverse" in opts:
+        print(os.getcwd())
+        print(os.listdir(os.getcwd()))
+        execute_scripts(opts)
commit fc3db64c783f7988aaa3b8b35bc0be7263fd82eb
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Fri Apr 19 07:21:02 2013 +0200

    update the test-bugzilla-files script to latest version

diff --git a/test-bugzilla-files/test-bugzilla-files.py b/test-bugzilla-files/test-bugzilla-files.py
index cd41795..54343f6 100644
--- a/test-bugzilla-files/test-bugzilla-files.py
+++ b/test-bugzilla-files/test-bugzilla-files.py
@@ -167,6 +167,9 @@ class OfficeConnection:
 #            return ret
     def kill(self):
         command = "kill " + str(self.pro.pid)
+        killFile = open("killFile.log", "a")
+        killFile.write(command + "\n")
+        killFile.close()
         print("kill")
         print(command)
         os.system(command)
@@ -245,25 +248,44 @@ def mkPropertyValue(name, value):
 
 ### tests ###
 
-def loadFromURL(xContext, url):
+def loadFromURL(xContext, url, t, component):
     xDesktop = xContext.ServiceManager.createInstanceWithContext(
             "com.sun.star.frame.Desktop", xContext)
     props = [("Hidden", True), ("ReadOnly", True)] # FilterName?
     loadProps = tuple([mkPropertyValue(name, value) for (name, value) in props])
-    xListener = EventListener()
-    xGEB = xContext.ServiceManager.createInstanceWithContext(
-        "com.sun.star.frame.GlobalEventBroadcaster", xContext)
-    xGEB.addDocumentEventListener(xListener)
+    xListener = None
+    if component == "writer":
+        xListener = EventListener()
+        xGEB = xContext.ServiceManager.createInstanceWithContext(
+            "com.sun.star.frame.GlobalEventBroadcaster", xContext)
+        xGEB.addDocumentEventListener(xListener)
     try:
         xDoc = None
         xDoc = xDesktop.loadComponentFromURL(url, "_blank", 0, loadProps)
-        time_ = 0
-        while time_ < 30:
-            if xListener.layoutFinished:
-                return xDoc
-            print("delaying...")
-            time_ += 1
-            time.sleep(1)
+        if component == "calc":
+            try:
+                if xDoc:
+                    xDoc.calculateAll()
+            except AttributeError:
+                pass
+            t.cancel()
+            return xDoc
+        elif component == "writer":
+            time_ = 0
+            t.cancel()
+            while time_ < 30:
+                if xListener.layoutFinished:
+                    return xDoc
+                print("delaying...")
+                time_ += 1
+                time.sleep(1)
+        else:
+            t.cancel()
+            return xDoc
+        file = open("file.log", "a")
+        file.write("layout did not finish\n")
+        file.close()
+        return xDoc
     except pyuno.getClass("com.sun.star.beans.UnknownPropertyException"):
         xListener = None
         raise # means crashed, handle it later
@@ -295,21 +317,25 @@ def alarm_handler(args):
     args.kill()
 
 class LoadFileTest:
-    def __init__(self, file, state):
+    def __init__(self, file, state, component):
         self.file = file
         self.state = state
+        self.component = component
     def run(self, xContext, connection):
         print("Loading document: " + self.file)
         t = None
+        args = None
         try:
             url = "file://" + quote(self.file)
+            file = open("file.log", "a")
+            file.write(url + "\n")
+            file.close()
             xDoc = None
             args = [connection]
-            t = threading.Timer(45, alarm_handler, args)
+            t = threading.Timer(60, alarm_handler, args)
             t.start()      
-            xDoc = loadFromURL(xContext, url)
+            xDoc = loadFromURL(xContext, url, t, self.component)
             self.state.goodFiles.append(self.file)
-            t.cancel()
         except pyuno.getClass("com.sun.star.beans.UnknownPropertyException"):
             print("caught UnknownPropertyException " + self.file)
             if not t.is_alive():
@@ -337,7 +363,10 @@ class LoadFileTest:
                 t.cancel()
             try:
                 if xDoc:
+                    t = threading.Timer(10, alarm_handler, args)
+                    t.start()
                     xDoc.close(True)
+                    t.cancel()
             except pyuno.getClass("com.sun.star.beans.UnknownPropertyException"):
                 print("caught UnknownPropertyException while closing")
                 self.state.badPropertyFiles.append(self.file)
@@ -345,7 +374,10 @@ class LoadFileTest:
                 connection.setUp()
             except pyuno.getClass("com.sun.star.lang.DisposedException"):
                 print("caught DisposedException while closing")
-                self.state.badDisposedFiles.append(self.file)
+                if t.is_alive():
+                    t.cancel()
+                else:
+                    self.state.badDisposedFiles.append(self.file)
                 connection.tearDown()
                 connection.setUp()
             print("...done with: " + self.file)
@@ -388,19 +420,26 @@ def writeReport(state, startTime):
         timeoutFiles.write("\n")
     timeoutFiles.close()
 
-
-validFileExtensions = [ ".docx" , ".rtf", ".odt", ".fodt", ".doc" ]
+validCalcFileExtensions = [ ".xlsx", ".xls", ".ods", ".fods" ]
+validWriterFileExtensions = [ ".docx" , ".rtf", ".odt", ".fodt", ".doc" ]
+validImpressFileExtensions = [ ".ppt", ".pptx", ".odp", ".fodp" ]
+validDrawFileExtensions = [ ".odg", ".fodg" ]
+validRevereseFileExtensions = [ ".vsd", ".vdx", ".cdr", ".pub", ".wpd" ]
+validFileExtensions = dict([("calc", validCalcFileExtensions), ("writer", validWriterFileExtensions), ("impress", validImpressFileExtensions), ("draw", validDrawFileExtensions), ("reverse", validRevereseFileExtensions) ])
 
 def runLoadFileTests(opts, dirs):
     startTime = datetime.datetime.now()
+    connection = PersistentConnection(opts)
     try:
-        files = []
-        for suffix in validFileExtensions:
-            files.extend(getFiles(dirs, suffix))
-        files.sort()
+        tests = []
         state = State()
-        tests = (LoadFileTest(file, state) for file in files)
-        connection = PersistentConnection(opts)
+        print("before map")
+        for component, validExtension in validFileExtensions.items():
+            files = []
+            for suffix in validExtension:
+                files.extend(getFiles(dirs, suffix))
+            files.sort()
+            tests.extend( (LoadFileTest(file, state, component) for file in files) )
         runConnectionTests(connection, simpleInvoke, tests)
     finally:
         connection.kill()


More information about the Libreoffice-commits mailing list