diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2009-06-05 17:25:42 +0200 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2009-06-11 19:59:59 +0200 |
commit | 84f2d3001dd8a9e8734d0b36f4e1445fc1a8254c (patch) | |
tree | 4d108911d5257ef64dd8fb875f1ab52b7e772f4e | |
parent | d8a77a798b5c691c76fcbadbc41c97ff1c9922f3 (diff) | |
download | samba-84f2d3001dd8a9e8734d0b36f4e1445fc1a8254c.tar.gz samba-84f2d3001dd8a9e8734d0b36f4e1445fc1a8254c.tar.bz2 samba-84f2d3001dd8a9e8734d0b36f4e1445fc1a8254c.zip |
selftest/subunit: Add diff command that can diff two subunit streams.
-rw-r--r-- | selftest/Subunit.pm | 2 | ||||
-rw-r--r-- | selftest/Subunit/Diff.pm | 73 | ||||
-rwxr-xr-x | selftest/diff-subunit.pl | 24 | ||||
-rwxr-xr-x | selftest/filter-subunit.pl | 2 | ||||
-rwxr-xr-x | selftest/selftest.pl | 2 |
5 files changed, 98 insertions, 5 deletions
diff --git a/selftest/Subunit.pm b/selftest/Subunit.pm index bb23483d12..9ca68f3db2 100644 --- a/selftest/Subunit.pm +++ b/selftest/Subunit.pm @@ -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"; } diff --git a/selftest/Subunit/Diff.pm b/selftest/Subunit/Diff.pm new file mode 100644 index 0000000000..8add5827f4 --- /dev/null +++ b/selftest/Subunit/Diff.pm @@ -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; diff --git a/selftest/diff-subunit.pl b/selftest/diff-subunit.pl new file mode 100755 index 0000000000..225c3d8986 --- /dev/null +++ b/selftest/diff-subunit.pl @@ -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; diff --git a/selftest/filter-subunit.pl b/selftest/filter-subunit.pl index 912070a0d4..1c25db6f59 100755 --- a/selftest/filter-subunit.pl +++ b/selftest/filter-subunit.pl @@ -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, diff --git a/selftest/selftest.pl b/selftest/selftest.pl index 28e0460a5a..3094f78b8e 100755 --- a/selftest/selftest.pl +++ b/selftest/selftest.pl @@ -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, |