From bf14c34490c869745d0ed5f9611ab8b5904d94d7 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Sat, 27 Feb 2021 05:59:55 -0800 Subject: [PATCH] update testing tools --- dev-bin/perltidy_minimal_flags.pl | 4 ++ dev-bin/perltidy_random_run.pl | 69 ++++++++++++++++++++++++------- dev-bin/perltidy_random_setup.pl | 13 ++++++ 3 files changed, 71 insertions(+), 15 deletions(-) diff --git a/dev-bin/perltidy_minimal_flags.pl b/dev-bin/perltidy_minimal_flags.pl index b18545cd..e4785dc0 100755 --- a/dev-bin/perltidy_minimal_flags.pl +++ b/dev-bin/perltidy_minimal_flags.pl @@ -56,6 +56,10 @@ while ( my $line = ) { # remove flags not related to formatting next if ( $ris_non_essential->{$key} ); + # Turn off iterations + if ( $key =~ /^(iterations|it)=/ ) { $line = '##' . $line } + if ( $key =~ /^(converge|conv)/ ) { $line = '##' . $line } + push @lines, $line; } close IN; diff --git a/dev-bin/perltidy_random_run.pl b/dev-bin/perltidy_random_run.pl index f61f551d..878a2cbb 100755 --- a/dev-bin/perltidy_random_run.pl +++ b/dev-bin/perltidy_random_run.pl @@ -48,7 +48,7 @@ getopts( 'h', \%opts ) or die "$usage"; if ( $opts{h} ) { die "$usage" } our $rsetup; # the config info -my $hash='#'; +my $hash = '#'; my $config_file = "config.txt"; if ( !-e $config_file ) { @@ -80,6 +80,7 @@ elsif ( $ARGV[0] ) { read_config($config_file); my $chain_mode = $rsetup->{chain_mode}; +my $append_flags = $rsetup->{append_flags}; my $do_syntax_check = $rsetup->{syntax_check}; my $delete_good_output = $rsetup->{delete_good_output}; my $FILES_file = $rsetup->{files}; @@ -124,6 +125,8 @@ if ( !@profiles ) { my $rsummary = []; my @problems; +my $BLINKDIR = "BLINKERS"; + my $stop_file = 'stop.now'; if ( -e $stop_file ) { unlink $stop_file } @@ -186,7 +189,7 @@ for ( my $nf = $nf_beg ; $nf <= $nf_end ; $nf++ ) { my $efile_count = 0; my $has_starting_error; my $starting_syntax_ok = 1; - my $tmperr = "STDERR.txt"; + my $tmperr = "STDERR.txt"; # Inner loop over profiles for a given file for ( my $np = $np_beg ; $np <= $np_end ; $np++ ) { @@ -205,29 +208,31 @@ for ( my $nf = $nf_beg ; $nf <= $nf_end ; $nf++ ) { print STDERR "$hash>Run '$nf.$np' : profile='$profile', ifile='$ifile'\n"; - if (-e $tmperr) {unlink $tmperr} - my $cmd = "$binfile <$ifile >$ofile -pro=$profile 2>$tmperr"; - system_echo($cmd,$hash); + if ( -e $tmperr ) { unlink $tmperr } + #my $cmd = "$binfile <$ifile >$ofile -pro=$profile 2>$tmperr"; + my $cmd = "$binfile <$ifile >$ofile -pro=$profile $append_flags 2>$tmperr"; + system_echo( $cmd, $hash ); my $efile = "perltidy.ERR"; my $logfile = "perltidy.LOG"; if ( -e $efile ) { rename $efile, "ERR.$ext" } if ( -e $logfile ) { rename $logfile, "LOG.$ext" } if ( -e $tmperr && !-z $tmperr ) { - open(IN,"<",$tmperr); - foreach my $line() { - if ($line=~/BLINKER/) { - $error_count++; + open( IN, "<", $tmperr ); + foreach my $line () { + if ( $line =~ /BLINKER/ ) { + ##$error_count++; push @blinkers, $ofile; $error_count_this_file++; $error_count_this_case++; + save_blinker_info( "$np.$nf", $ofile, $profile, $tmperr ); } - if ($line=~/STRANGE/) { + if ( $line =~ /STRANGE/ ) { $error_count++; push @strange, $ofile; $error_count_this_file++; $error_count_this_case++; } - if ($line=~/uninitialized/) { + if ( $line =~ /uninitialized/ ) { $error_count++; push @uninitialized, $ofile; $error_count_this_file++; @@ -315,7 +320,7 @@ for ( my $nf = $nf_beg ; $nf <= $nf_end ; $nf++ ) { if ( $do_syntax_check && $starting_syntax_ok ) { my $synfile = "$ofile.syntax"; my $cmd = "perl -c $ofile 2>$synfile"; - system_echo($cmd,$hash); + system_echo( $cmd, $hash ); my $fh; if ( open( $fh, '<', $synfile ) ) { my @lines = <$fh>; @@ -323,7 +328,9 @@ for ( my $nf = $nf_beg ; $nf <= $nf_end ; $nf++ ) { if ( $case == 1 ) { $starting_syntax_ok = $syntax_ok; unlink $synfile; - if ($syntax_ok) { print STDERR "$hash syntax OK for $ofile\n"; } + if ($syntax_ok) { + print STDERR "$hash syntax OK for $ofile\n"; + } } elsif ($syntax_ok) { unlink $synfile; @@ -342,7 +349,8 @@ for ( my $nf = $nf_beg ; $nf <= $nf_end ; $nf++ ) { # run perltidy on the output to see if it can be reformatted # without errors my $cmd2 = "perltidy <$ofile >$chkfile"; - system_echo($cmd2,$hash); + system_echo( $cmd2, $hash ); + #print STDERR "$cmd2\n"; my $err; if ( -e $efile ) { @@ -505,7 +513,7 @@ if (@saved_for_deletion) { } # Summarize results.. -if (@problems) { +if (@problems || @blinkers) { print STDERR <$blink_dir/README.txt"); + return; +} + sub report_results { my ($rh) = @_; diff --git a/dev-bin/perltidy_random_setup.pl b/dev-bin/perltidy_random_setup.pl index ef329f0b..4222028e 100755 --- a/dev-bin/perltidy_random_setup.pl +++ b/dev-bin/perltidy_random_setup.pl @@ -96,6 +96,7 @@ my $nprofiles = @{$rprofiles}; while (1) { my $files = $rsetup->{files}; my $chain_mode = $rsetup->{chain_mode}; + my $append_flags = $rsetup->{append_flags}; my $do_syntax_check = $rsetup->{syntax_check}; my $delete_good_output = $rsetup->{delete_good_output}; my $perltidy_version = $rsetup->{perltidy}; @@ -110,6 +111,7 @@ $profile_info C - Chain mode : $chain_mode D - Delete good output? : $delete_good_output S - Syntax check? : $do_syntax_check +A - Append flags : $append_flags V - perltidy Version : $perltidy_version Q - Quit without saving config file W - Write config, FILES.txt, PROFILES.txt, GO.sh and eXit @@ -137,6 +139,10 @@ EOM $chain_mode = get_num("Chaining: 0=no, 1=always,2=random"); $rsetup->{chain_mode} = $chain_mode; } + elsif ( $ans eq 'A' ) { + my $str = query("Enter any flags to append"); + $rsetup->{append_flags} = $str; + } elsif ( $ans eq 'D' ) { $delete_good_output = ifyes( "Delete needless good output files? [Y/N]", "Y" ); @@ -316,6 +322,7 @@ sub default_config { profiles => $PROFILES_file, files => $FILES_file, perltidy => $perltidy, + append_flags => "", }; return; } @@ -1013,6 +1020,9 @@ EOM 'default-tabsize' => [ 0, 8 ], 'entab-leading-whitespace' => [ 0, 8 ], + # always iterate + 'iterations' => [ 6, 10 ], + 'want-break-after' => \@operators, 'want-break-before' => \@operators, 'want-left-space' => \@operators, @@ -1090,6 +1100,7 @@ EOM logfile logfile-gap look-for-hash-bang + maximum-file-size-mb notidy outfile output-file-extension @@ -1105,6 +1116,8 @@ EOM tee-side-comments version delete-pod + tabs + entab-leading-whitespace ); my %skip; -- 2.39.5