# Utility -----------------------------
use Data::Dumper qw( );
-use Test qw( ok plan );
-
-# Test Setup --------------------------
-
-BEGIN {
- plan tests => 5,
- todo => [],
- ;
-}
+use Test::More tests => 4;
# -------------------------------------
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
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<floor ceil>;
-=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;
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);
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)");
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 };
if $ENV{TEST_DEBUG};
print 'not ';
}
-print "ok 5\n";
+ok 1;