my $ipath = 'expect/';
+# The packing list file is used to keep the snippets packed in the
+# same order each time, in order to avoid creating file differences
+# when files are checked in to git. Each of the snippet files
+# also has a small packing list at the top, and the list can
+# be obtained there instead.
+my $fpacking_list = "packing_list.txt";
+
# Limit file size to simplify debugging
my $MAX_TESTS_PER_FILE = 20;
return;
};
+# We can either get the packing list from the snippets, or by
+# reading the packing list file. To get it from the file,
+# pass 'get_passing_list()' the file name. Otherwise,
+# it will be constructed from the snippets. Both
+# methods work.
+#my $rpacking_list=get_packing_list($fpacking_list);
+my $rpacking_list=get_packing_list();
+
my @exp = glob("$ipath*");
#print "exp=(@exp)\n";
+my $ix = 0;
+my $rix_lookup = {};
foreach my $file_exp (@exp) {
my $estring = $get_string->($file_exp);
my $ename = $file_exp;
if ( $ename =~ /([^\/]+)$/ ) { $ename = $1 }
my ( $sname, $pname ) = split /\./, $ename;
- #print "BUBBA: file=$file_exp, ename = $ename, sname=$sname, pname=$pname\n";
$get_source->($sname);
$get_param->($pname);
push @{$rtests}, [ $ename, $pname, $sname, $estring ];
+ $rix_lookup->{$ename} = $ix;
+ $ix++;
+}
+
+# assign indexes to existing packing locations
+my $rassigned;
+my $rcount;
+my $high_file="";
+my $high_digits=0;
+foreach my $item ( @{$rpacking_list} ) {
+ my ( $ofile, $ename ) = @{$item};
+ $rcount->{$ofile}++;
+ my $ix = $rix_lookup->{$ename};
+ push @{$item}, $ix;
+ $rassigned->{$ix} = $ofile;
+
+ # Find the last snippet file in the set
+ if ( $ofile =~ /(\d+)\.t/ ) {
+ my $digits = $1;
+ if ( $digits > $high_digits ) {
+ $high_digits = $digits;
+ $high_file = $ofile;
+ }
+ }
}
-my $file_count = 0;
-my $nend = -1;
-my $nstop = @{$rtests} - 1;
-while ( $nend < $nstop ) {
- $file_count++;
- my $nbeg = $nend + 1;
- $nend += $MAX_TESTS_PER_FILE;
- if ( $nend > $nstop ) { $nend = $nstop }
- my @tests;
- foreach my $n ( $nbeg .. $nend ) { push @tests, $rtests->[$n]; }
+# Pack all new items. Continue with last file in the list
+my $ofile_last = $rpacking_list->[-1]->[0];
+my $case_count = $rcount->{$ofile_last} + 1;
+
+my $file_count = $high_digits;
+
+for ( my $ix = 0 ; $ix < @{$rtests} ; $ix++ ) {
+ next if ( $rassigned->{$ix} );
+ if ( $case_count >= $MAX_TESTS_PER_FILE ) { $case_count = 1; $file_count++ }
+ my $ename = $rtests->[$ix]->[0];
my $ofile = "../snippets" . $file_count . ".t";
- make_snippet_t( $ofile, \@tests, $rparams, $rsources );
- print "Now run a 'make test' from the top directory to check these\n";
+ push @{$rpacking_list}, [ $ofile, $ename, $ix ];
+ print "Added case $ename to $ofile\n";
+ $case_count++;
+}
+
+# make the packing list for each file
+my $rpacking_hash;
+my @missing_cases;
+foreach my $item ( @{$rpacking_list} ) {
+ my ( $ofile, $ename, $ix ) = @{$item};
+ if ( !defined($ix) ) { push @missing_cases, $ename; next }
+ push @{ $rpacking_hash->{$ofile} }, $rtests->[$ix];
+}
+
+# Write the snippet files
+my @empty_files;
+foreach my $ofile ( sort keys %{$rpacking_hash} ) {
+ my @tests = @{ $rpacking_hash->{$ofile} };
+ my $num = @tests;
+ if ($num) {
+ make_snippet_t( $ofile, \@tests, $rparams, $rsources );
+ print "writing $num tests to $ofile\n";
+ }
+ else {
+
+ # a file no longer exists, we should delete or move it
+ push @empty_files, $ofile;
+ system "mv $ofile $ofile.bak";
+ }
+}
+
+if (@missing_cases) {
+ local $" = '> <';
+ print <<EOM;
+Note that these old cases are missing:
+<@missing_cases>
+EOM
+}
+
+if (@empty_files) {
+ local $" = '> <';
+ print <<EOM;
+NOTE: These old files did nnot have any cases, so I moved them to .bak
+<@empty_files>
+EOM
+}
+
+write_packing_list("$fpacking_list", $rpacking_list);
+print "Now run a 'make test' from the top directory to check these\n";
+
+sub write_packing_list {
+ my ( $ofile, $rpacking ) = @_;
+ if (-e $ofile) {system "mv $ofile $ofile.bak"}
+ open my $fh, '>', $ofile or die "cannot open $ofile: $!\n";
+ $fh->print("# This file is automatically generated by make_t.pl\n");
+ foreach my $item ( @{$rpacking} ) {
+ my ( $ofile, $ename ) = @{$item};
+ $fh->print("$ofile\t$ename\n");
+ }
+ $fh->close();
+ print "wrote new packing list to $fpacking_list\n";
+}
+
+sub get_packing_list {
+ my ($ifile) = @_;
+ my $rlist;
+ if ( defined($ifile) && -e $ifile ) {
+ $rlist = read_packing_list($ifile);
+ }
+ else {
+ $rlist = construct_packing_list();
+ }
+ return $rlist;
+}
+
+sub read_packing_list {
+
+ my ($ifile) = @_;
+ my $rlist;
+ open my $fh, '<', $ifile or die "cannot open $ifile: $!\n";
+ foreach my $line (<$fh>) {
+ $line =~ s/^\s+//;
+ $line =~ s/\s+$//;
+ next unless ($line);
+ next if ( $line =~ /^#/ );
+ my ( $ofile, $ename ) = split /\t/, $line;
+ push @{$rlist}, [ $ofile, $ename ];
+ }
+ $fh->close();
+ return $rlist;
+}
+
+sub construct_packing_list {
+
+ # construct the packing list directly from the snippet files
+ # this should be more reliable
+ my @files = glob("../snippets*.t");
+ my $rlist;
+ foreach my $ifile (@files) {
+ open my $fh, '<', $ifile or die "cannot open $ifile: $!\n";
+ my $saw_contents;
+ foreach my $line (<$fh>) {
+ if ( !$saw_contents ) {
+ if ( $line =~ /# Contents/ ) { $saw_contents = 1; next }
+ }
+ else {
+ if ( $line =~ /#\d+\s+(.*)\s*$/ ) {
+ my $ename = $1;
+ push @{$rlist}, [ $ifile, $ename ];
+ }
+ else { last }
+ }
+ }
+ }
+ return $rlist;
}
sub make_snippet_t {
my ( $ofile, $rtests, $rparams_all, $rsources_all ) = @_;
+ my $ename_string = "# Contents:\n";
# pull out the parameters and sources we need
my $rparams = {};
my $rsources = {};
+ my $nn=0;
foreach my $item ( @{$rtests} ) {
my ( $ename, $pname, $sname, $estring ) = @{$item};
$rparams->{$pname} = $rparams_all->{$pname};
$rsources->{$sname} = $rsources_all->{$sname};
+ $nn++;
+ $ename_string .= "#$nn $ename\n";
}
my $count = 0;
my $audit_string = audit_string('#');
my $script = <<EOM;
-# **This script was automatically generated**
$audit_string
-# To locate test #13 for example, search for the string '#13'
+$ename_string
+
+# To locate test #13 you can search for its name or the string '#13'
EOM
$script .= <<'EOM';
#push @audit_trail, "$ch Created with: $0 $args\n";
push @audit_trail, "$string\n";
- push @audit_trail, "$ch $date $host\n";
+ ##push @audit_trail, "$ch $date $host\n";
return \@audit_trail;
}
--- /dev/null
+# This file is automatically generated by make_t.pl
+../snippets1.t 105484.def
+../snippets1.t align1.def
+../snippets1.t align2.def
+../snippets1.t align3.def
+../snippets1.t align4.def
+../snippets1.t align5.def
+../snippets1.t align6.def
+../snippets1.t align7.def
+../snippets1.t align8.def
+../snippets1.t align9.def
+../snippets1.t andor1.def
+../snippets1.t andor10.def
+../snippets1.t andor2.def
+../snippets1.t andor3.def
+../snippets1.t andor4.def
+../snippets1.t andor5.def
+../snippets1.t andor6.def
+../snippets1.t andor7.def
+../snippets1.t andor8.def
+../snippets1.t andor9.def
+../snippets10.t scl.def
+../snippets10.t scl.scl
+../snippets10.t semicolon2.def
+../snippets10.t side_comments1.def
+../snippets10.t sil1.def
+../snippets10.t sil1.sil
+../snippets10.t slashslash.def
+../snippets10.t smart.def
+../snippets10.t space1.def
+../snippets10.t space2.def
+../snippets10.t space3.def
+../snippets10.t space4.def
+../snippets10.t space5.def
+../snippets10.t structure1.def
+../snippets10.t style.def
+../snippets10.t style.style1
+../snippets10.t style.style2
+../snippets10.t style.style3
+../snippets10.t style.style4
+../snippets10.t style.style5
+../snippets11.t sub1.def
+../snippets11.t sub2.def
+../snippets11.t switch1.def
+../snippets11.t syntax1.def
+../snippets11.t syntax2.def
+../snippets11.t ternary1.def
+../snippets11.t ternary2.def
+../snippets11.t tick1.def
+../snippets11.t trim_quote.def
+../snippets11.t tso1.def
+../snippets11.t tso1.tso
+../snippets11.t tutor.def
+../snippets11.t undoci1.def
+../snippets11.t use1.def
+../snippets11.t use2.def
+../snippets11.t version1.def
+../snippets11.t version2.def
+../snippets11.t vert.def
+../snippets11.t vmll.def
+../snippets11.t vmll.vmll
+../snippets12.t vtc1.def
+../snippets12.t vtc1.vtc
+../snippets12.t vtc2.def
+../snippets12.t vtc2.vtc
+../snippets12.t vtc3.def
+../snippets12.t vtc3.vtc
+../snippets12.t vtc4.def
+../snippets12.t vtc4.vtc
+../snippets12.t wn1.def
+../snippets12.t wn1.wn
+../snippets12.t wn2.def
+../snippets12.t wn2.wn
+../snippets12.t wn3.def
+../snippets12.t wn3.wn
+../snippets12.t wn4.def
+../snippets12.t wn4.wn
+../snippets12.t wn5.def
+../snippets12.t wn5.wn
+../snippets12.t wn6.def
+../snippets12.t wn6.wn
+../snippets2.t angle.def
+../snippets2.t arrows1.def
+../snippets2.t arrows2.def
+../snippets2.t attrib1.def
+../snippets2.t attrib2.def
+../snippets2.t attrib3.def
+../snippets2.t bar1.bar
+../snippets2.t bar1.def
+../snippets2.t block1.def
+../snippets2.t boc1.boc
+../snippets2.t boc1.def
+../snippets2.t boc2.boc
+../snippets2.t boc2.def
+../snippets2.t break1.def
+../snippets2.t break2.def
+../snippets2.t break3.def
+../snippets2.t break4.def
+../snippets2.t carat.def
+../snippets2.t ce1.ce
+../snippets2.t ce1.def
+../snippets3.t ce_wn1.ce_wn
+../snippets3.t ce_wn1.def
+../snippets3.t colin.colin
+../snippets3.t colin.def
+../snippets3.t essential.def
+../snippets3.t essential.essential1
+../snippets3.t essential.essential2
+../snippets3.t extrude1.def
+../snippets3.t extrude1.extrude
+../snippets3.t extrude2.def
+../snippets3.t extrude2.extrude
+../snippets3.t extrude3.def
+../snippets3.t extrude3.extrude
+../snippets3.t extrude4.def
+../snippets3.t extrude4.extrude
+../snippets3.t fabrice_bug.def
+../snippets3.t fabrice_bug.fabrice_bug
+../snippets3.t format1.def
+../snippets3.t given1.def
+../snippets3.t gnu1.def
+../snippets4.t gnu1.gnu
+../snippets4.t gnu2.def
+../snippets4.t gnu2.gnu
+../snippets4.t gnu3.def
+../snippets4.t gnu3.gnu
+../snippets4.t gnu4.def
+../snippets4.t gnu4.gnu
+../snippets4.t hanging_side_comments1.def
+../snippets4.t hanging_side_comments2.def
+../snippets4.t hash1.def
+../snippets4.t hashbang.def
+../snippets4.t here1.def
+../snippets4.t html1.def
+../snippets4.t html1.html
+../snippets4.t ident1.def
+../snippets4.t if1.def
+../snippets4.t iscl1.def
+../snippets4.t iscl1.iscl
+../snippets4.t label1.def
+../snippets4.t lextest1.def
+../snippets5.t list1.def
+../snippets5.t listop1.def
+../snippets5.t listop2.def
+../snippets5.t lp1.def
+../snippets5.t lp1.lp
+../snippets5.t mangle1.def
+../snippets5.t mangle1.mangle
+../snippets5.t mangle2.def
+../snippets5.t mangle2.mangle
+../snippets5.t mangle3.def
+../snippets5.t mangle3.mangle
+../snippets5.t math1.def
+../snippets5.t math2.def
+../snippets5.t math3.def
+../snippets5.t math4.def
+../snippets5.t nasc.def
+../snippets5.t nasc.nasc
+../snippets5.t nothing.def
+../snippets5.t nothing.nothing
+../snippets5.t otr1.def
+../snippets6.t otr1.otr
+../snippets6.t pbp1.def
+../snippets6.t pbp1.pbp
+../snippets6.t pbp2.def
+../snippets6.t pbp2.pbp
+../snippets6.t pbp3.def
+../snippets6.t pbp3.pbp
+../snippets6.t pbp4.def
+../snippets6.t pbp4.pbp
+../snippets6.t pbp5.def
+../snippets6.t pbp5.pbp
+../snippets6.t print1.def
+../snippets6.t q1.def
+../snippets6.t q2.def
+../snippets6.t recombine1.def
+../snippets6.t recombine2.def
+../snippets6.t recombine3.def
+../snippets6.t recombine4.def
+../snippets6.t rt101547.def
+../snippets6.t rt102371.def
+../snippets7.t rt102451.def
+../snippets7.t rt104427.def
+../snippets7.t rt106492.def
+../snippets7.t rt107832.def
+../snippets7.t rt107832.rt107832
+../snippets7.t rt111519.def
+../snippets7.t rt111519.rt111519
+../snippets7.t rt112534.def
+../snippets7.t rt113689.def
+../snippets7.t rt113689.rt113689
+../snippets7.t rt113792.def
+../snippets7.t rt114359.def
+../snippets7.t rt114909.def
+../snippets7.t rt116344.def
+../snippets7.t rt119140.def
+../snippets7.t rt119588.def
+../snippets7.t rt119970.def
+../snippets7.t rt119970.rt119970
+../snippets7.t rt123492.def
+../snippets7.t rt123749.def
+../snippets8.t rt123749.rt123749
+../snippets8.t rt123774.def
+../snippets8.t rt124114.def
+../snippets8.t rt124354.def
+../snippets8.t rt124354.rt124354
+../snippets8.t rt125012.def
+../snippets8.t rt125012.rt125012
+../snippets8.t rt125506.def
+../snippets8.t rt125506.rt125506
+../snippets8.t rt126965.def
+../snippets8.t rt15735.def
+../snippets8.t rt18318.def
+../snippets8.t rt18318.rt18318
+../snippets8.t rt27000.def
+../snippets8.t rt31741.def
+../snippets8.t rt49289.def
+../snippets8.t rt50702.def
+../snippets8.t rt50702.rt50702
+../snippets8.t rt68870.def
+../snippets8.t rt70747.def
+../snippets9.t rt70747.rt70747
+../snippets9.t rt74856.def
+../snippets9.t rt78156.def
+../snippets9.t rt78764.def
+../snippets9.t rt79813.def
+../snippets9.t rt79947.def
+../snippets9.t rt80645.def
+../snippets9.t rt81852.def
+../snippets9.t rt81852.rt81852
+../snippets9.t rt81854.def
+../snippets9.t rt87502.def
+../snippets9.t rt93197.def
+../snippets9.t rt94338.def
+../snippets9.t rt95419.def
+../snippets9.t rt95708.def
+../snippets9.t rt96021.def
+../snippets9.t rt96101.def
+../snippets9.t rt98902.def
+../snippets9.t rt98902.rt98902
+../snippets9.t rt99961.def
+../snippets13.t align10.def
+../snippets13.t align11.def
+../snippets13.t align12.def