summaryrefslogtreecommitdiff
path: root/selftest/Subunit/Diff.pm
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2009-06-05 17:25:42 +0200
committerJelmer Vernooij <jelmer@samba.org>2009-06-11 19:59:59 +0200
commit84f2d3001dd8a9e8734d0b36f4e1445fc1a8254c (patch)
tree4d108911d5257ef64dd8fb875f1ab52b7e772f4e /selftest/Subunit/Diff.pm
parentd8a77a798b5c691c76fcbadbc41c97ff1c9922f3 (diff)
downloadsamba-84f2d3001dd8a9e8734d0b36f4e1445fc1a8254c.tar.gz
samba-84f2d3001dd8a9e8734d0b36f4e1445fc1a8254c.tar.bz2
samba-84f2d3001dd8a9e8734d0b36f4e1445fc1a8254c.zip
selftest/subunit: Add diff command that can diff two subunit streams.
Diffstat (limited to 'selftest/Subunit/Diff.pm')
-rw-r--r--selftest/Subunit/Diff.pm73
1 files changed, 73 insertions, 0 deletions
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;