[Libreoffice-commits] dev-tools.git: 5 commits - uitest/mass-testing

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Apr 23 17:06:23 UTC 2019


 uitest/mass-testing/calc.py    |  161 +++++++++++++++++++++--------------------
 uitest/mass-testing/impress.py |   13 +--
 uitest/mass-testing/run.py     |   42 +++++++---
 uitest/mass-testing/writer.py  |   13 +--
 4 files changed, 124 insertions(+), 105 deletions(-)

New commits:
commit f9be4795bac37d177402f49a7f2de7daf9b764d0
Author:     Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Tue Apr 23 19:02:14 2019 +0200
Commit:     Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Tue Apr 23 19:02:14 2019 +0200

    mass-uitesting: thread not loaded files as skipped

diff --git a/uitest/mass-testing/run.py b/uitest/mass-testing/run.py
index 65bbc1d..40d88c6 100755
--- a/uitest/mass-testing/run.py
+++ b/uitest/mass-testing/run.py
@@ -126,12 +126,17 @@ def run_tests_and_get_results(liboPath, listFiles, isDebug, isResume):
         fileInterval = 10
         testIternval = 20
         timeout = time.time() + fileInterval
+        notLoaded = True
         while True:
             time.sleep(1)
 
             if time.time() > timeout:
-                logger.info("TIMEOUT: " + fileName)
-                results['timeout'] += 1
+                if notLoaded:
+                    logger.info("SKIP: " + fileName)
+                    results['skip'] += 1
+                else:
+                    logger.info("TIMEOUT: " + fileName)
+                    results['timeout'] += 1
 
                 # kill popen process
                 os.killpg(process.pid, signal.SIGKILL)
@@ -164,6 +169,8 @@ def run_tests_and_get_results(liboPath, listFiles, isDebug, isResume):
 
                         break
                     elif message == 'loaded':
+                        notLoaded = False
+
                         #Extend timeout
                         timeout += testIternval
 
commit 77efd108d283951e7bc8ec3bb2ecb519fa7b3c57
Author:     Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Tue Apr 23 18:49:32 2019 +0200
Commit:     Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Tue Apr 23 18:49:32 2019 +0200

    mass-uitesting: Make sure the sheet is not protected...
    
    ... while changing text formatting

diff --git a/uitest/mass-testing/calc.py b/uitest/mass-testing/calc.py
index 58d532d..f1ac576 100755
--- a/uitest/mass-testing/calc.py
+++ b/uitest/mass-testing/calc.py
@@ -148,47 +148,55 @@ class massTesting(UITestCase):
     def test_change_text_formatting_and_undo(self):
         xEdit = self.load_file()
         if xEdit:
