From 5397fc87adb897178a4c23211cb44b310358fbd5 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Fri, 30 Apr 2010 18:16:01 -0500 Subject: tests --- t/001-term.t | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ t/002-html.t | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ t/003-detect.t | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 139 insertions(+) create mode 100644 t/001-term.t create mode 100644 t/002-html.t create mode 100644 t/003-detect.t (limited to 't') diff --git a/t/001-term.t b/t/001-term.t new file mode 100644 index 0000000..07c2751 --- /dev/null +++ b/t/001-term.t @@ -0,0 +1,51 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; +BEGIN { + eval "use IO::Pty::Easy;"; + plan skip_all => "IO::Pty::Easy is required for this test" if $@; + plan tests => 4; +} + +sub output_is { + local $Test::Builder::Level = $Test::Builder::Level + 1; + my ($script, $expected, $desc) = @_; + my $pty = IO::Pty::Easy->new; + $pty->spawn("$^X", "-e", $script); + is($pty->read, $expected, $desc); +} + +output_is(< "IO::Pty::Easy is required for this test" if $@; + plan tests => 4; +} + +sub output_is { + local $Test::Builder::Level = $Test::Builder::Level + 1; + my ($script, $expected, $desc) = @_; + my $pty = IO::Pty::Easy->new; + $pty->spawn("$^X", "-e", $script); + is($pty->read, $expected, $desc); +} + +output_is(<foo at -e line 2\n", + "simple warns work"); + +output_is(<foo at -e line 3\n\tmain::foo() called at -e line 5\n", + "warns with a stacktrace work"); + +output_is(<foo at -e line 2\n", + "simple dies work"); + +output_is(<foo at -e line 3\n\tmain::foo() called at -e line 5\n", + "dies with a stacktrace work"); diff --git a/t/003-detect.t b/t/003-detect.t new file mode 100644 index 0000000..aadcf88 --- /dev/null +++ b/t/003-detect.t @@ -0,0 +1,37 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; +BEGIN { + eval "use IO::Pty::Easy;"; + plan skip_all => "IO::Pty::Easy is required for this test" if $@; + plan tests => 2; +} + +sub output_is { + local $Test::Builder::Level = $Test::Builder::Level + 1; + my ($script, $expected, $desc) = @_; + my $pty = IO::Pty::Easy->new; + $pty->spawn("$^X", "-e", $script); + is($pty->read, $expected, $desc); +} + +output_is(<', \\\$stderr); + } + use Carp::Always::Color; + warn "foo"; + print \$stderr; +EOF + "foo at -e line 7\n", + "detection works for terminal output"); -- cgit v1.2.3-54-g00ecf