]> git.lyx.org Git - features.git/commitdiff
keytests: Allow controlfile (used by searchPatterns.pl) to be opened for 'append'
authorKornel Benko <kornel@lyx.org>
Wed, 17 May 2017 22:03:50 +0000 (00:03 +0200)
committerKornel Benko <kornel@lyx.org>
Wed, 17 May 2017 22:03:50 +0000 (00:03 +0200)
This allows collecting search strings of multiple tests in one file

development/autotests/hello-world-in.txt
development/autotests/keytest.py

index 80d4e31c6d11fb75d290b1960da5405b3949c8a2..dc502e665b7d940fa7e6ce37fee5a472febc2f43 100644 (file)
@@ -51,8 +51,9 @@
 # KD: n
 #   Changes the delay among typed charactes to n milliseconds.
 #
-# CO: <filename>
-#    Open control file for write. This file will contain the search and comment strings.
+# CO: [>>] <filename>
+#    Open control file for write (or append if preceeded with '>>').
+#    This file will contain the search and comment strings.
 #    Used only by the script 'searchPatterns.pl' at the end of test
 #
 # CN: <notice>
index a785709e94f4f824804698f715904a4c8d91ac53..67bb3ca1526350dcc02d0430d542f7cf521c67c0 100755 (executable)
@@ -165,20 +165,38 @@ class ControlFile:
 
     def __init__(self):
         self.control = re.compile(r'^(C[ONPRC]):\s*(.*)$')
+        self.fileformat = re.compile(r'^((\>\>?)[,\s]\s*)?([^\s]+)\s*$')
         self.cntrname = None
         self.cntrfile = None
 
     def open(self, filename):
+        if not self.cntrfile is None:
+            self.cntrfile.close()
+            self.cntrfile = None
+            self.cntrname = None
+        m = self.fileformat.match(filename)
+        if m:
+            type = m.group(2)
+            filename = m.group(3)
+            if type == '>>':
+                append = True
+            else:
+                append = False
+        else:
+            append = False
         self.cntrname = filename
-        self.cntrfile = open(filename, 'w')
+        if append:
+            self.cntrfile = open(filename, 'a')
+        else:
+            self.cntrfile = open(filename, 'w')
 
     def close(self):
         if not self.cntrfile is None:
             self.cntrfile.close()
             self.cntrfile = None
             self.cntrname = None
-
-    def addline(self, pat):
+    # make the method below 'private'
+    def __addline(self, pat):
         self.cntrfile.writelines(pat + "\n")
 
     def getfname(self):
@@ -199,11 +217,11 @@ class ControlFile:
                 print("Controlfile not initialized")
             else:
                 if command == "CN":
-                    self.addline("Comment: " + text)
+                    self.__addline("Comment: " + text)
                 elif command == "CP":
-                    self.addline("Simple: " + text)
+                    self.__addline("Simple: " + text)
                 elif command == "CR":
-                    self.addline("Regex: " + text)
+                    self.__addline("Regex: " + text)
                 else:
                     die(1,"Error, Unrecognised Command '" + command + "'")
         return True
@@ -257,7 +275,7 @@ def printresstatus():
 
 def lyx_status_retry(pid):
     resstatus = []
-    if lyx_pid is None:
+    if pid is None:
         print('Pid is None')
         return "dead"
     fname = '/proc/' + pid + '/status'
@@ -667,9 +685,8 @@ while not failed:
             failed = True
         else:
             print("    ------------    Forcing quit of lyx instance: " + str(lyx_pid) + "    ------------")
-            # \Ax Enter command line is sometimes blocked
-            # \[Escape] works after this
-            sendKeystringAx("\Ax\[Escape]", lyx_pid)
+            # \[Escape]+ should work as RESET focus to main window
+            sendKeystringAx("\[Escape]\[Escape]\[Escape]\[Escape]", lyx_pid)
             time.sleep(controlkey_delay)
             # now we should be outside any dialog
             # and so the function lyx-quit should work