-            self.xUITest.executeCommand(".uno:SelectAll")
-            self.xUITest.executeCommand(".uno:Bold")
-            self.xUITest.executeCommand(".uno:Undo")
-            self.xUITest.executeCommand(".uno:Italic")
-            self.xUITest.executeCommand(".uno:Undo")
-            self.xUITest.executeCommand(".uno:Underline")
-            self.xUITest.executeCommand(".uno:Undo")
-            self.xUITest.executeCommand(".uno:UnderlineDouble")
-            self.xUITest.executeCommand(".uno:Undo")
-            self.xUITest.executeCommand(".uno:Strikeout")
-            self.xUITest.executeCommand(".uno:Undo")
-            self.xUITest.executeCommand(".uno:Overline")
-            self.xUITest.executeCommand(".uno:Undo")
-            self.xUITest.executeCommand(".uno:SuperScript")
-            self.xUITest.executeCommand(".uno:Undo")
-            self.xUITest.executeCommand(".uno:SubScript")
-            self.xUITest.executeCommand(".uno:Undo")
-            self.xUITest.executeCommand(".uno:Shadowed")
-            self.xUITest.executeCommand(".uno:Undo")
-            self.xUITest.executeCommand(".uno:OutlineFont")
-            self.xUITest.executeCommand(".uno:Undo")
-            self.xUITest.executeCommand(".uno:Grow")
-            self.xUITest.executeCommand(".uno:Undo")
-            self.xUITest.executeCommand(".uno:Shrink")
-            self.xUITest.executeCommand(".uno:Undo")
-            self.xUITest.executeCommand(".uno:ChangeCaseToUpper")
-            self.xUITest.executeCommand(".uno:Undo")
-            self.xUITest.executeCommand(".uno:ChangeCaseToLower")
-            self.xUITest.executeCommand(".uno:Undo")
-            self.xUITest.executeCommand(".uno:ChangeCaseRotateCase")
-            self.xUITest.executeCommand(".uno:Undo")
-            self.xUITest.executeCommand(".uno:ChangeCaseToSentenceCase")
-            self.xUITest.executeCommand(".uno:Undo")
-            self.xUITest.executeCommand(".uno:ChangeCaseToTitleCase")
-            self.xUITest.executeCommand(".uno:Undo")
-            self.xUITest.executeCommand(".uno:ChangeCaseToToggleCase")
-            self.xUITest.executeCommand(".uno:Undo")
-            self.xUITest.executeCommand(".uno:SmallCaps")
-            self.xUITest.executeCommand(".uno:Undo")
-            self.xUITest.executeCommand(".uno:StyleApply?Style:string=Heading%202&FamilyName:string=ParagraphStyles")
-            self.xUITest.executeCommand(".uno:Undo")
+            document = self.ui_test.get_component()
+            nrSheets = document.Sheets.getCount()  #number of sheets in the document
+
+            #go to first sheet
+            for i in range(nrSheets - 1):
+                self.xUITest.executeCommand(".uno:JumpToPrevTable")
+
+            if not document.Sheets[0].isProtected():
+                self.xUITest.executeCommand(".uno:SelectAll")
+                self.xUITest.executeCommand(".uno:Bold")
+                self.xUITest.executeCommand(".uno:Undo")
+                self.xUITest.executeCommand(".uno:Italic")
+                self.xUITest.executeCommand(".uno:Undo")
+                self.xUITest.executeCommand(".uno:Underline")
+                self.xUITest.executeCommand(".uno:Undo")
+                self.xUITest.executeCommand(".uno:UnderlineDouble")
+                self.xUITest.executeCommand(".uno:Undo")
+                self.xUITest.executeCommand(".uno:Strikeout")
+                self.xUITest.executeCommand(".uno:Undo")
+                self.xUITest.executeCommand(".uno:Overline")
+                self.xUITest.executeCommand(".uno:Undo")
+                self.xUITest.executeCommand(".uno:SuperScript")
+                self.xUITest.executeCommand(".uno:Undo")
+                self.xUITest.executeCommand(".uno:SubScript")
+                self.xUITest.executeCommand(".uno:Undo")
+                self.xUITest.executeCommand(".uno:Shadowed")
+                self.xUITest.executeCommand(".uno:Undo")
+                self.xUITest.executeCommand(".uno:OutlineFont")
+                self.xUITest.executeCommand(".uno:Undo")
+                self.xUITest.executeCommand(".uno:Grow")
+                self.xUITest.executeCommand(".uno:Undo")
+                self.xUITest.executeCommand(".uno:Shrink")
+                self.xUITest.executeCommand(".uno:Undo")
+                self.xUITest.executeCommand(".uno:ChangeCaseToUpper")
+                self.xUITest.executeCommand(".uno:Undo")
+                self.xUITest.executeCommand(".uno:ChangeCaseToLower")
+                self.xUITest.executeCommand(".uno:Undo")
+                self.xUITest.executeCommand(".uno:ChangeCaseRotateCase")
+                self.xUITest.executeCommand(".uno:Undo")
+                self.xUITest.executeCommand(".uno:ChangeCaseToSentenceCase")
+                self.xUITest.executeCommand(".uno:Undo")
+                self.xUITest.executeCommand(".uno:ChangeCaseToTitleCase")
+                self.xUITest.executeCommand(".uno:Undo")
+                self.xUITest.executeCommand(".uno:ChangeCaseToToggleCase")
+                self.xUITest.executeCommand(".uno:Undo")
+                self.xUITest.executeCommand(".uno:SmallCaps")
+                self.xUITest.executeCommand(".uno:Undo")
+                self.xUITest.executeCommand(".uno:StyleApply?Style:string=Heading%202&FamilyName:string=ParagraphStyles")
+                self.xUITest.executeCommand(".uno:Undo")
 
         self.ui_test.close_doc()
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
commit 7051847eb83b9dfa7976c72c0dd441613312fe36
Author:     Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Tue Apr 23 18:39:31 2019 +0200
Commit:     Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Tue Apr 23 18:39:31 2019 +0200

    mass-uitesting: kill the process earlier if the document...
    
    ... can't be loaded.
    Sometimes it hangs or a popup is prompted.
    bail out earlier so we can save some time

