Mercurial > vim
annotate src/libvterm/t/run-test.pl @ 28266:0b12ce9ae38f
Added tag v8.2.4658 for changeset 67ef250562e545973ae5f7dd9f27c5090d7bc29a
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 31 Mar 2022 21:30:04 +0200 |
parents | f93337ae0612 |
children | 2d2758ffd959 |
rev | line source |
---|---|
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 use strict; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4 use warnings; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 use Getopt::Long; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 use IO::Handle; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 use IPC::Open2 qw( open2 ); |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 use POSIX qw( WIFEXITED WEXITSTATUS WIFSIGNALED WTERMSIG ); |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 my $VALGRIND = 0; |
23080
8eed19bd0235
patch 8.2.2086: libvterm tests are only run on Linux
Bram Moolenaar <Bram@vim.org>
parents:
20498
diff
changeset
|
11 my $EXECUTABLE = "t/harness"; |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 GetOptions( |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 'valgrind|v+' => \$VALGRIND, |
20488
1d595fada804
patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20482
diff
changeset
|
14 'executable|e=s' => \$EXECUTABLE, |
1d595fada804
patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20482
diff
changeset
|
15 'fail-early|F' => \(my $FAIL_EARLY), |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 ) or exit 1; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 my ( $hin, $hout, $hpid ); |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 { |
20448
89fade12827d
patch 8.2.0778: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
15166
diff
changeset
|
20 my @command = $EXECUTABLE; |
15166
694594a0d25d
patch 8.1.0593: illegal memory access in libvterm test
Bram Moolenaar <Bram@vim.org>
parents:
11621
diff
changeset
|
21 unshift @command, "valgrind", "--tool=memcheck", "--leak-check=yes", "--num-callers=25", "--log-file=valgrind.out", "--error-exitcode=126" if $VALGRIND; |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 $hpid = open2 $hout, $hin, @command or die "Cannot open2 harness - $!"; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
24 } |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
25 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 my $exitcode = 0; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 my $command; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
29 my @expect; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
30 |
20482
dc88c690f19b
patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20480
diff
changeset
|
31 my $linenum = 0; |
dc88c690f19b
patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20480
diff
changeset
|
32 |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
33 sub do_onetest |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
34 { |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
35 $hin->print( "$command\n" ); |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
36 undef $command; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
37 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
38 my $fail_printed = 0; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
39 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
40 while( my $outline = <$hout> ) { |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
41 last if $outline eq "DONE\n" or $outline eq "?\n"; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
42 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
43 chomp $outline; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
44 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
45 if( !@expect ) { |
20482
dc88c690f19b
patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20480
diff
changeset
|
46 print "# line $linenum: Test failed\n" unless $fail_printed++; |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
47 print "# expected nothing more\n" . |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
48 "# Actual: $outline\n"; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
49 next; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
50 } |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
51 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
52 my $expectation = shift @expect; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
53 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
54 next if $expectation eq $outline; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
55 |
20482
dc88c690f19b
patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20480
diff
changeset
|
56 print "# line $linenum: Test failed\n" unless $fail_printed++; |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
57 print "# Expected: $expectation\n" . |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
58 "# Actual: $outline\n"; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
59 } |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
60 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
61 if( @expect ) { |
20482
dc88c690f19b
patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20480
diff
changeset
|
62 print "# line $linenum: Test failed\n" unless $fail_printed++; |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
63 print "# Expected: $_\n" . |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
64 "# didn't happen\n" for @expect; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
65 } |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
66 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
67 $exitcode = 1 if $fail_printed; |
20488
1d595fada804
patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20482
diff
changeset
|
68 exit $exitcode if $exitcode and $FAIL_EARLY; |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
69 } |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
70 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
71 sub do_line |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
72 { |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
73 my ( $line ) = @_; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
74 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
75 if( $line =~ m/^!(.*)/ ) { |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
76 do_onetest if defined $command; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
77 print "> $1\n"; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
78 } |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
79 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
80 # Commands have capitals |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
81 elsif( $line =~ m/^([A-Z]+)/ ) { |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
82 # Some convenience formatting |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
83 if( $line =~ m/^(PUSH|ENCIN) (.*)$/ ) { |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
84 # we're evil |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
85 my $string = eval($2); |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
86 $line = "$1 " . unpack "H*", $string; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
87 } |
26270
f93337ae0612
patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents:
23080
diff
changeset
|
88 elsif( $line =~ m/^(SELECTION \d+) +(\[?)(.*?)(\]?)$/ ) { |
f93337ae0612
patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents:
23080
diff
changeset
|
89 # we're evil |
f93337ae0612
patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents:
23080
diff
changeset
|
90 my $string = eval($3); |
f93337ae0612
patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents:
23080
diff
changeset
|
91 $line = "$1 $2 " . unpack( "H*", $string ) . " $4"; |
f93337ae0612
patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents:
23080
diff
changeset
|
92 } |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
93 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
94 do_onetest if defined $command; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
95 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
96 $command = $line; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
97 undef @expect; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
98 } |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
99 # Expectations have lowercase |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
100 elsif( $line =~ m/^([a-z]+)/ ) { |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
101 # Convenience formatting |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
102 if( $line =~ m/^(text|encout) (.*)$/ ) { |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
103 $line = "$1 " . join ",", map sprintf("%x", $_), eval($2); |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
104 } |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
105 elsif( $line =~ m/^(output) (.*)$/ ) { |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
106 $line = "$1 " . join ",", map sprintf("%x", $_), unpack "C*", eval($2); |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
107 } |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
108 elsif( $line =~ m/^control (.*)$/ ) { |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
109 $line = sprintf "control %02x", eval($1); |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
110 } |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
111 elsif( $line =~ m/^csi (\S+) (.*)$/ ) { |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
112 $line = sprintf "csi %02x %s", eval($1), $2; # TODO |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
113 } |
20488
1d595fada804
patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20482
diff
changeset
|
114 elsif( $line =~ m/^(osc) (\[\d+)? *(.*?)(\]?)$/ ) { |
1d595fada804
patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20482
diff
changeset
|
115 my ( $cmd, $initial, $data, $final ) = ( $1, $2, $3, $4 ); |
1d595fada804
patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20482
diff
changeset
|
116 $initial //= ""; |
1d595fada804
patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20482
diff
changeset
|
117 $initial .= ";" if $initial =~ m/\d+/; |
1d595fada804
patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20482
diff
changeset
|
118 |
20498
55a373a243c0
patch 8.2.0803: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20488
diff
changeset
|
119 $line = "$cmd $initial" . join( "", map sprintf("%02x", $_), unpack "C*", length $data ? eval($data) : "" ) . "$final"; |
20488
1d595fada804
patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20482
diff
changeset
|
120 } |
26270
f93337ae0612
patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents:
23080
diff
changeset
|
121 elsif( $line =~ m/^(escape|dcs|apc|pm|sos) (\[?)(.*?)(\]?)$/ ) { |
f93337ae0612
patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents:
23080
diff
changeset
|
122 $line = "$1 $2" . join( "", map sprintf("%02x", $_), unpack "C*", length $3 ? eval($3) : "" ) . "$4"; |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
123 } |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
124 elsif( $line =~ m/^putglyph (\S+) (.*)$/ ) { |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
125 $line = "putglyph " . join( ",", map sprintf("%x", $_), eval($1) ) . " $2"; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
126 } |
26270
f93337ae0612
patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents:
23080
diff
changeset
|
127 elsif( $line =~ m/^(?:movecursor|scrollrect|moverect|erase|damage|sb_pushline|sb_popline|settermprop|setmousefunc|selection-query) / ) { |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
128 # no conversion |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
129 } |
26270
f93337ae0612
patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents:
23080
diff
changeset
|
130 elsif( $line =~ m/^(selection-set) (.*?) (\[?)(.*?)(\]?)$/ ) { |
f93337ae0612
patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents:
23080
diff
changeset
|
131 $line = "$1 $2 $3" . join( "", map sprintf("%02x", $_), unpack "C*", eval($4) ) . "$5"; |
f93337ae0612
patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents:
23080
diff
changeset
|
132 } |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
133 else { |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
134 warn "Unrecognised test expectation '$line'\n"; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
135 } |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
136 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
137 push @expect, $line; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
138 } |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
139 # ?screen_row assertion is emulated here |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
140 elsif( $line =~ s/^\?screen_row\s+(\d+)\s*=\s*// ) { |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
141 my $row = $1; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
142 my $row1 = $row + 1; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
143 my $want = eval($line); |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
144 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
145 do_onetest if defined $command; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
146 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
147 # TODO: may not be 80 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
148 $hin->print( "\?screen_chars $row,0,$row1,80\n" ); |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
149 my $response = <$hout>; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
150 chomp $response; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
151 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
152 $response = pack "C*", map hex, split m/,/, $response; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
153 if( $response ne $want ) { |
20482
dc88c690f19b
patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20480
diff
changeset
|
154 print "# line $linenum: Assert ?screen_row $row failed:\n" . |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
155 "# Expected: $want\n" . |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
156 "# Actual: $response\n"; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
157 $exitcode = 1; |
20488
1d595fada804
patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20482
diff
changeset
|
158 exit $exitcode if $exitcode and $FAIL_EARLY; |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
159 } |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
160 } |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
161 # Assertions start with '?' |
20480
d0bf39eb2b07
patch 8.2.0794: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20462
diff
changeset
|
162 elsif( $line =~ s/^\?([a-z]+.*?=)\s*// ) { |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
163 do_onetest if defined $command; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
164 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
165 my ( $assertion ) = $1 =~ m/^(.*)\s+=/; |
20482
dc88c690f19b
patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20480
diff
changeset
|
166 my $expectation = $line; |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
167 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
168 $hin->print( "\?$assertion\n" ); |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
169 my $response = <$hout>; defined $response or wait, die "Test harness failed - $?\n"; |
20480
d0bf39eb2b07
patch 8.2.0794: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20462
diff
changeset
|
170 chomp $response; $response =~ s/^\s+|\s+$//g; |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
171 |
20482
dc88c690f19b
patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20480
diff
changeset
|
172 # Some convenience formatting |
dc88c690f19b
patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20480
diff
changeset
|
173 if( $assertion =~ m/^screen_chars/ and $expectation =~ m/^"/ ) { |
dc88c690f19b
patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20480
diff
changeset
|
174 $expectation = join ",", map sprintf("0x%02x", ord $_), split m//, eval($expectation); |
dc88c690f19b
patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20480
diff
changeset
|
175 } |
dc88c690f19b
patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20480
diff
changeset
|
176 |
dc88c690f19b
patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20480
diff
changeset
|
177 if( $response ne $expectation ) { |
dc88c690f19b
patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20480
diff
changeset
|
178 print "# line $linenum: Assert $assertion failed:\n" . |
dc88c690f19b
patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20480
diff
changeset
|
179 "# Expected: $expectation\n" . |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
180 "# Actual: $response\n"; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
181 $exitcode = 1; |
20488
1d595fada804
patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20482
diff
changeset
|
182 exit $exitcode if $exitcode and $FAIL_EARLY; |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
183 } |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
184 } |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
185 # Test controls start with '$' |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
186 elsif( $line =~ s/\$SEQ\s+(\d+)\s+(\d+):\s*// ) { |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
187 my ( $low, $high ) = ( $1, $2 ); |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
188 foreach my $val ( $low .. $high ) { |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
189 ( my $inner = $line ) =~ s/\\#/$val/g; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
190 do_line( $inner ); |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
191 } |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
192 } |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
193 elsif( $line =~ s/\$REP\s+(\d+):\s*// ) { |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
194 my $count = $1; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
195 do_line( $line ) for 1 .. $count; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
196 } |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
197 else { |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
198 die "Unrecognised TEST line $line\n"; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
199 } |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
200 } |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
201 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
202 open my $test, "<", $ARGV[0] or die "Cannot open test script $ARGV[0] - $!"; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
203 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
204 while( my $line = <$test> ) { |
20482
dc88c690f19b
patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20480
diff
changeset
|
205 $linenum++; |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
206 $line =~ s/^\s+//; |
20462
9ad473b50471
patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20448
diff
changeset
|
207 chomp $line; |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
208 |
20462
9ad473b50471
patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20448
diff
changeset
|
209 next if $line =~ m/^(?:#|$)/; |
9ad473b50471
patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20448
diff
changeset
|
210 last if $line eq "__END__"; |
9ad473b50471
patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20448
diff
changeset
|
211 |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
212 do_line( $line ); |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
213 } |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
214 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
215 do_onetest if defined $command; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
216 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
217 close $hin; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
218 close $hout; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
219 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
220 waitpid $hpid, 0; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
221 if( $? ) { |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
222 printf STDERR "Harness exited %d\n", WEXITSTATUS($?) if WIFEXITED($?); |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
223 printf STDERR "Harness exit signal %d\n", WTERMSIG($?) if WIFSIGNALED($?); |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
224 $exitcode = WIFEXITED($?) ? WEXITSTATUS($?) : 125; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
225 } |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
226 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
227 exit $exitcode; |