mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
keytests: Added some new controls for the *-in.txt files
The controls are described in hello-world-in.txt as CO: for control file open for write CN: control notice CP: simple search pattern CR: regex search pattern CC: close control file The control-file will be used at the end of test by searchPatterns.pl
This commit is contained in:
parent
161f7b7f62
commit
d870a0f2fd
205
development/autotests/findadv-combined-in.txt
Normal file
205
development/autotests/findadv-combined-in.txt
Normal file
@ -0,0 +1,205 @@
|
||||
# Finding special latex/regexp chars: \
|
||||
#
|
||||
Lang sk_SK.utf8
|
||||
TestBegin test.lyx -dbg key,find > findadv-combined.loga.txt 2>&1
|
||||
CO: searchStrings
|
||||
CP: Key (queried) [action=buffer-begin][Ctrl+Home]
|
||||
# String to be checked
|
||||
KK: \\()[]{}%^#@?*.\[Return]
|
||||
KK: \\()[]{}%^#@?*.\[Return]
|
||||
KK: \\()[]{}%^#@?*.\[Return]
|
||||
KK: \\()[]{}%^#@?*.\[Return]
|
||||
KK: \\()[]{}%^#@?*.\[Return]
|
||||
KK: \\()[]{}%^#@?*.\[Return]
|
||||
KK: \\()[]{}%^#@?*.\[Return]
|
||||
KK: \\()[]{}%^#@?*.\[Return]
|
||||
KK: \Cs
|
||||
|
||||
#
|
||||
# First tests with ignore format set
|
||||
# The tests are not separated by \[Home] in order to
|
||||
# be found at possibly different inset
|
||||
#
|
||||
|
||||
#
|
||||
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]
|
||||
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]
|
||||
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]
|
||||
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]
|
||||
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]
|
||||
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]
|
||||
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]
|
||||
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]
|
||||
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]
|
||||
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]
|
||||
CP: Escaping: '\backslash\}'
|
||||
CP: Putting selection at .*idx: 0 par: 3 pos: 6\n with len: 1
|
||||
|
||||
|
||||
|
||||
CN: ..
|
||||
CN: Now tests with unchecked ignore format
|
||||
CN: ..
|
||||
#
|
||||
KK: \CF
|
||||
# Uncheck ignore format
|
||||
KK: \At\Ai\Ah
|
||||
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]
|
||||
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]
|
||||
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]
|
||||
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]
|
||||
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]
|
||||
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]
|
||||
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]
|
||||
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]
|
||||
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]
|
||||
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]
|
||||
CP: Escaped : '\@'
|
||||
CP: Putting selection at .*idx: 0 par: 4 pos: 10\n with len: 1
|
||||
|
||||
#
|
||||
TestEnd
|
||||
CC:
|
||||
Assert searchPatterns.pl log=findadv-combined.loga.txt patterns=searchStrings
|
||||
#/usr2/src/lyx/lyx-git/development/autotests/searchPatterns.pl
|
@ -51,6 +51,26 @@
|
||||
# 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.
|
||||
# Used only by the script 'searchPatterns.pl' at the end of test
|
||||
#
|
||||
# CN: <notice>
|
||||
# Write a comment-notice to the control file. Will be output when processed
|
||||
# by 'searchPatterns.pl' script.
|
||||
#
|
||||
# CP: <pattern>
|
||||
# Write a pattern to the control file. Special characters in this pattern
|
||||
# will be escaped to create a suitable regex.
|
||||
# The result will be applied on the lyx-log-file
|
||||
#
|
||||
# CR: <regex pattern>
|
||||
# Write a pattern to the control file. Pattern will be used directly (no conversion).
|
||||
#
|
||||
# CC:
|
||||
# Close the control file. The file is also closed at 'TestEndWithKill' and 'TestEnd'
|
||||
# implicitly.
|
||||
#
|
||||
# Sleep f
|
||||
# Single delay of f seconds.
|
||||
#
|
||||
|
@ -155,6 +155,55 @@ class CommandSourceFromFile(CommandSource):
|
||||
self.i = self.i + 1
|
||||
return line
|
||||
|
||||
class ControlFile:
|
||||
|
||||
def __init__(self):
|
||||
self.control = re.compile(r'^(C[ONPRC]):\s+(.*)$')
|
||||
self.cntrname = None
|
||||
self.cntrfile = None
|
||||
|
||||
def open(self, filename):
|
||||
self.cntrname = filename
|
||||
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):
|
||||
self.cntrfile.writelines(pat + "\n")
|
||||
|
||||
def getfname(self):
|
||||
return self.cntrname
|
||||
|
||||
def dispatch(self, c):
|
||||
m = self.control.match(c)
|
||||
if not m:
|
||||
return False
|
||||
command = m.group(1)
|
||||
text = m.group(2)
|
||||
if command == "CO":
|
||||
self.open(text);
|
||||
elif command == "CC":
|
||||
self.close()
|
||||
else:
|
||||
if self.cntrfile is None:
|
||||
print("Controlfile not initialized")
|
||||
else:
|
||||
if command == "CN":
|
||||
self.addline("Comment: " + text)
|
||||
elif command == "CP":
|
||||
self.addline("Simple: " + text)
|
||||
elif command == "CR":
|
||||
self.addline("Regex: " + text)
|
||||
else:
|
||||
print("Error")
|
||||
_exit(1)
|
||||
return True
|
||||
|
||||
|
||||
def get_proc_pid(proc_name):
|
||||
pid=os.popen("pidof " + proc_name).read().rstrip()
|
||||
return pid
|
||||
@ -496,7 +545,7 @@ if not lyx_pid is None:
|
||||
write_commands = True
|
||||
failed = False
|
||||
lineempty = re.compile(r'^\s*$')
|
||||
|
||||
marked = ControlFile()
|
||||
while not failed:
|
||||
#intr_system('echo -n LOADAVG:; cat /proc/loadavg')
|
||||
c = x.getCommand()
|
||||
@ -508,6 +557,8 @@ while not failed:
|
||||
continue
|
||||
outfile.writelines(c + '\n')
|
||||
outfile.flush()
|
||||
if marked.dispatch(c):
|
||||
continue
|
||||
if c[0] == '#':
|
||||
print("Ignoring comment line: " + c)
|
||||
elif c[0:9] == 'TestBegin':
|
||||
@ -588,6 +639,7 @@ while not failed:
|
||||
failed = failed or (result != 0)
|
||||
print("result=" + str(result) + ", failed=" + str(failed))
|
||||
elif c[0:15] == 'TestEndWithKill':
|
||||
marked.close()
|
||||
cmd = c[16:].rstrip()
|
||||
if lyx_dead(lyx_pid):
|
||||
print("LyX instance not found because of crash or assert !\n")
|
||||
@ -608,6 +660,7 @@ while not failed:
|
||||
else:
|
||||
print("failed=" + str(failed))
|
||||
elif c[0:7] == 'TestEnd':
|
||||
marked.close()
|
||||
#lyx_other_window_name = None
|
||||
if lyx_dead(lyx_pid):
|
||||
print("LyX instance not found because of crash or assert !\n")
|
||||
|
@ -14,8 +14,9 @@ use warnings;
|
||||
|
||||
sub sexit($); # Print synax and exit
|
||||
sub readPatterns($); # Process patterns file
|
||||
sub processLogFile($);
|
||||
sub convertPattern($); # escape some chars, (e.g. ']' ==> '\]')
|
||||
sub processLogFile($); #
|
||||
sub convertPattern($); # check for regex, comment
|
||||
sub convertSimplePattern($); # escape some chars, (e.g. ']' ==> '\]')
|
||||
|
||||
my %options = (
|
||||
"log" => undef,
|
||||
@ -85,16 +86,43 @@ sub sexit($)
|
||||
}
|
||||
|
||||
sub convertPattern($)
|
||||
{
|
||||
my ($pat) = @_;
|
||||
if ($pat eq "") {
|
||||
return("");
|
||||
}
|
||||
return $pat if ($pat =~ /^Comment:/);
|
||||
if ($pat =~ s/^Regex:\s+//) {
|
||||
# PassThrough variant
|
||||
return($pat);
|
||||
}
|
||||
elsif ($pat =~ s/^Simple:\s+//) {
|
||||
return convertSimplePattern($pat);
|
||||
}
|
||||
else {
|
||||
# This should not happen.
|
||||
return undef;
|
||||
}
|
||||
}
|
||||
|
||||
sub convertSimplePattern($)
|
||||
{
|
||||
# Convert all chars '[]()+'
|
||||
my ($pat) = @_;
|
||||
if ($pat eq "") {
|
||||
return("");
|
||||
}
|
||||
if ($pat =~ /^(.*)([\[\]\(\)\+\^\{\}])(.*)$/) {
|
||||
if ($pat =~ /^(.*)(\\n)(.*)$/) {
|
||||
# do not convert '\n'
|
||||
my ($first, $found, $third) = ($1, $2, $3);
|
||||
$first = &convertPattern($first);
|
||||
$third = &convertPattern($third);
|
||||
$first = &convertSimplePattern($first);
|
||||
$third = &convertSimplePattern($third);
|
||||
return("$first$found$third");
|
||||
}
|
||||
if ($pat =~ /^(.*)([\[\]\(\)\+\^\{\}\\])(.*)$/) {
|
||||
my ($first, $found, $third) = ($1, $2, $3);
|
||||
$first = &convertSimplePattern($first);
|
||||
$third = &convertSimplePattern($third);
|
||||
return($first . "\\$found" . $third);
|
||||
}
|
||||
# Substitue white spaces
|
||||
@ -106,14 +134,26 @@ sub readPatterns($)
|
||||
{
|
||||
my ($patfile) = @_;
|
||||
|
||||
my $errors = 0;
|
||||
if (open(FP, $patfile)) {
|
||||
my $line = 0;
|
||||
while (my $p = <FP>) {
|
||||
$line++;
|
||||
chomp($p);
|
||||
$p = &convertPattern($p);
|
||||
push(@patterns, $p);
|
||||
if (defined($p)) {
|
||||
push(@patterns, $p) if ($p ne "");
|
||||
}
|
||||
else {
|
||||
print "Wrong entry in patterns-file at line $line\n";
|
||||
$errors++;
|
||||
}
|
||||
}
|
||||
close(FP);
|
||||
}
|
||||
if ($errors > 0) {
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
sub processLogFile($)
|
||||
@ -126,10 +166,19 @@ sub processLogFile($)
|
||||
my @savedlines = ();
|
||||
my $readsavedlines = 0;
|
||||
my $savedline;
|
||||
my $comment = "";
|
||||
if (open(FL, $log)) {
|
||||
$errors = 0;
|
||||
my $line = 0;
|
||||
for my $pat (@patterns) {
|
||||
if ($pat =~ /^Comment:\s*(.*)$/) {
|
||||
$comment = $1;
|
||||
$comment =~ s/\s+$//;
|
||||
if ($comment ne "") {
|
||||
print "............ $comment ..........\n";
|
||||
}
|
||||
next;
|
||||
}
|
||||
#print "Searching for \"$pat\"\n";
|
||||
$found = 0;
|
||||
my @lines = ();
|
||||
|
Loading…
Reference in New Issue
Block a user