@@ -7,8 +7,6 @@ use POSIX qw( WEXITSTATUS WIFEXITED);
77use Cwd qw( abs_path getcwd) ;
88use File::Path qw( mkpath) ; # mkpath works with ancient perl, as well as newer perl
99
10- eval ' use YAML qw(LoadFile); 1' || die " TESTrun needs YAML.pm. apt install libyaml-perl/yum install perl-YAML/cpanm YAML" ;
11-
1210# these are created in the directory where we are run, which might be
1311# a build directory.
1412my $newdir = " tests/NEW" ;
@@ -57,7 +55,7 @@ my $failureoutput=$origdir . "/tests/failure-outputs.txt";
5755open (FAILUREOUTPUT, " >" . $failureoutput );
5856close (FAILUREOUTPUT);
5957
60- sub runComplexTests {
58+ sub runShellTests {
6159
6260 my @files = glob ( $testsdir . ' /*.sh' );
6361 foreach $file (@files ) {
@@ -73,16 +71,16 @@ sub runComplexTests {
7371 # have to update passed/failed here
7472}
7573
76- sub runOneYamlTest {
77- local ($yamltest ) = @_ ;
74+ sub runOneComplexTest {
75+ local ($testconfig ) = @_ ;
7876
79- my $output = $yamltest -> {output };
80- my $input = $yamltest -> {input };
81- my $name = $yamltest -> {name };
82- my $options = $yamltest -> {args };
77+ my $output = $testconfig -> {output };
78+ my $input = $testconfig -> {input };
79+ my $name = $testconfig -> {name };
80+ my $options = $testconfig -> {args };
8381
8482 # use Data::Dumper;
85- # print Dumper($yamltest );
83+ # print Dumper($testconfig );
8684
8785 my $result = runtest($name ,
8886 $testsdir . " /" . $input ,
@@ -96,14 +94,27 @@ sub runOneYamlTest {
9694 }
9795}
9896
99- sub runYamlTests {
100- my @files = glob ( $testsdir . ' /*.yaml' );
97+ # *.tests files are PERL hash definitions. They should create an array of hashes
98+ # one per test, and place it into the variable @testlist.
99+ sub runComplexTests {
100+ my @files = glob ( $testsdir . ' /*.tests' );
101101 foreach $file (@files ) {
102- # print "FILE: ${file}\n";
103- my $yaml = LoadFile($file );
104-
105- foreach $name (keys %$yaml ) {
106- runOneYamlTest($yaml -> {$name });
102+ my @testlist = undef ;
103+ print " FILE: ${file} \n " ;
104+ open (FILE, " <" .$file ) || die " can not open $file : $! " ;
105+ local $/ = undef ;
106+ $definitions = <FILE>;
107+ close (FILE);
108+ # print "STUFF: ${definitions}\n";
109+ eval $definitions ;
110+ if (defined ($testlist )) {
111+ # use Data::Dumper;
112+ # print Dumper($testlist);
113+ foreach $test (@$testlist ) {
114+ runOneComplexTest($test );
115+ }
116+ } else {
117+ warn " File: ${file} could not be loaded as PERL: $! " ;
107118 }
108119 }
109120}
@@ -130,14 +141,14 @@ sub runSimpleTests {
130141 output => $output ,
131142 args => $options };
132143
133- runOneYamlTest ($hash );
144+ runOneComplexTest ($hash );
134145 }
135146}
136147
137148if (scalar (@ARGV ) == 0) {
138- runComplexTests ();
149+ runShellTests ();
139150 runSimpleTests();
140- runYamlTests ();
151+ runComplexTests ();
141152} else {
142153 runSimpleTests($ARGV [0]);
143154}
0 commit comments