Apache-Test

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

Allow / \ and \\ path delimiters in SKIP file [Markus Wichitill
<mawic@gmx.de>]

Added an apxs query cache for improved test performance [Gozer]

run_tests make target no longer invokes t/TEST -clean, making it
possible to save a few development cycles when a full cleanup is
not required between runs.  [Geoffrey Young] 

Apache::TestSmoke imrovements: [Stas]
 o the command line option -iterations=N should always be respected
   (previously it was internally overriden for order!='random').
 o since IPC::Run3 broke the Ctrl-C handler, we started to loose any
   intermediate results, should the run be aborted. So for now, try to
   always store those results in the temp file:
   smoke-report...$iter.temp

fix 'require blib' in scripts to also call 'blib->import', required to
have an effect under perl 5.6.x. [Stas]

don't allow running an explicit 'perl Makefile.PL', when Apache-Test

lib/Apache/TestSmoke.pm  view on Meta::CPAN

);

sub new {
    my($class, @argv) = @_;

    my $self = bless {
        seen    => {}, # seen sequences and tried them md5 hash
        results => {}, # final reduced sequences md5 hash
        smoking_completed         => 0,
        tests                     => [],
        total_iterations          => 0,
        total_reduction_attempts  => 0,
        total_reduction_successes => 0,
        total_tests_run           => 0,
    }, ref($class)||$class;

    $self->{test_config} = Apache::TestConfig->thaw;

    $self->getopts(\@argv);
    my $opts = $self->{opts};

lib/Apache/TestSmoke.pm  view on Meta::CPAN

    my $iter = 0;

    warning "running t/TEST in the bug report mode";

    my $reduce_iter = 0;
    my @good = ();

    # first time run all tests, or all specified tests
    my @tests = @{ $self->{tests} }; # copy
    my $bad = $self->run_test($iter, $reduce_iter, \@tests, \@good);
    $self->{total_iterations}++;

}


# returns true if for some reason no more iterations should be made
sub run_iter {
    my($self, $iter) = @_;
    my $stop_now = 0;
    my $reduce_iter = 0;
    my @good = ();
    warning "\n" . sep("-");
    warning sprintf "[%03d-%02d-%02d] running all tests",
        $iter, $reduce_iter, $self->{times};


    # first time run all tests, or all specified tests
    my @tests = @{ $self->{tests} }; # copy

    # hack to ensure a new random seed is generated
    Apache::TestSort->run(\@tests, $self);

    my $bad = $self->run_test($iter, $reduce_iter, \@tests, \@good);
    unless ($bad) {
        $self->{total_iterations}++;
        return $stop_now;
    }
    error "recorded a positive failure ('$bad'), " .
        "will try to minimize the input now";

    my $command = $self->{base_command};

    # does the test fail on its own
    {
        $reduce_iter++;
        warning sprintf "[%03d-%02d-%02d] trying '$bad' on its own",
            $iter, $reduce_iter, 1;
        my @good = ();
        my @tests = ($bad);
        my $bad = $self->run_test($iter, $reduce_iter, \@tests, \@good);
        # if a test is failing on its own there is no point to
        # continue looking for other sequences
        if ($bad) {
            $stop_now = 1;
            $self->{total_iterations}++;
            unless ($self->sequence_seen($self->{results}, [@good, $bad])) {
                $self->report_success($iter, $reduce_iter, "$command $bad", 1);
            }
            return $stop_now;
        }
    }

    # positive failure
    my $ok_tests = @good;
    my $reduction_success = 0;

lib/Apache/TestSmoke.pm  view on Meta::CPAN

            $done = 1;
            last;
        }

    }

    # we have a minimal failure sequence at this point (to the extend
    # of success of our attempts to reduce)

    # report the sequence if we didn't see such one yet in the
    # previous iterations
    unless ($self->sequence_seen($self->{results}, [@good, $bad])) {
        # if no reduction succeeded, it's 0
        $reduce_iter = 0 unless $reduction_success;
        $self->report_success($iter, $reduce_iter,
                              "$command @good $bad", @good + 1);
    }

    $self->{total_iterations}++;

    return $stop_now;
}

# my $sub = $self->reduce_stream(\@items);
sub reduce_stream {
    my($self) = shift;
    my @items = @{+shift};

    my $items = @items;

lib/Apache/TestSmoke.pm  view on Meta::CPAN

        my $sep = sep("-");
        my $cfg_as_string = $self->build_config_as_string;
        my $unique_seqs   = scalar keys %{ $self->{results} };
        my $attempts      = $self->{total_reduction_attempts};
        my $successes     = $self->{total_reduction_successes};
        my $completion    = $self->{smoking_completed}
            ? "Completed"
            : "Not Completed (aborted by user)";

        my $status = "Unknown";
        if ($self->{total_iterations} > 0) {
            if ($failures) {
                $status = "*** NOT OK ***";
            }
            else {
                $status = "+++ OK +++";
            }
        }

        my $title = sep('=', "Summary");

        my $iter_made = sprintf "Iterations (%s) made : %d",
            $self->{order}, $self->{total_iterations};

        print $fh <<EOM;

$title
Completion               : $completion
Status                   : $status
Tests run                : $self->{total_tests_run}
$iter_made
EOM

lib/Apache/TestSmoke.pm  view on Meta::CPAN


=head1 SYNOPSIS

  # get the usage and the default values
  % t/SMOKE -help

  # repeat all tests 5 times and save the report into
  # the file 'myreport'
  % t/SMOKE -times=5 -report=myreport

  # run all tests default number of iterations, and repeat tests
  # default number of times
  % t/SMOKE

  # same as above but work only the specified tests
  % t/SMOKE foo/bar foo/tar

  # run once a sequence of tests in a non-random mode
  # e.g. when trying to reduce a known long sequence that fails
  % t/SMOKE -order=rotate -times=1 foo/bar foo/tar



( run in 1.360 second using v1.01-cache-2.11-cpan-96521ef73a4 )