Using this instruction, a test case can include the contents of a file
into the test during the preprocessing.
Closes #12612
%repeat[100 x hello]%
+## Include file
+
+This instruction allows a test case to include another file. It is helpful to
+remember that the ordinary variables are expanded before the include happens
+so `%LOGDIR` and the others can be used in the include line.
+
+The file name cannot contain `%` as that letter is used to end the name for
+the include instruction:
+
+ %include filename%
+
## Conditional lines
Lines in the test file can be made to appear conditionally on a specific
#######################################################################
+
+sub includefile {
+ my ($f) = @_;
+ open(F, "<$f");
+ my @a = <F>;
+ close(F);
+ return join("", @a);
+}
+
sub subbase64 {
my ($thing) = @_;
$d =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;
$$thing =~ s/%%HEX%%/$d/;
}
+ # repeat
while($$thing =~ s/%repeat\[(\d+) x (.*?)\]%/%%REPEAT%%/i) {
# decode %NN characters
my ($d, $n) = ($2, $1);
my $all = $d x $n;
$$thing =~ s/%%REPEAT%%/$all/;
}
+
+ # include a file
+ $$thing =~ s/%include ([^%]*)%[\n\r]+/includefile($1)/ge;
}
my $prevupdate; # module scope so it remembers the last value