r8228 - in /branches/upstream/libtest-expect-perl: ./ current/ current/lib/ current/lib/Test/ current/t/

makholm at users.alioth.debian.org makholm at users.alioth.debian.org
Fri Oct 12 19:18:27 UTC 2007


Author: makholm
Date: Fri Oct 12 19:18:27 2007
New Revision: 8228

URL: http://svn.debian.org/wsvn/?sc=1&rev=8228
Log:
[svn-inject] Installing original source of libtest-expect-perl

Added:
    branches/upstream/libtest-expect-perl/
    branches/upstream/libtest-expect-perl/current/
    branches/upstream/libtest-expect-perl/current/Build.PL
    branches/upstream/libtest-expect-perl/current/CHANGES
    branches/upstream/libtest-expect-perl/current/MANIFEST
    branches/upstream/libtest-expect-perl/current/META.yml
    branches/upstream/libtest-expect-perl/current/Makefile.PL
    branches/upstream/libtest-expect-perl/current/README
    branches/upstream/libtest-expect-perl/current/lib/
    branches/upstream/libtest-expect-perl/current/lib/Test/
    branches/upstream/libtest-expect-perl/current/lib/Test/Expect.pm
    branches/upstream/libtest-expect-perl/current/read
    branches/upstream/libtest-expect-perl/current/readline
    branches/upstream/libtest-expect-perl/current/t/
    branches/upstream/libtest-expect-perl/current/t/simple.t

Added: branches/upstream/libtest-expect-perl/current/Build.PL
URL: http://svn.debian.org/wsvn/branches/upstream/libtest-expect-perl/current/Build.PL?rev=8228&op=file
==============================================================================
--- branches/upstream/libtest-expect-perl/current/Build.PL (added)
+++ branches/upstream/libtest-expect-perl/current/Build.PL Fri Oct 12 19:18:27 2007
@@ -1,0 +1,16 @@
+use Module::Build;
+use strict;
+
+my $build = Module::Build->new(
+  create_makefile_pl => 'traditional',
+  license            => 'perl',
+  module_name        => 'Test::Expect',
+  requires           => {
+    'Class::Accessor::Chained::Fast'   => '0',
+    'Expect::Simple' => '0',
+    'Term::ReadLine' => '0',
+    'Test::Builder'  => '0',
+    'Test::More'     => '0',
+  },
+);
+$build->create_build_script;

Added: branches/upstream/libtest-expect-perl/current/CHANGES
URL: http://svn.debian.org/wsvn/branches/upstream/libtest-expect-perl/current/CHANGES?rev=8228&op=file
==============================================================================
--- branches/upstream/libtest-expect-perl/current/CHANGES (added)
+++ branches/upstream/libtest-expect-perl/current/CHANGES Fri Oct 12 19:18:27 2007
@@ -1,0 +1,8 @@
+Revision history for Perl module Devel::ebug
+
+0.30 Tue Feb 28 21:54:16 GMT 2006
+     - added expect_handle to fetch the underlying Expect object
+       (patch by Kevin Riggle)
+
+0.29 Wed Mar 30 23:18:02 CST 2005
+     - initial release

Added: branches/upstream/libtest-expect-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/branches/upstream/libtest-expect-perl/current/MANIFEST?rev=8228&op=file
==============================================================================
--- branches/upstream/libtest-expect-perl/current/MANIFEST (added)
+++ branches/upstream/libtest-expect-perl/current/MANIFEST Fri Oct 12 19:18:27 2007
@@ -1,0 +1,10 @@
+Build.PL
+CHANGES
+lib/Test/Expect.pm
+Makefile.PL
+MANIFEST			This list of files
+META.yml
+read
+readline
+README
+t/simple.t

