X-Git-Url: https://git.donarmstrong.com/?p=term-progressbar.git;a=blobdiff_plain;f=t%2Fcompat.t;h=3698e57aa88747db68e22b82455cdda21ca3df76;hp=9aa8efca0dbfb1f829fd0892777ae9923c29381a;hb=14647cabb5bbb54629de8545e080519bd0be430f;hpb=3797cda1b0da9caa24c7ff35e910e1f318c77918 diff --git a/t/compat.t b/t/compat.t index 9aa8efc..3698e57 100644 --- a/t/compat.t +++ b/t/compat.t @@ -12,15 +12,7 @@ and is intended to test compatibility with that version. # Utility ----------------------------- use Data::Dumper qw( ); -use Test qw( ok plan ); - -# Test Setup -------------------------- - -BEGIN { - plan tests => 5, - todo => [], - ; -} +use Test::More tests => 4; # ------------------------------------- @@ -35,8 +27,9 @@ BEGIN { sub grab_output($) { die 'usage: grab_stderr(string to eval)' if @_ != 1; my $code = shift; - require POSIX; - my $tmp_o = POSIX::tmpnam(); my $tmp_e = POSIX::tmpnam(); + use File::Temp qw(tempdir); + my $dir = tempdir( CLEANUP => 1 ); + my $tmp_o = "$dir/out"; my $tmp_e = "$dir/err"; local (*OLDOUT, *OLDERR); # Try to get a message to the outside world if we die @@ -67,23 +60,9 @@ sub grab_output($) { return [ $o, $e ]; } -# Change 1..1 below to 1..last_test_to_print . -# (It may become useful if the test is moved to ./t subdirectory.) - use Term::ProgressBar; use POSIX qw; -=head2 Test 1: compilation - -This test confirms that the test script and the modules it calls compiled -successfully. - -=cut - -ok 1, 1, 'compilation'; - -# ------------------------------------- - $| = 1; my $count = 100; @@ -98,7 +77,7 @@ if (not $b or $o->[0] ne '' or $o->[1] ne "$test_str: ") { if $ENV{TEST_DEBUG}; print 'not '; } -print "ok 2\n"; +ok 1; # Test 3: do half the stuff and check half the bar has printed my $halfway = floor($count / 2); @@ -110,7 +89,7 @@ if ($o->[0] ne '' if $ENV{TEST_DEBUG}; print 'not '; } -print "ok 3\n"; +ok 1; # Test 4: do the rest of the stuff and check the whole bar has printed $o = grab_output("update \$b foreach ($halfway .. $count - 1)"); @@ -121,7 +100,7 @@ if ($o->[0] ne '' if $ENV{TEST_DEBUG}; print 'not '; } -print "ok 4\n"; +ok 1; # Test 5: try to do another item and check there is an error eval { update $b }; @@ -133,4 +112,4 @@ unless ( defined($@) if $ENV{TEST_DEBUG}; print 'not '; } -print "ok 5\n"; +ok 1;