# Finding special latex/regexp chars: \
+UseShortcut "C-F20" "regexp-mode"
+UseShortcut "C-F21" "command-sequence dialog-show findreplaceadv ; buffer-end ; buffer-begin-select ; char-delete-forward ;"
+PrepareShortcuts
#
Lang sk_SK.utf8
TestBegin test.lyx -dbg key,find > findadv-combined.loga.txt 2>&1
#
KK: \[Escape]\C\[Home]
CP: Key (queried) [action=buffer-begin][Ctrl+Home]
-CN: Searching for '@'
-KK: \CF
-KK: \[Delete]
-KK: \Axregexp-mode\[Return]\\@\[Return]
-KK: \[Escape]
+CN: Part 001
+KK: \C\[F21]\C\[F20]\\@\[Return]
CP: Escaped : '\@'
CR: [pP]utting selection at .*idx: 0 par: 0 pos: 10\n with len: 1
#
-CN: Searching for '('
-KK: \CF
-KK: \[Delete]
-KK: \Axregexp-mode\[Return]\\(\[Return]
-KK: \[Escape]
+CN: Part 002
+KK: \C\[F21]\C\[F20]\\(\[Return]
CP: Escaped : '\('
CP: Putting selection at .*idx: 0 par: 1 pos: 1\n with len: 1
#
-CN: Searching for ')'
-KK: \CF
-KK: \[Delete]
-KK: \Axregexp-mode\[Return]\\)\[Return]
-KK: \[Escape]
+CN: Part 003
+KK: \C\[F21]\C\[F20]\\)\[Return]
CP: Escaped : '\)'
CP: Putting selection at .*idx: 0 par: 1 pos: 2\n with len: 1
#
-CN: Searching for '\\'
-KK: \CF
-KK: \[Delete]
-KK: \Axregexp-mode\[Return]\\\\\[Return]
-KK: \[Escape]
+CN: Part 004
+KK: \C\[F21]\C\[F20]\\\\\[Return]
CP: Escaping: '\backslash\backslash'
CP: Putting selection at .*idx: 0 par: 2 pos: 0\n with len: 1
#
-CN: Searching for '%'
-KK: \CF
-KK: \[Delete]
-KK: \Axregexp-mode\[Return]%\[Return]
-KK: \[Escape]
+CN: Part 005
+KK: \C\[F21]\C\[F20]%\[Return]
CP: Escaped : '%'
CP: Putting selection at .*idx: 0 par: 2 pos: 7\n with len: 1
#
-CN: Searching for '^'
-KK: \CF
-KK: \[Delete]
-KK: \Axregexp-mode\[Return]\\^\[Return]
-KK: \[Escape]
+CN: Part 006
+KK: \C\[F21]\C\[F20]\\^\[Return]
CP: Escaped : '\^'
CP: Putting selection at .*idx: 0 par: 2 pos: 8\n with len: 1
#
-CN: Searching for '['
-KK: \CF
-KK: \[Delete]
-KK: \Axregexp-mode\[Return]\\[\[Return]
-KK: \[Escape]
+CN: Part 007
+KK: \C\[F21]\C\[F20]\\[\[Return]
CP: Escaped : '\['
CP: Putting selection at .*idx: 0 par: 3 pos: 3\n with len: 1
#
-CN: Searching for ']'
-KK: \CF
-KK: \[Delete]
-KK: \Axregexp-mode\[Return]\\]\[Return]
-KK: \[Escape]
+CN: Part 008
+KK: \C\[F21]\C\[F20]\\]\[Return]
CP: Escaped : '\]'
CP: Putting selection at .*idx: 0 par: 3 pos: 4\n with len: 1
#
-CN: Searching for '{'
-KK: \CF
-KK: \[Delete]
-KK: \Axregexp-mode\[Return]\\{\[Return]
-KK: \[Escape]
+CN: Part 009
+KK: \C\[F21]\C\[F20]\\{\[Return]
CP: Escaping: '\backslash\{'
CP: Putting selection at .*idx: 0 par: 3 pos: 5\n with len: 1
#
-CN: Searching for '}'
-KK: \CF
-KK: \[Delete]
-KK: \Axregexp-mode\[Return]\\}\[Return]
-KK: \[Escape]
+CN: Part 010
+KK: \C\[F21]\C\[F20]\\}\[Return]
CP: Escaping: '\backslash\}'
CP: Putting selection at .*idx: 0 par: 3 pos: 6\n with len: 1
CP: Key (queried) [action=buffer-begin][Ctrl+Home]
#
-CN: Searching for '['
-KK: \CF
-KK: \[Delete]
-KK: \Axregexp-mode\[Return]\\[\[Return]
-KK: \[Escape]
+CN: Part 101
+KK: \C\[F21]\C\[F20]\\[\[Return]
CP: Escaped : '\['
CP: Putting selection at .*idx: 0 par: 0 pos: 3\n with len: 1
#
-CN: Searching for '('
-KK: \CF
-KK: \[Delete]
-KK: \Axregexp-mode\[Return]\\(\[Return]
-KK: \[Escape]
+CN: Part 102
+KK: \C\[F21]\C\[F20]\\(\[Return]
CP: Escaped : '\('
CP: Putting selection at .*idx: 0 par: 1 pos: 1\n with len: 1
#
-CN: Searching for ')'
-KK: \CF
-KK: \[Delete]
-KK: \Axregexp-mode\[Return]\\)\[Return]
-KK: \[Escape]
+CN: Part 103
+KK: \C\[F21]\C\[F20]\\)\[Return]
CP: Escaped : '\)'
CP: Putting selection at .*idx: 0 par: 1 pos: 2\n with len: 1
#
-CN: Searching for '\\'
-KK: \CF
-KK: \[Delete]
-KK: \Axregexp-mode\[Return]\\\\\[Return]
-KK: \[Escape]
+CN: Part 104
+KK: \C\[F21]\C\[F20]\\\\\[Return]
CP: Escaped : '\\'
CP: Putting selection at .*idx: 0 par: 2 pos: 0\n with len: 1
#
-CN: Searching for '%'
-KK: \CF
-KK: \[Delete]
-KK: \Axregexp-mode\[Return]%\[Return]
-KK: \[Escape]
+CN: Part 105
+KK: \C\[F21]\C\[F20]%\[Return]
CP: Escaped : '%'
CP: Putting selection at .*idx: 0 par: 2 pos: 7\n with len: 1
#
-CN: Searching for '^'
-KK: \CF
-KK: \[Delete]
-# Uncheck ignore format
-KK: \Axregexp-mode\[Return]\\^\[Return]
-KK: \[Escape]
+CN: Part 105
+KK: \C\[F21]\C\[F20]\\^\[Return]
CP: Escaped : '\^'
CP: Putting selection at .*idx: 0 par: 2 pos: 8\n with len: 1
#
-CN: Searching for '{'
-KK: \CF
-KK: \[Delete]
-KK: \Axregexp-mode\[Return]\\{\[Return]
-KK: \[Escape]
+CN: Part 106
+KK: \C\[F21]\C\[F20]\\{\[Return]
CP: Escaping: '\backslash\{'
CP: Putting selection at .*idx: 0 par: 3 pos: 5\n with len: 1
#
-CN: Searching for '}'
-KK: \CF
-KK: \[Delete]
-KK: \Axregexp-mode\[Return]\\}\[Return]
-KK: \[Escape]
+CN: Part 107
+KK: \C\[F21]\C\[F20]\\}\[Return]
CP: Escaping: '\backslash\}'
CP: Putting selection at .*idx: 0 par: 3 pos: 6\n with len: 1
#
-CN: Searching for ']'
-KK: \CF
-KK: \[Delete]
-KK: \Axregexp-mode\[Return]\\]\[Return]
-KK: \[Escape]
+CN: Part 108
+KK: \C\[F21]\C\[F20]\\]\[Return]
CP: Escaped : '\]'
CP: Putting selection at .*idx: 0 par: 4 pos: 4\n with len: 1
#
-CN: Searching for '@'
-KK: \CF
-KK: \[Delete]
-KK: \Axregexp-mode\[Return]\\@\[Return]
-KK: \[Escape]
+CN: Part 109
+KK: \C\[F21]\C\[F20]\\@\[Return]
CP: Escaped : '\@'
CP: Putting selection at .*idx: 0 par: 4 pos: 10\n with len: 1
#
TestEnd
-CC:
+Lang C
Assert searchPatterns.pl log=findadv-combined.loga.txt patterns=findadv-combined.ctrl
import re
import sys
import time
+import tempfile
+import shutil
+
#from subprocess import call
import subprocess
FNULL = open('/dev/null', 'w')
key_delay = ''
+bindings = {}
# Ignore status == "dead" if this is set. Used at the last commands after "\Cq"
dead_expected = False
elif command == "CC":
self.close()
else:
- if self.cntrfile is None:
- print("Controlfile not initialized")
- else:
+ if not self.cntrfile is None:
if command == "CN":
self.__addline("Comment: " + text)
elif command == "CP":
def system_retry(num_retry, cmd):
i = 0
- rtn = intr_system(cmd)
+ rtn = intr_system(cmd, True)
while ( ( i < num_retry ) and ( rtn != 0) ):
i = i + 1
- rtn = intr_system(cmd)
+ rtn = intr_system(cmd, True)
time.sleep(1)
if ( rtn != 0 ):
print("Command Failed: "+cmd)
intr_system("wmctrl -R '"+lyx_window_name+"' ;sleep 0.1")
system_retry(30, "wmctrl -i -a '"+lyx_window_name+"'")
+shortcut_entry = re.compile(r'^\s*"([^"]+)"\s*\"([^"]+)\"')
+def UseShortcut(c):
+ m = shortcut_entry.match(c)
+ if m:
+ sh = m.group(1)
+ fkt = m.group(2)
+ bindings[sh] = fkt
+ else:
+ die(1, "cad shortcut spec(" + c + ")")
+
+def PrepareShortcuts():
+ bind = re.compile(r'^\s*\\bind\s+"([^"]+)"')
+ if lyx_userdir_ver is None:
+ dir = lyx_userdir
+ else:
+ dir = lyx_userdir_ver
+ if not dir is None:
+ tmp = tempfile.NamedTemporaryFile(suffix='.bind', delete=False)
+ try:
+ old = open(dir + '/bind/user.bind', 'r')
+ except IOError as e:
+ old = None
+ if not old is None:
+ lines = old.read().split("\n")
+ old.close()
+ bindfound = False
+ for line in lines:
+ m = bind.match(line)
+ if m:
+ bindfound = True
+ val = m.group(1)
+ if not bindings[val] is None:
+ if bindings[val] != "":
+ tmp.write("\\bind \"" + val + "\" \"" + bindings[val] + "\"\n")
+ bindings[val] = ""
+ else:
+ tmp.write(line + '\n')
+ elif not bindfound:
+ tmp.write(line + '\n')
+ else:
+ tmp.writelines(
+ '## This file is used for keytests only\n\n' +
+ 'Format 4\n\n'
+ )
+ for val in bindings:
+ if not bindings[val] is None:
+ if bindings[val] != "":
+ tmp.write("\\bind \"" + val + "\" \"" + bindings[val] + "\"\n")
+ bindings[val] = ""
+ tmp.close()
+ shutil.move(tmp.name, dir + '/bind/user.bind')
+ else:
+ print("User dir not specified")
lyx_pid = os.environ.get('LYX_PID')
print('lyx_pid: ' + str(lyx_pid) + '\n')
lyx_other_window_name = None
screenshot_out = os.environ.get('SCREENSHOT_OUT')
lyx_userdir = os.environ.get('LYX_USERDIR')
+lyx_userdir_ver = os.environ.get('LYX_USERDIR_23x')
max_loops = os.environ.get('MAX_LOOPS')
if max_loops is None:
elif c == 'RaiseLyx':
print('Raising Lyx')
RaiseWindow()
+ elif c == 'PrepareShortcuts':
+ print('Preparing usefull sortcuts for tests')
+ PrepareShortcuts()
+ elif c[0:12] == 'UseShortcut ':
+ UseShortcut(c[12:])
elif c[0:4] == 'KK: ':
if lyx_exists():
sendKeystringRT(c[4:], lyx_pid)
sendKeystringRT(ResetCommand, lyx_pid)
elif c[0:6] == 'Assert':
cmd = c[7:].rstrip()
- result = intr_system(cmd)
+ result = intr_system(cmd, True)
failed = failed or (result != 0)
print("result=" + str(result) + ", failed=" + str(failed))
elif c[0:15] == 'TestEndWithKill':
time.sleep(0.5)
if cmd != "":
print("Executing " + cmd)
- result = intr_system(cmd)
+ result = intr_system(cmd, True)
failed = failed or (result != 0)
print("result=" + str(result) + ", failed=" + str(failed))
else:
print("failed=" + str(failed))
elif c[0:7] == 'TestEnd':
- marked.close()
- #lyx_other_window_name = None
+ #lyx_other_window_name = None
if lyx_dead(lyx_pid):
print("LyX instance not found because of crash or assert !\n")
+ marked.close()
failed = True
else:
print(" ------------ Forcing quit of lyx instance: " + str(lyx_pid) + " ------------")
# now we should be outside any dialog
# and so the function lyx-quit should work
sendKeystringLocal("\Cq", lyx_pid)
+ marked.dispatch('CP: action=lyx-quit')
+ marked.close()
time.sleep(0.5)
dead_expected = True
is_sleeping = wait_until_lyx_sleeping(lyx_pid)
cmd = c[8:].rstrip()
if cmd != "":
print("Executing " + cmd)
- result = intr_system(cmd)
+ result = intr_system(cmd, True)
failed = failed or (result != 0)
print("result=" + str(result) + ", failed=" + str(failed))
else: