]> git.lyx.org Git - features.git/commitdiff
keytests: more tweaking
authorKornel Benko <kornel@lyx.org>
Wed, 10 May 2017 22:00:42 +0000 (00:00 +0200)
committerKornel Benko <kornel@lyx.org>
Wed, 10 May 2017 22:00:42 +0000 (00:00 +0200)
Tested with QT5.7 QT5.8 (self compiled) and QT4.8

development/autotests/findadv-12-in.txt
development/autotests/findadv-logo-in.txt
development/autotests/findadv-re-05-in.txt
development/autotests/hello-world-in.txt
development/autotests/keytest.py

index 2cc849139623b4de8d9b4cf2c8d1a330c2624869..d8b64a6037b47f1037fb61de8865cd4d48cb4b6e 100644 (file)
@@ -2,12 +2,13 @@
 # again the search pattern, should not result in a double replacement
 # (#7442)
 #
-Lang it_IT.utf8
+Lang sk_SK.utf8
 TestBegin test.lyx -dbg key,find > findadv-12.loga.txt 2>&1
 KK: a\C\[Home]
+KK: \Cs
 KK: \CF
 KK: a\[Tab]
-KK: \Cm\\bar a\[Return]\[Return]
+KK: \Cm\\bar a \Ar\Ar\An\An\[Left]
 TestEnd
 Lang C
 Assert ! pcregrep -M 'against.*bar' findadv-12.loga.txt
index f43ebcd62b882d365326cf165a85e1f3767d2f1c..c42413ad0952bd9fd97645956f58a05502ef88d9 100644 (file)
@@ -10,8 +10,8 @@ KK: \Cs
 KK: \CF
 # Uncheck ignore format (depends on IT language)
 KK: \At\Ai\Ah
-KK: \Axspecialchar-insert lyx\[Return]\Ai
-KK: \Axspecialchar-insert latex\[Return]\Ae
+KK: \Axspecialchar-insert lyx\[Return]\[Tab]
+KK: \Axspecialchar-insert latex\[Return]\Al\Ar\An
 TestEnd
 Lang C
 Assert pcregrep -M 'Putting selection at .*idx: 0 par: 0 pos: 29\n with len: 1' findadv-logo.loga.txt
index 2b2371153a6599188b8a49b23da98b5e4f65b3c7..069790358db4ea3c5dfc7826d6cec39b2b83b0fe 100644 (file)
@@ -12,7 +12,10 @@ Lang it_IT.utf8
 TestBegin test.lyx -dbg key,find > findadv-re-05.loga.txt 2>&1
 KK: \Cm\\frac 1-x\[Down]1+x^2 \C\[Home]
 KK: \CF
-KK: \Cm\\frac \Axregexp-mode\[Return].* \[Down]1+x^2 \[Return]
-TestEnd
+KK: \Cm\\frac \Axregexp-mode\[Return].* \[Down]1+x^2 \[Return]\[Return]
+# After the message about reaching the end of buffer, lyx
+# loses focus :(
+# so no more keys can be sent to lyx
+TestEndWithKill
 Lang C
 Assert pcregrep 'raggiunta la fine cercando in avanti' findadv-re-05.loga.txt
index 92faef2a1aa4a898dfdc8ecb709ec4f3d45d4ee2..679e037e14633603983f646a66124e9a1b9ee568 100644 (file)
 #   A new LyX instance is spawned, with the command-line arguments
 #   specified in <args...>.
 #
+# TestEndWithKill <cmd...>
+#   Ends a test case, killing immidiately the LyX instance under test
+#   Behaviour is otherwise the same as in 'TestEnd' below
+#
 # TestEnd <cmd...>
-#   Ends a test case, killing the LyX instance under test, and
+#   Ends a test case, closing the LyX instance under test, and
 #   executing the <cmd...> commands into an os.system(). The exit status
 #   of the commands sequence determines success or failure of the test.
 #   This is equivalent to:
index e62e6a6a305972d5570f570f7ed5a2391260e97f..7b36a6dc0512897305e3bc25ae65754d6a22bf87 100755 (executable)
@@ -22,7 +22,6 @@ print('Beginning keytest.py')
 FNULL = open('/dev/null', 'w')
 
 key_delay = ''
-controlkey_delay = 0.30
 
 class CommandSource:
 
@@ -205,31 +204,33 @@ def lyx_dead():
     status = lyx_status(lyx_pid)
     return (status == "dead") or (status == "zombie")
 
-def sendKeystringLocal(keystr, LYX_PID):
-
-    #if not re.match(".*\w.*", keystr):
-    #    print('print .' + keystr)
-    #    keystr = 'a'
+def wait_until_lyx_sleeping():
     before_secs = time.time()