diff --git a/uitest/mass-testing/calc.py b/uitest/mass-testing/calc.py
index dc19af8..58d532d 100755
--- a/uitest/mass-testing/calc.py
+++ b/uitest/mass-testing/calc.py
@@ -10,12 +10,6 @@ from uitest.framework import UITestCase
 from libreoffice.uno.propertyvalue import mkPropertyValues
 import time
 
-
-def handle_skip():
-    #Kill the process so we don't have to open the same file for each test
-    print("skipped")
-    os.killpg(os.getpid(), signal.SIGINT)
-
 class massTesting(UITestCase):
 
     def load_file(self):
@@ -28,16 +22,21 @@ class massTesting(UITestCase):
         self.ui_test.load_file(fileName)
         document = self.ui_test.get_component()
 
+
         # Ignore read-only or protected files
         if not hasattr(document, 'isReadonly') or document.isReadonly() or document.isProtected():
-            handle_skip()
+            print("mass-uitesting:skipped", flush=True)
+            return
 
         try:
             xDoc = self.xUITest.getTopFocusWindow()
             xEdit = xDoc.getChild("grid_window")
         except:
             #In case the mimetype is wrong and the file is open with another component
-            handle_skip()
+            print("mass-uitesting:skipped", flush=True)
+            return
+
+        print("mass-uitesting:loaded", flush=True)
 
         return xEdit
 
diff --git a/uitest/mass-testing/impress.py b/uitest/mass-testing/impress.py
index f2797b2..cb63fe0 100755
--- a/uitest/mass-testing/impress.py
+++ b/uitest/mass-testing/impress.py
@@ -9,11 +9,6 @@ from uitest.framework import UITestCase
 from libreoffice.uno.propertyvalue import mkPropertyValues
 import time
 
-def handle_skip():
-    #Kill the process so we don't have to open the same file for each test
-    print("skipped")
-    os.killpg(os.getpid(), signal.SIGINT)
-
 class massTesting(UITestCase):
 
     def load_file(self):
@@ -28,7 +23,8 @@ class massTesting(UITestCase):
 
         # Ignore read-only files
         if not hasattr(document, 'isReadonly') or document.isReadonly():
-            handle_skip()
+            print("mass-uitesting:skipped", flush=True)
+            return
 
         # Go to the normal view
         self.xUITest.executeCommand(".uno:NormalMultiPaneGUI")
@@ -38,7 +34,10 @@ class massTesting(UITestCase):
             xEdit = xDoc.getChild("impress_win")
         except:
             #In case the mimetype is wrong and the file is open with another component
-            handle_skip()
+            print("mass-uitesting:skipped", flush=True)
+            return
+
+        print("mass-uitesting:loaded", flush=True)
 
         return xEdit
 