Added: branches/upstream/libtest-expect-perl/current/META.yml
URL: http://svn.debian.org/wsvn/branches/upstream/libtest-expect-perl/current/META.yml?rev=8228&op=file
==============================================================================
--- branches/upstream/libtest-expect-perl/current/META.yml (added)
+++ branches/upstream/libtest-expect-perl/current/META.yml Fri Oct 12 19:18:27 2007
@@ -1,0 +1,8 @@
+--- #YAML:1.0
+name: Test-Expect
+version: 0.30
+author:
+  - Leon Brocard, C<< <acme at astray.com> >>
+abstract: Automated driving and testing of terminal-based programs
+license: perl
+generated_by: Module::Build version 0.2611, without YAML.pm

Added: branches/upstream/libtest-expect-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/branches/upstream/libtest-expect-perl/current/Makefile.PL?rev=8228&op=file
==============================================================================
--- branches/upstream/libtest-expect-perl/current/Makefile.PL (added)
+++ branches/upstream/libtest-expect-perl/current/Makefile.PL Fri Oct 12 19:18:27 2007
@@ -1,0 +1,17 @@
+# Note: this file was auto-generated by Module::Build::Compat version 0.03
+use ExtUtils::MakeMaker;
+WriteMakefile
+(
+          'NAME' => 'Test::Expect',
+          'VERSION_FROM' => 'lib/Test/Expect.pm',
+          'PREREQ_PM' => {
+                           'Class::Accessor::Chained::Fast' => '0',
+                           'Expect::Simple' => '0',
+                           'Term::ReadLine' => '0',
+                           'Test::Builder' => '0',
+                           'Test::More' => '0'
+                         },
+          'INSTALLDIRS' => 'site',
+          'PL_FILES' => {}
+        )
+;

Added: branches/upstream/libtest-expect-perl/current/README
URL: http://svn.debian.org/wsvn/branches/upstream/libtest-expect-perl/current/README?rev=8228&op=file
==============================================================================
--- branches/upstream/libtest-expect-perl/current/README (added)
+++ branches/upstream/libtest-expect-perl/current/README Fri Oct 12 19:18:27 2007
@@ -1,0 +1,77 @@
+NAME
+    Test::Expect - Automated driving and testing of terminal-based programs
+
+SYNOPSIS
+      # in a t/*.t file:
+      use Test::Expect;
+      use Test::More tests => 13;
+      expect_run(
+        command => "perl testme.pl",
+        prompt  => 'testme: ',
+        quit    => 'quit',
+      );
+      expect("ping", "pong", "expect");
+      expect_send("ping", "expect_send");
+      expect_is("* Hi there, to testme", "expect_is");
+      expect_like(qr/Hi there, to testme/, "expect_like");
+
+DESCRIPTION
+    Test::Expect is a module for automated driving and testing of
+    terminal-based programs. It is handy for testing interactive programs
+    which have a prompt, and is based on the same concepts as the Tcl Expect
+    tool. As in Expect::Simple, the Expect object is made available for
+    tweaking.
+
+    Test::Expect is intended for use in a test script.
+
+SUBROUTINES
+  expect_run
+    The expect_run subroutine sets up Test::Expect. You must pass in the
+    interactive program to run, what the prompt of the program is, and which
+    command quits the program:
+
+      expect_run(
+        command => "perl testme.pl",
+        prompt  => 'testme: ',
+        quit    => 'quit',
+      );
+
+  expect
+    The expect subroutine is the catch all subroutine. You pass in the
+    command, the expected output of the subroutine and an optional comment.
+
+      expect("ping", "pong", "expect");
+
+  expect_send
+    The expect_send subroutine sends a command to the program. You pass in
+    the command and an optional comment.
+
+      expect_send("ping", "expect_send");
+
+  expect_is
+    The expect_is subroutine tests the output of the program like
+    Test::More's is. It has an optional comment:
+
+      expect_is("* Hi there, to testme", "expect_is");
+
+  expect_like
+    The expect_like subroutine tests the output of the program like
+    Test::More's like. It has an optional comment:
+
+      expect_like(qr/Hi there, to testme/, "expect_like");
+
+  expect_handle
+    This returns the Expect object.
+
+SEE ALSO
+    Expect, Expect::Simple.
+
+AUTHOR
+    Leon Brocard, "<acme at astray.com>"
+
+COPYRIGHT
+    Copyright (C) 2005, Leon Brocard
+
+    This module is free software; you can redistribute it or modify it under
+    the same terms as Perl itself.
+