-    while lyx_exists() and not lyx_sleeping():
-        time.sleep(0.02)
-        sys.stdout.flush()
+    while True:
+        status = lyx_status(lyx_pid)
+        if status == "sleeping":
+            return
+        if (status == "dead") or (status == "zombie"):
+            print('Lyx is dead, exiting')
+            sys.stdout.flush()
+            os._exit(1)
         if time.time() - before_secs > 180:
             print('Killing due to freeze (KILL_FREEZE)')
 
             # Do profiling, but sysprof has no command line interface?
             # intr_system("killall -KILL lyx")
 
+            sys.stdout.flush()
             os._exit(1)
+        time.sleep(0.02)
+
+def sendKeystringLocal(keystr, LYX_PID):
+    wait_until_lyx_sleeping()
     if not screenshot_out is None:
-        while lyx_exists() and not lyx_sleeping():
-            time.sleep(0.02)
-            sys.stdout.flush()
         print('Making Screenshot: ' + screenshot_out + ' OF ' + infilename)
         time.sleep(0.2)
         intr_system('import -window root '+screenshot_out+str(x.count)+".png")
         time.sleep(0.1)
-    sys.stdout.flush()
     actual_delay = key_delay
     if actual_delay == '':
         actual_delay = def_delay
@@ -238,10 +239,11 @@ def sendKeystringLocal(keystr, LYX_PID):
         xvpar.extend(["-jump-pointer", "-no-back-pointer"])
     else:
         xvpar.extend(["-xsendevent"])
-    xvpar.extend(["-window", lyx_window_name, "-delay", actual_delay, "-text", keystr])
-
+    #xvpar.extend(["-window", lyx_window_name])
+    xvpar.extend(["-delay", actual_delay, "-text", keystr])
     print("Sending \"" + keystr + "\"")
     subprocess.call(xvpar, stdout = FNULL, stderr = FNULL)
+    sys.stdout.flush()
 
 Axreg = re.compile(r'^(.*)\\Ax([^\\]*)(.*)$')
 returnreg = re.compile(r'(\\\[[A-Z][a-z]+\])(.*)$')
@@ -280,8 +282,8 @@ def sendKeystringAx(line, LYX_PID):
         if line != "":
             sendKeystringLocal(line, LYX_PID)
 
-specialkeyreg = re.compile(r'(.+)(\\[AC][a-zA-Z].*)$')
-# Split line at start of each \[AC][a-zA-Z]
+specialkeyreg = re.compile(r'(.+)(\\[AC]([a-zA-Z]|\\\[[A-Z][a-z]+\]).*)$')
+# Split line at start of each meta or controll char
 
 def sendKeystringAC(line, LYX_PID):
     m = specialkeyreg.match(line)
@@ -368,6 +370,10 @@ if xvkbd_exe is None:
 qt_frontend = os.environ.get('QT_FRONTEND')
 if qt_frontend is None:
     qt_frontend = 'QT4'
+if qt_frontend == 'QT5':
+    controlkey_delay = 0.01
+else:
+    controlkey_delay = 0.4
 
 locale_dir = os.environ.get('LOCALE_DIR')
 if locale_dir is None:
@@ -375,7 +381,10 @@ if locale_dir is None:
 
 def_delay = os.environ.get('XVKBD_DELAY')
 if def_delay is None:
-    def_delay = '5'
+    if qt_frontend == 'QT5':
+        def_delay = '5'
+    else:
+        def_delay = '1'
 
 file_new_command = os.environ.get('FILE_NEW_COMMAND')
 if file_new_command is None:
@@ -414,13 +423,16 @@ if not lyx_pid is None:
 
 write_commands = True
 failed = False
+lineempty = re.compile(r'^\s*$')
 
 while not failed:
     #intr_system('echo -n LOADAVG:; cat /proc/loadavg')
     c = x.getCommand()
     if c is None:
         break
-    if c.strip() == "":
+
+    # Do not strip trailing spaces, only check for 'empty' lines
+    if lineempty.match(c):
         continue
     outfile.writelines(c + '\n')
     outfile.flush()
@@ -501,8 +513,24 @@ while not failed:
         result = intr_system(cmd)
         failed = failed or (result != 0)
         print("result=" + str(result) + ", failed=" + str(failed))
+    elif c[0:15] == 'TestEndWithKill':
+        cmd = c[16:].rstrip()
+        if lyx_dead():
+            print("LyX instance not found because of crash or assert !\n")
+            failed = True
+        else:
+            print("    ------------    Forcing kill of lyx instance: " + str(lyx_pid) + "    ------------")
+            while not lyx_dead():
+                intr_system("kill -9 " + str(lyx_pid), True);
+                time.sleep(0.5)
+            if cmd != "":
+                print("Executing " + cmd)
+                result = intr_system(cmd)
+                failed = failed or (result != 0)
+                print("result=" + str(result) + ", failed=" + str(failed))
+            else:
+                print("failed=" + str(failed))
     elif c[0:7] == 'TestEnd':
-#        time.sleep(0.5)
         if lyx_dead():
             print("LyX instance not found because of crash or assert !\n")
             failed = True