diff --git a/uitest/mass-testing/run.py b/uitest/mass-testing/run.py
index 20bb101..65bbc1d 100755
--- a/uitest/mass-testing/run.py
+++ b/uitest/mass-testing/run.py
@@ -120,9 +120,12 @@ def run_tests_and_get_results(liboPath, listFiles, isDebug, isResume):
         # Do not block on process.stdout
         fcntl.fcntl(process.stdout.fileno(), fcntl.F_SETFL, os.O_NONBLOCK)
 
-        # Kill the process if the test can't be executed in 'timeoutTime' seconds
-        timeoutTime = 20
-        timeout = time.time() + timeoutTime
+        # Kill the process if:
+        # 1. The file can't be loaded in 'fielInterval' seconds
+        # 2. The test can't be executed in 'testInterval' seconds
+        fileInterval = 10
+        testIternval = 20
+        timeout = time.time() + fileInterval
         while True:
             time.sleep(1)
 
@@ -136,7 +139,6 @@ def run_tests_and_get_results(liboPath, listFiles, isDebug, isResume):
 
             try:
                 outputLines = process.stdout.readlines()
-
             except IOError:
                 pass
 
@@ -151,17 +153,22 @@ def run_tests_and_get_results(liboPath, listFiles, isDebug, isResume):
                 if isDebug:
                     print(line)
 
-                if 'skipped' == line.lower():
-                    logger.info("SKIP: " + fileName + " : " + importantInfo)
-                    results['skip'] += 1
-                    break
+                if line.startswith("mass-uitesting:"):
+                    message = line.split(":")[1]
+                    if message == 'skipped':
+                        logger.info("SKIP: " + fileName + " : " + importantInfo)
+                        results['skip'] += 1
 
-                if 'Execution time' in line:
+                        # kill popen process
+                        os.killpg(process.pid, signal.SIGKILL)
 
-                    importantInfo = line.split('for ')[1]
+                        break
+                    elif message == 'loaded':
+                        #Extend timeout
+                        timeout += testIternval
 
-                    #Extend timeout
-                    timeout = time.time() + timeoutTime
+                elif 'Execution time' in line:
+                    importantInfo = line.split('for ')[1]
 
                 elif importantInfo and 'error' == line.lower() or 'fail' == line.lower():
                     isFailure = True
diff --git a/uitest/mass-testing/writer.py b/uitest/mass-testing/writer.py
index cbf27b6..563bc8c 100755
--- a/uitest/mass-testing/writer.py
+++ b/uitest/mass-testing/writer.py
@@ -10,11 +10,6 @@ from uitest.framework import UITestCase
 from libreoffice.uno.propertyvalue import mkPropertyValues
 import time
 
-def handle_skip():
-    #Kill the process so we don't have to open the same file for each test
-    print("skipped")
-    os.killpg(os.getpid(), signal.SIGINT)
-
 class massTesting(UITestCase):
 
     def load_file(self):
@@ -29,14 +24,18 @@ class massTesting(UITestCase):
 
         # Ignore read-only files
         if not hasattr(document, 'isReadonly') or document.isReadonly():
-            handle_skip()
+            print("mass-uitesting:skipped", flush=True)
+            return
 
         try:
             xDoc = self.xUITest.getTopFocusWindow()
             xEdit = xDoc.getChild("writer_edit")
         except:
             #In case the mimetype is wrong and the file is open with another component
-            handle_skip()
+            print("mass-uitesting:skipped", flush=True)
+            return
+
+        print("mass-uitesting:loaded", flush=True)
 
         return xEdit
 
commit aea68aa76ce0ee7c074f5b2ea9178aea726d7e04
Author:     Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Tue Apr 23 16:47:02 2019 +0200
Commit:     Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Tue Apr 23 16:47:02 2019 +0200

    mass-uitesting: Do not delete protected sheets

