Apache-Test
view release on metacpan or search on metacpan
lib/Apache/TestSmoke.pm view on Meta::CPAN
for my $test (@$tests) {
(my $test_name = $test) =~ s/\.t$//;
my $fill = "." x ($max_len - length $test_name);
$self->{total_tests_run}++;
my $test_command = "$command $test";
my $log = '';
IPC::Run3::run3($test_command, undef, \$log, \$log);
my $ok = ($log =~ /All tests successful|NOTESTS/) ? 1 : 0;
my @core_files_msg = $self->Apache::TestRun::scan_core_incremental(1);
# if the test has caused core file(s) it's not ok
$ok = 0 if @core_files_msg;
if ($ok == 1) {
push @$ra_ok, $test;
if ($self->{verbose}) {
if ($log =~ m/NOTESTS/) {
print STDERR "$test_name${fill}skipped\n";
} else {
print STDERR "$test_name${fill}ok\n";
}
}
# need to run log_diff to reset the position of the fh
my %log_diffs = map { $_ => $self->log_diff($_) } @log_files;
}
elsif ($ok == 0) {
push @$ra_nok, $test;
$bad = $test;
if ($self->{verbose}) {
print STDERR "$test_name${fill}FAILED\n";
error sep("-");
# give server some time to finish the
# logging. it's ok to wait long time since we have
# to deal with an error
sleep 5;
my %log_diffs = map { $_ => $self->log_diff($_) } @log_files;
# client log
error "\t\t*** run log ***";
$log =~ s/^/ /mg;
print STDERR "$log\n";
# server logs
for my $path (@log_files) {
next unless length $log_diffs{$path};
error "\t\t*** $path ***";
$log_diffs{$path} =~ s/^/ /mg;
print STDERR "$log_diffs{$path}\n";
}
}
if (@core_files_msg) {
unless ($self->{verbose}) {
# currently the output of 'run log' already
# includes the information about core files once
# Test::Harness::Straps allows us to run callbacks
# after each test, and we move back to run all
# tests at once, we will log the message here
error "$test_name caused core";
print STDERR join "\n", @core_files_msg, "\n";
}
}
if ($self->{verbose}) {
error sep("-");
}
unless ($self->{bug_mode}) {
# normal smoke stop the run, but in the bug_mode
# we want to complete all the tests
last;
}
}
}
}
$self->logs_end();
# stop server
$self->kill_proc();
if ($self->{bug_mode}) {
warning sep("-");
if (@$ra_nok == 0) {
printf STDERR "All tests successful (%d)\n", scalar @$ra_ok;
}
else {
error sprintf "error running %d tests out of %d\n",
scalar(@$ra_nok), scalar @$ra_ok + @$ra_nok;
}
}
else {
return $bad;
}
}
sub report_start {
my($self) = shift;
my $time = scalar localtime;
$self->{start_time} = $time;
$time =~ s/\s/_/g;
$time =~ s/:/-/g; # winFU
my $file = $self->{opts}->{report} ||
catfile Apache::Test::vars('top_dir'), "smoke-report-$time.txt";
$self->{runtime}->{report} = $file;
info "Report file: $file";
open my $fh, ">$file" or die "cannot open $file for writing: $!";
$self->{fh} = $fh;
my $sep = sep("-");
my $title = sep('=', "Special Tests Sequence Failure Finder Report");
( run in 0.588 second using v1.01-cache-2.11-cpan-39bf76dae61 )