1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-27 22:50:26 +03:00

selftest/subunit: Add diff command that can diff two subunit streams.

This commit is contained in:
Jelmer Vernooij 2009-06-05 17:25:42 +02:00
parent d8a77a798b
commit 84f2d3001d
5 changed files with 98 additions and 5 deletions

View File

@ -187,7 +187,7 @@ sub skip_testsuite($;$)
{
my ($name, $reason) = @_;
if ($reason) {
print "skip-testsuite: $name [$reason]\n";
print "skip-testsuite: $name [\n$reason\n]\n";
} else {
print "skip-testsuite: $name\n";
}

73
selftest/Subunit/Diff.pm Normal file
View File

@ -0,0 +1,73 @@
#!/usr/bin/perl
# Diff two subunit streams
# Copyright (C) Jelmer Vernooij <jelmer@samba.org>
# Published under the GNU GPL, v3 or later
package Subunit::Diff;
use strict;
use Subunit qw(parse_results);
sub control_msg() { }
sub report_time($$) { }
sub output_msg($$)
{
my ($self, $msg) = @_;
# No output for now, perhaps later diff this as well ?
}
sub start_test($$)
{
my ($self, $testname) = @_;
}
sub end_test($$$$$)
{
my ($self, $testname, $result, $unexpected, $reason) = @_;
$self->{$testname} = $result;
}
sub skip_testsuite($;$) { }
sub start_testsuite($;$) { }
sub end_testsuite($$;$) { }
sub testsuite_count($$) { }
sub new {
my ($class) = @_;
my $self = {
};
bless($self, $class);
}
sub diff($$)
{
my ($fh1, $fh2) = @_;
my $ret = {};
my $statistics = {
TESTS_UNEXPECTED_OK => 0,
TESTS_EXPECTED_OK => 0,
TESTS_UNEXPECTED_FAIL => 0,
TESTS_EXPECTED_FAIL => 0,
TESTS_ERROR => 0,
TESTS_SKIP => 0,
};
my $old = new Subunit::Diff();
parse_results($old, $statistics, $fh1);
my $new = new Subunit::Diff();
parse_results($new, $statistics, $fh2);
foreach my $testname (keys %$old) {
if ($new->{$testname} ne $old->{$testname}) {
$ret->{$testname} = [$old->{$testname}, $new->{$testname}];
}
}
return $ret;
}
1;

24
selftest/diff-subunit.pl Executable file
View File

@ -0,0 +1,24 @@
#!/usr/bin/perl
# Diff two subunit streams
# Copyright (C) Jelmer Vernooij <jelmer@samba.org>
# Published under the GNU GPL, v3 or later
use Getopt::Long;
use strict;
use FindBin qw($RealBin $Script);
use lib "$RealBin";
use Subunit::Diff;
open(FH1, $ARGV[0]) or die("Unable to open $ARGV[0]: $!");
open(FH2, $ARGV[1]) or die("Unable to open $ARGV[1]: $!");
my $ret = Subunit::Diff::diff(*FH1, *FH2);
close(FH1);
close(FH2);
foreach my $e (keys %$ret) {
printf "%s: %s -> %s\n", $e, $ret->{$e}[0], $ret->{$e}[1];
}
0;

View File

@ -81,8 +81,6 @@ if (defined($opt_expected_failures)) {
}
my $statistics = {
SUITES_FAIL => 0,
TESTS_UNEXPECTED_OK => 0,
TESTS_EXPECTED_OK => 0,
TESTS_UNEXPECTED_FAIL => 0,

View File

@ -222,8 +222,6 @@ sub run_testsuite($$$$$)
open(RESULTS, "$cmd 2>&1|");
my $statistics = {
SUITES_FAIL => 0,
TESTS_UNEXPECTED_OK => 0,
TESTS_EXPECTED_OK => 0,
TESTS_UNEXPECTED_FAIL => 0,