diff --git a/uitest/mass-testing/calc.py b/uitest/mass-testing/calc.py
index 38078cd..dc19af8 100755
--- a/uitest/mass-testing/calc.py
+++ b/uitest/mass-testing/calc.py
@@ -113,36 +113,36 @@ class massTesting(UITestCase):
         if xEdit:
             document = self.ui_test.get_component()
             nrSheets = document.Sheets.getCount()  #number of sheets in the document
-            if nrSheets == 1:
-                #copy sheet and undo
+            #go to first sheet
+            for i in range(nrSheets - 1):
+                self.xUITest.executeCommand(".uno:JumpToPrevTable")
+
+            ignoreSheets = 0
+            for i in range(nrSheets):
+                #copy sheet, undo and delete
                 self.ui_test.execute_dialog_through_command(".uno:Move")
                 xDialog = self.xUITest.getTopFocusWindow()
+                xCopy = xDialog.getChild("copy")
+                xCopy.executeAction("CLICK", tuple())
                 xOKBtn = xDialog.getChild("ok")
                 self.ui_test.close_dialog_through_button(xOKBtn)
-                self.assertEqual(document.Sheets.getCount(), 2)
+
                 self.xUITest.executeCommand(".uno:Undo")
-            else:
-                #copy sheet and undo and delete
-                #go to first sheet
-                for i in range(nrSheets - 1):
-                    self.xUITest.executeCommand(".uno:JumpToPrevTable")
-                #copy sheet; delete sheet
-                for i in range(nrSheets - 1):
-                    self.ui_test.execute_dialog_through_command(".uno:Move")
-                    xDialog = self.xUITest.getTopFocusWindow()
-                    xCopy = xDialog.getChild("copy")
-                    xCopy.executeAction("CLICK", tuple())
-                    xOKBtn = xDialog.getChild("ok")
-                    self.ui_test.close_dialog_through_button(xOKBtn)
-
-                    self.xUITest.executeCommand(".uno:Undo")
-
-                    self.ui_test.execute_dialog_through_command(".uno:Remove")  #delete sheet
-                    xDialog = self.xUITest.getTopFocusWindow()
-                    xOKButton = xDialog.getChild("yes")
-                    xOKButton.executeAction("CLICK", tuple())
-
-            self.assertEqual(document.Sheets.getCount(), 1)
+
+                if document.Sheets[ignoreSheets].isProtected():
+                    #Do not count  the last sheet
+                    if i < nrSheets - 1:
+                        ignoreSheets += 1
+                        self.xUITest.executeCommand(".uno:JumpToNextTable")
+                else:
+                    #Do not delete the last sheet
+                    if i < nrSheets - 1:
+                        self.ui_test.execute_dialog_through_command(".uno:Remove")  #delete sheet
+                        xDialog = self.xUITest.getTopFocusWindow()
+                        xOKButton = xDialog.getChild("yes")
+                        xOKButton.executeAction("CLICK", tuple())
+
+            self.assertEqual(document.Sheets.getCount(), 1 + ignoreSheets)
 
         self.ui_test.close_doc()
 
commit a91e1c5e96623bfc53ac5506024aacd243df3901
Author:     Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Tue Apr 23 16:45:50 2019 +0200
Commit:     Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Tue Apr 23 16:45:50 2019 +0200

    mass-uitesting: Ignore protected files

diff --git a/uitest/mass-testing/calc.py b/uitest/mass-testing/calc.py
index 91bd21b..38078cd 100755
--- a/uitest/mass-testing/calc.py
+++ b/uitest/mass-testing/calc.py
@@ -28,8 +28,8 @@ class massTesting(UITestCase):
         self.ui_test.load_file(fileName)
         document = self.ui_test.get_component()
 
-        # Ignore read-only files
-        if not hasattr(document, 'isReadonly') or document.isReadonly():
+        # Ignore read-only or protected files
+        if not hasattr(document, 'isReadonly') or document.isReadonly() or document.isProtected():
             handle_skip()
 
         try:


More information about the Libreoffice-commits mailing list