Add test for macro expansion in file names

This commit is contained in:
Martin Konrad
2019-01-07 14:55:12 -05:00
parent 409ee26fae
commit a9606dbf6e
4 changed files with 22 additions and 2 deletions

View File

@@ -11,7 +11,7 @@
use strict;
use Test;
BEGIN {plan tests => 11}
BEGIN {plan tests => 12}
# Check include/substitute command model
ok(msi('-I .. ../t1-template.txt'), slurp('../t1-result.txt'));
@@ -56,6 +56,8 @@ ok(msi('-I. -I.. -S ../t10-substitute.txt'), slurp('../t10-result.txt'));
# Substitution file, pattern format, with 0 pattern definitions
ok(msi('-I. -I.. -S ../t11-substitute.txt'), slurp('../t11-result.txt'));
# Macros in template-file name populated from environment variable
ok(msi('-I. -I.. -S ../t12-substitute.txt', 'TEST_NO=12,PREFIX=t'), slurp('../t12-result.txt'));
# Test support routines
@@ -68,10 +70,16 @@ sub slurp {
}
sub msi {
my ($args) = @_;
my ($args, $envstr) = @_;
my $exe = ($^O eq 'MSWin32') || ($^O eq 'cygwin') ? '.exe' : '';
my $msi = "./msi-copy$exe";
my $result;
my @envs = split(/,/, $envstr);
foreach (@envs)
{
my ($var, $value) = split /=/, $_;
$ENV{$var} = $value;
}
if ($args =~ m/-o / && $args !~ m/-D/) {
# An empty result is expected
$result = `$msi $args`;
@@ -85,5 +93,10 @@ sub msi {
if $result eq '';
} while ($result eq '') && (--$count > 0);
}
foreach (@envs)
{
my ($var, $value) = split /=/, $_;
delete $ENV{$var};
}
return $result;
}

View File

@@ -0,0 +1,2 @@
# comment line
a=foo

View File

@@ -0,0 +1,3 @@
file $(PREFIX)$(TEST_NO)-template.txt {
{ a=foo }
}

View File

@@ -0,0 +1,2 @@
# comment line
a=$(a)