added test for leaks of ssh's STDIN filehandle leak_test
Christian Walde [Tue, 18 Jun 2013 20:54:42 +0000 (22:54 +0200)]
t/leak.t [new file with mode: 0644]

diff --git a/t/leak.t b/t/leak.t
new file mode 100644 (file)
index 0000000..b25bf1a
--- /dev/null
+++ b/t/leak.t
@@ -0,0 +1,24 @@
+use strictures;
+
+use Test::More;
+
+use Scalar::Util 'weaken';
+use Object::Remote::FromData;
+
+my $conn_ref;
+{
+    my $conn = Object::Remote->connect( '-' );
+    $conn_ref = \( $conn->{send_to_fh} );
+    weaken $conn_ref;
+    is My::TestClass->new::on( $conn )->run, 3, "correct output";
+}
+sleep 3;
+is $$conn_ref, undef, "filehandle to ssh's STDIN is garbage-collected";
+
+done_testing;
+
+__DATA__
+
+package My::TestClass;
+use Moo;
+sub run { "3" }