tests/data: add %includetext, dedupe XML payloads into external file

To reduce duplication and to avoid keeping XML-like markup within XML
markup (`test*`), that was tripping `xmllint`.

Ref: #19470

Closes #19504
This commit is contained in:
Viktor Szakats 2025-11-13 02:11:48 +01:00
parent 85cfc15601
commit ca27404d27
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
12 changed files with 134 additions and 787 deletions

View file

@ -100,8 +100,11 @@ sub clearlogs {
#######################################################################
sub includefile {
my ($f) = @_;
my ($f, $text) = @_;
open(F, "<$f");
if($text) {
binmode F, ':crlf';
}
my @a = <F>;
close(F);
return join("", @a);
@ -147,12 +150,15 @@ sub subbase64 {
$$thing =~ s/%%DAYS%%/%alternatives[$d,$d2]/;
}
# include a file, expand space macros
$$thing =~ s/%includetext ([^%]*)%[\n\r]+/includefile($1, 1)/ge;
$$thing =~ s/%SP/ /g; # space
$$thing =~ s/%TAB/\t/g; # horizontal tab
$$thing =~ s/%CR/\r/g; # carriage return aka \r aka 0x0d
# include a file
$$thing =~ s/%include ([^%]*)%[\n\r]+/includefile($1)/ge;
$$thing =~ s/%include ([^%]*)%[\n\r]+/includefile($1, 0)/ge;
}
my $prevupdate; # module scope so it remembers the last value