Bug#711446: [PATCH 1/2] Tests: Provide a TestUtils.pl containing broken-out launder() function

Ian Jackson ijackson at chiark.greenend.org.uk
Sat Feb 8 17:56:02 UTC 2014


The code for laundering font sizes was duplicated between the tests.
Instead, break it out into a common function launder() in a new file
t/TestUtils.pl (which exists just for the tests).

Signed-off-by: Ian Jackson <ijackson at chiark.greenend.org.uk>

squash! Tests: Provide a Test.pm containing
---
 MANIFEST       |    1 +
 t/1.simple.t   |    6 +++---
 t/2.ioall.t    |    7 ++++---
 t/TestUtils.pl |    8 ++++++++
 4 files changed, 16 insertions(+), 6 deletions(-)
 create mode 100644 t/TestUtils.pl

diff --git a/MANIFEST b/MANIFEST
index 749c521..68c47e7 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -14,3 +14,4 @@ README
 t/0.use.t
 t/1.simple.t
 t/2.ioall.t
+t/TestUtils.pl
diff --git a/t/1.simple.t b/t/1.simple.t
index 952a07b..66fb1e2 100644
--- a/t/1.simple.t
+++ b/t/1.simple.t
@@ -6,6 +6,7 @@ use Test::Simple tests => 1;
 use IO::All;
 use Graph;
 use Graph::Writer::GraphViz;
+require 't/TestUtils.pl';
 
 my @v = qw/Alice Bob Crude Dr/;
 my $g = Graph->new;
@@ -17,9 +18,8 @@ $wr->write_graph($g,'t/graph.simple.dot');
 $/ = undef;
 my $g1 = <DATA>;
 my $g2 = io('t/graph.simple.dot')->slurp;
-# Ignore font-sizes, it's system-dependant
-$g1 =~ s/\d+/0/g;
-$g2 =~ s/\d+/0/g;
+launder(\$g1);
+launder(\$g2);
 ok($g1 eq $g2);
 unlink('t/graph.simple.dot');
 
diff --git a/t/2.ioall.t b/t/2.ioall.t
index f18fff8..a489445 100644
--- a/t/2.ioall.t
+++ b/t/2.ioall.t
@@ -6,6 +6,7 @@ use Test::Simple tests => 2;
 use IO::All;
 use Graph;
 use Graph::Writer::GraphViz;
+require 't/TestUtils.pl';
 
 my @v = qw/Alice Bob Crude Dr/;
 my $g = Graph->new;
@@ -25,9 +26,9 @@ $g2 = $io->slurp;
 }
 
 ok(-f 't/graph.ioall.dot');
-# Ignore font-sizes, it's system-dependant
-$g1 =~ s/\d+/0/g;
-$g2 =~ s/\d+/0/g;
+
+launder(\$g1);
+launder(\$g2);
 ok($g1 eq $g2);
 $io->unlink;
 
diff --git a/t/TestUtils.pl b/t/TestUtils.pl
new file mode 100644
index 0000000..4fec3d3
--- /dev/null
+++ b/t/TestUtils.pl
@@ -0,0 +1,8 @@
+
+sub launder ($) {
+    my ($gr) = @_;
+    # Ignore font-sizes, it's system-dependant
+    $$gr =~ s/\d+/0/g;
+}
+
+1;
-- 
1.7.10.4



More information about the pkg-perl-maintainers mailing list