[Jifty-commit] r1901 - jifty/trunk/t
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Wed Aug 30 20:23:30 EDT 2006
Author: schwern
Date: Wed Aug 30 20:23:30 2006
New Revision: 1901
Modified:
/ (props changed)
jifty/trunk/lib/Jifty/Test.pm
jifty/trunk/t/04-test_file.t
Log:
r17647 at windhund: schwern | 2006-08-30 20:23:18 -0400
Jifty::Test->test_file() accepting and returning a list causes problems
because people will try to do: my $file = Jifty::Test->test_file($file) and
it ain't gonna DWIM.
Modified: jifty/trunk/lib/Jifty/Test.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Test.pm (original)
+++ jifty/trunk/lib/Jifty/Test.pm Wed Aug 30 20:23:30 2006
@@ -298,26 +298,26 @@
=head2 test_file
- my @files = Jifty::Test->test_file(@files);
+ my $files = Jifty::Test->test_file($file);
-Register @files as having been created by the test. They will be
+Register $file as having been created by the test. It will be
cleaned up at the end of the test run I<if and only if> the test
-passes. Otherwise they will be left alone.
+passes. Otherwise it will be left alone.
-It returns @files so you can do this:
+It returns $file so you can do this:
- my @files = Jifty::Test->test_file( Jifty::Util->absolute_path("t/foo") );
+ my $file = Jifty::Test->test_file( Jifty::Util->absolute_path("t/foo") );
=cut
my @Test_Files_To_Cleanup;
sub test_file {
my $class = shift;
- my @files = @_;
+ my $file = shift;
- push @Test_Files_To_Cleanup, @files;
+ push @Test_Files_To_Cleanup, $file;
- return @files;
+ return $file;
}
Modified: jifty/trunk/t/04-test_file.t
==============================================================================
--- jifty/trunk/t/04-test_file.t (original)
+++ jifty/trunk/t/04-test_file.t Wed Aug 30 20:23:30 2006
@@ -5,14 +5,11 @@
use Shell::Command;
-use Jifty::Test 'no_plan';
+use Jifty::Test tests => 10;
{
my $tmpfile = "t/foo";
- is_deeply( [Jifty::Test->test_file( $tmpfile )], [$tmpfile] );
- touch( $tmpfile );
-
- is_deeply( [Jifty::Test->test_file( $tmpfile )], [$tmpfile] );
+ is( Jifty::Test->test_file( $tmpfile ), $tmpfile );
touch( $tmpfile );
ok -e $tmpfile;
@@ -20,6 +17,18 @@
ok !-e $tmpfile;
}
+
+{
+ my @tmpfiles = ("t/foo", "t/bar");
+ is( Jifty::Test->test_file( $_ ), $_ ) for @tmpfiles;
+ touch( $_ ) for @tmpfiles;
+
+ ok -e $_ for @tmpfiles;
+ Jifty::Test->_ending;
+ ok !-e $_ for @tmpfiles;
+}
+
+
{
my $tmpfile = "t/bar";
Jifty::Test->test_in_isolation( sub {
More information about the Jifty-commit
mailing list