Added: branches/upstream/libtest-expect-perl/current/lib/Test/Expect.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libtest-expect-perl/current/lib/Test/Expect.pm?rev=8228&op=file
==============================================================================
--- branches/upstream/libtest-expect-perl/current/lib/Test/Expect.pm (added)
+++ branches/upstream/libtest-expect-perl/current/lib/Test/Expect.pm Fri Oct 12 19:18:27 2007
@@ -1,0 +1,183 @@
+package Test::Expect;
+use strict;
+use warnings;
+use Class::Accessor::Chained::Fast;
+use Expect::Simple;
+use Exporter;
+use Test::Builder;
+use base qw(Class::Accessor::Chained::Fast Exporter);
+__PACKAGE__->mk_accessors(qw(program));
+our $VERSION = "0.30";
+our @EXPORT = qw(
+expect_run
+expect_handle
+expect_is
+expect_like
+expect_send
+expect
+END
+);
+
+my $Test = Test::Builder->new;
+
+my $expect;
+my $sent;
+
+sub import {
+  my $self = shift;
+  if (@_) {
+    die @_;
+    my $package = caller;
+    $Test->exported_to($package);
+    $Test->plan(@_);
+  };
+  $Test->no_ending(0);
+  $self->export_to_level(1, $self, $_) foreach @EXPORT;
+}
+
+sub expect_run {
+  my(%conf) = @_;
+  $expect = Expect::Simple->new({
+  Cmd => "PERL_RL=\"o=0\" " . $conf{command},
+  Prompt => $conf{prompt},
+  DisconnectCmd => $conf{quit},
+  Verbose => 0,
+  Debug => 0,
+  Timeout => 100
+});
+  die $expect->error if $expect->error;
+  $Test->ok(1, "expect_run");
+}
+
+sub expect_handle { return $expect->expect_handle(); }
+
+sub before {
+  my $before = $expect->before;
+  $before =~ s/\r//g;
+  $before =~ s/^$sent// if $sent;
+  $before =~ s/^\n+//;
+  $before =~ s/\n+$//;
+  return $before;
+}
+
+sub expect_like {
+  my($like, $comment) = @_;
+  $Test->like(before(), $like, $comment);
+}
+
+sub expect_is {
+  my($is, $comment) = @_;
+  $Test->is_eq(before(), $is, $comment);
+}
+
+sub expect_send {
+  my($send, $comment) = @_;
+  $expect->send($send);
+  $sent = $send;
+  $Test->ok(1, $comment);
+}
+
+sub expect {
+  my($send, $is, $label) = @_;
+  expect_send($send, $label);
+  expect_is($is, $label);
+}
+
+sub END {
+  undef $expect;
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+Test::Expect - Automated driving and testing of terminal-based programs
+
+=head1 SYNOPSIS
+
+  # in a t/*.t file:
+  use Test::Expect;
+  use Test::More tests => 13;
+  expect_run(
+    command => "perl testme.pl",
+    prompt  => 'testme: ',
+    quit    => 'quit',
+  );
+  expect("ping", "pong", "expect");
+  expect_send("ping", "expect_send");
+  expect_is("* Hi there, to testme", "expect_is");
+  expect_like(qr/Hi there, to testme/, "expect_like");
+
+=head1 DESCRIPTION
+
+L<Test::Expect> is a module for automated driving and testing of
+terminal-based programs.  It is handy for testing interactive programs
+which have a prompt, and is based on the same concepts as the Tcl
+Expect tool.  As in L<Expect::Simple>, the L<Expect> object is made
+available for tweaking.
+
+L<Test::Expect> is intended for use in a test script.
+
+=head1 SUBROUTINES
+
+=head2 expect_run
+
+The expect_run subroutine sets up L<Test::Expect>. You must pass in
+the interactive program to run, what the prompt of the program is, and
+which command quits the program:
+
+  expect_run(
+    command => "perl testme.pl",
+    prompt  => 'testme: ',
+    quit    => 'quit',
+  );
+
+=head2 expect
+
+The expect subroutine is the catch all subroutine. You pass in the
+command, the expected output of the subroutine and an optional
+comment.
+
+  expect("ping", "pong", "expect");
+
+=head2 expect_send
+
+The expect_send subroutine sends a command to the program. You pass in
+the command and an optional comment.
+
+  expect_send("ping", "expect_send");
+
+=head2 expect_is
+
+The expect_is subroutine tests the output of the program like
+Test::More's is. It has an optional comment:
+
+  expect_is("* Hi there, to testme", "expect_is");
+
+=head2 expect_like
+
+The expect_like subroutine tests the output of the program like
+Test::More's like. It has an optional comment:
+
+  expect_like(qr/Hi there, to testme/, "expect_like");
+
+=head2 expect_handle
+
+This returns the L<Expect> object.
+
+=head1 SEE ALSO
+
+L<Expect>, L<Expect::Simple>.
+
+=head1 AUTHOR
+
+Leon Brocard, C<< <acme at astray.com> >>
+
+=head1 COPYRIGHT
+
+Copyright (C) 2005, Leon Brocard
+
+This module is free software; you can redistribute it or modify it
+under the same terms as Perl itself.

Added: branches/upstream/libtest-expect-perl/current/read
URL: http://svn.debian.org/wsvn/branches/upstream/libtest-expect-perl/current/read?rev=8228&op=file
==============================================================================
--- branches/upstream/libtest-expect-perl/current/read (added)
+++ branches/upstream/libtest-expect-perl/current/read Fri Oct 12 19:18:27 2007
@@ -1,0 +1,18 @@
+#!perl
+use strict;
+use warnings;
+$| = 1;
+
+print "* Hi there, to read\n";
+
+while (1) {
+  print "read: ";
+  my $command = <>;
+  chomp $command;
+
+  if ($command eq 'ping') {
+    print "pong\n";
+  } elsif ($command eq 'quit') {
+    exit;
+  }
+}

Added: branches/upstream/libtest-expect-perl/current/readline
URL: http://svn.debian.org/wsvn/branches/upstream/libtest-expect-perl/current/readline?rev=8228&op=file
==============================================================================
--- branches/upstream/libtest-expect-perl/current/readline (added)
+++ branches/upstream/libtest-expect-perl/current/readline Fri Oct 12 19:18:27 2007
@@ -1,0 +1,18 @@
+#!perl
+use strict;
+use warnings;
+use Term::ReadLine;
+
+print "* Hi there, to readline\n";
+
+my $term = Term::ReadLine->new('readline');
+
+while (1) {
+  my $command = $term->readline("readline: ");
+
+  if ($command eq 'ping') {
+    print "pong\n";
+  } elsif ($command eq 'quit') {
+    exit;
+  }
+}

Added: branches/upstream/libtest-expect-perl/current/t/simple.t
URL: http://svn.debian.org/wsvn/branches/upstream/libtest-expect-perl/current/t/simple.t?rev=8228&op=file
==============================================================================
--- branches/upstream/libtest-expect-perl/current/t/simple.t (added)
+++ branches/upstream/libtest-expect-perl/current/t/simple.t Fri Oct 12 19:18:27 2007
@@ -1,0 +1,24 @@
+#!perl
+use strict;
+use warnings;
+use lib 'lib';
+use Test::Expect;
+use Test::More tests => 18;
+
+require_ok('Expect');
+
+ok(1, "True");
+
+foreach my $filename ('read', 'readline') {
+  ok($filename, "Testing $filename");
+  expect_run(
+    command => "$^X $filename",
+    prompt  => $filename . ': ',
+    quit    => 'quit',
+  );
+  isa_ok(expect_handle(), 'Expect');
+  expect_like(qr/Hi there, to $filename/, "expect_like");
+  expect_is("* Hi there, to $filename", "expect_is");
+  expect_send("ping", "expect_send");
+  expect("ping", "pong", "expect");
+};




More information about the Pkg-perl-cvs-commits mailing list