mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 10:58:52 +00:00
keytests: Add more controls for the *-in.txt files
The controls are described in hello-world-in.txt as Cr: not expected regex search pattern before next expected match Cp: not expected search pattern before next expected match See also findadv-re-04-in.txt for an example In this test-case, searching for case sensitive and format considering search is failing.
This commit is contained in:
parent
46e472dcf9
commit
8f74cac381
@ -1,14 +1,71 @@
|
||||
# Finding styles with regexp
|
||||
|
||||
Lang sk_SK.utf8
|
||||
CO: findadv-re-04.ctrl
|
||||
CN: Part 1
|
||||
CP: Init key
|
||||
TestBegin test.lyx -dbg key,find > findadv-re-04.loga.txt 2>&1
|
||||
KK: Hello \CeHello\C\[Home]
|
||||
CP: Key (queried) [action=buffer-begin][Ctrl+Home]
|
||||
KK: The quick Brown \CeFox JUmps\Ce over the lazy Dog\[Return]
|
||||
KK: \C\[Home]
|
||||
KK: \Cs
|
||||
KK: \CF
|
||||
# Uncheck ignore format (depends on IT language)
|
||||
KK: \At\Ai\Ah
|
||||
KK: \Ce
|
||||
CN: Case insensitive, format not ignored .*
|
||||
KK: \Axregexp-mode\[Return].*\[Return]
|
||||
Cr: ^.*Putting
|
||||
CP: Putting selection at .*idx: 0 par: 0 pos: 16\n with len: 9
|
||||
TestEnd
|
||||
|
||||
CO: >> findadv-re-04.ctrl
|
||||
CN: Part 2
|
||||
CP: Init key
|
||||
TestBegin test.lyx -dbg key,find >> findadv-re-04.loga.txt 2>&1
|
||||
CN: Case insensitive, format not ignored [a-z]*
|
||||
KK: \CF
|
||||
# Uncheck ignore format (depends on IT language)
|
||||
KK: \At\Ai\Ah
|
||||
KK: \Ce
|
||||
KK: \Axregexp-mode\[Return][a-z]*\[Return]\[Return]\[Return]
|
||||
Cr: ^.*Putting
|
||||
CP: Putting selection at .*idx: 0 par: 0 pos: 16\n with len: 3
|
||||
Cr: ^.*Putting
|
||||
CP: Putting selection at .*idx: 0 par: 0 pos: 20\n with len: 5
|
||||
TestEnd
|
||||
|
||||
CO: >> findadv-re-04.ctrl
|
||||
CN: Part 3
|
||||
CP: Init key
|
||||
TestBegin test.lyx -dbg key,find >> findadv-re-04.loga.txt 2>&1
|
||||
|
||||
CN: Case sensitive, format not ignored [a-z]*
|
||||
KK: \CF
|
||||
KK: \At\Ai\Ah
|
||||
KK: \Ce
|
||||
KK: \Ao\[Tab]\Axregexp-mode\[Return][a-z]*\[Return]\[Return]\[Return]\[Return]\[Return]\[Return]\[Return]
|
||||
Cr: ^.*Putting
|
||||
CP: Putting selection at .*idx: 0 par: 0 pos: 17\n with len: 2
|
||||
Cr: ^.*Putting
|
||||
Cr: ^.*Init key
|
||||
CP: Putting selection at .*idx: 0 par: 0 pos: 22\n with len: 3
|
||||
TestEnd
|
||||
|
||||
CO: >> findadv-re-04.ctrl
|
||||
CN: Part 4
|
||||
CP: Init key
|
||||
TestBegin test.lyx -dbg key,find >> findadv-re-04.loga.txt 2>&1
|
||||
|
||||
CN: Case sensitive, format not ignored [A-Z]*
|
||||
KK: \CF
|
||||
KK: \At\Ai\Ah
|
||||
KK: \Ce
|
||||
KK: \Ao\[Tab]\Axregexp-mode\[Return][A-Z]*\[Return]\[Return]\[Return]\[Return]\[Return]
|
||||
Cr: ^.*Putting
|
||||
CP: Putting selection at .*idx: 0 par: 0 pos: 16\n with len: 1
|
||||
Cr: ^.*Putting
|
||||
CP: Putting selection at .*idx: 0 par: 0 pos: 20\n with len: 2
|
||||
TestEnd
|
||||
Lang C
|
||||
Assert pcregrep -M 'Putting selection at .*idx: 0 par: 0 pos: 6\n with len: 5' findadv-re-04.loga.txt
|
||||
Assert searchPatterns.pl log=findadv-re-04.loga.txt patterns=findadv-re-04.ctrl
|
||||
|
@ -164,7 +164,7 @@ class CommandSourceFromFile(CommandSource):
|
||||
class ControlFile:
|
||||
|
||||
def __init__(self):
|
||||
self.control = re.compile(r'^(C[ONPRC]):\s*(.*)$')
|
||||
self.control = re.compile(r'^(C[ONPpRrC]):\s*(.*)$')
|
||||
self.fileformat = re.compile(r'^((\>\>?)[,\s]\s*)?([^\s]+)\s*$')
|
||||
self.cntrname = None
|
||||
self.cntrfile = None
|
||||
@ -220,8 +220,12 @@ class ControlFile:
|
||||
self.__addline("Comment: " + text)
|
||||
elif command == "CP":
|
||||
self.__addline("Simple: " + text)
|
||||
elif command == "Cp":
|
||||
self.__addline("ErrSimple: " + text)
|
||||
elif command == "CR":
|
||||
self.__addline("Regex: " + text)
|
||||
elif command == "Cr":
|
||||
self.__addline("ErrRegex: " + text)
|
||||
else:
|
||||
die(1,"Error, Unrecognised Command '" + command + "'")
|
||||
return True
|
||||
|
@ -17,6 +17,7 @@ sub readPatterns($); # Process patterns file
|
||||
sub processLogFile($); #
|
||||
sub convertPattern($); # check for regex, comment
|
||||
sub convertSimplePattern($); # escape some chars, (e.g. ']' ==> '\]')
|
||||
sub printInvalid($$); # display lines which should not match
|
||||
|
||||
my %options = (
|
||||
"log" => undef,
|
||||
@ -92,12 +93,14 @@ sub convertPattern($)
|
||||
return("");
|
||||
}
|
||||
return $pat if ($pat =~ /^Comment:/);
|
||||
if ($pat =~ s/^Regex:\s+//) {
|
||||
if ($pat =~ s/^((Err)?Regex):\s+//) {
|
||||
# PassThrough variant
|
||||
return($pat);
|
||||
return($1 . ":" . $pat);
|
||||
}
|
||||
elsif ($pat =~ s/^Simple:\s+//) {
|
||||
return convertSimplePattern($pat);
|
||||
elsif ($pat =~ s/^((Err)?Simple):\s+//) {
|
||||
my $ermark = $2;
|
||||
$ermark = "" if (!defined($ermark));
|
||||
return $ermark . "Regex:" . &convertSimplePattern($pat);
|
||||
}
|
||||
else {
|
||||
# This should not happen.
|
||||
@ -168,6 +171,8 @@ sub processLogFile($)
|
||||
if (open(FL, $log)) {
|
||||
$errors = 0;
|
||||
my $line = 0;
|
||||
my @ErrPatterns = ();
|
||||
my $minprevlines = 0;
|
||||
for my $pat (@patterns) {
|
||||
if ($pat =~ /^Comment:\s*(.*)$/) {
|
||||
$comment = $1;
|
||||
@ -177,9 +182,25 @@ sub processLogFile($)
|
||||
}
|
||||
next;
|
||||
}
|
||||
if ($pat =~ /^(Err)?Regex:(.*)$/) {
|
||||
my ($type, $regex) = ($1, $2);
|
||||
next if ($regex eq "");
|
||||
if (defined($type)) {
|
||||
# This regex should not apply until next 'found line'
|
||||
my $erlines = () = $regex =~ /\\n/g;
|
||||
$minprevlines = $erlines if ($erlines > $minprevlines);
|
||||
push(@ErrPatterns, $regex);
|
||||
next;
|
||||
}
|
||||
else {
|
||||
# This is the pattern which we are looking for
|
||||
$pat = $regex;
|
||||
}
|
||||
}
|
||||
#print "Searching for \"$pat\"\n";
|
||||
$found = 0;
|
||||
my $prevlines = () = $pat =~ /\\n/g; # Number of lines in pattern
|
||||
$prevlines = $minprevlines if ($prevlines < $minprevlines);
|
||||
my @prevl = ();
|
||||
for (my $i = 0; $i <= $prevlines; $i++) {
|
||||
push(@prevl, "\n");
|
||||
@ -210,6 +231,8 @@ sub processLogFile($)
|
||||
my $check = join("", @prevl);
|
||||
$line++;
|
||||
if ($check =~ /$pat/) {
|
||||
@ErrPatterns = (); # clean search for not wanted patterns
|
||||
$minprevlines = 0;
|
||||
my $fline = $line - $prevlines;
|
||||
print "$fline:\tfound \"$pat\"\n";
|
||||
$found = 1;
|
||||
@ -228,6 +251,18 @@ sub processLogFile($)
|
||||
}
|
||||
else {
|
||||
push(@savedlines, $l);
|
||||
# Check for not wanted patterns
|
||||
my $errindex = 0;
|
||||
for my $ep (@ErrPatterns) {
|
||||
if ($check =~ /$ep/) {
|
||||
$errors++;
|
||||
my $fline = $line - $prevlines;
|
||||
printInvalid($fline, $check);
|
||||
#splice(@ErrPatterns, $errindex, 1);
|
||||
last;
|
||||
}
|
||||
$errindex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (! $found) {
|
||||
@ -240,3 +275,13 @@ sub processLogFile($)
|
||||
}
|
||||
return($errors);
|
||||
}
|
||||
|
||||
sub printInvalid($$)
|
||||
{
|
||||
my ($line, $check) = @_;
|
||||
my @chk = split(/\n/, $check);
|
||||
print("$line:\tInvalid match: " . shift(@chk) . "\n");
|
||||
for my $l (@chk) {
|
||||
print("\t\t\t$l\n");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user