[Rt-commit] rt branch, 4.0/test-tempdirs, created. rt-4.0.0-389-gebe34f8

Thomas Sibley trs at bestpractical.com
Wed May 18 15:24:14 EDT 2011


The branch, 4.0/test-tempdirs has been created
        at  ebe34f8cfd694a4655b012a86f2ac44bd2a2698e (commit)

- Log -----------------------------------------------------------------
commit 8f40138bd4528e39179ab2357d47465812b54b2e
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Wed May 18 15:18:27 2011 -0400

    bootstrap_tempdir is called from import, so go one step higher in the callstack
    
    This explains why test temp dirs were t/tmp/foo/ instead of
    t/tmp/my-test.t/foo/.

diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index b468aae..77e284f 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -211,7 +211,7 @@ sub db_requires_no_dba {
 sub bootstrap_tempdir {
     my $self = shift;
     my $test_file = (
-        File::Spec->rel2abs((caller)[1])
+        File::Spec->rel2abs((caller(1))[1])
             =~ m{(?:^|[\\/])t[/\\](.*)}
     );
     my $dir_name = File::Spec->rel2abs('t/tmp/'. $test_file);

commit ebe34f8cfd694a4655b012a86f2ac44bd2a2698e
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Wed May 18 15:21:20 2011 -0400

    Respect xt/ author test directories in extensions when creating tempdirs
    
    This means running a test in xt/ doesn't create a tempdir in t/tmp/.

diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index 77e284f..196f238 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -210,11 +210,14 @@ sub db_requires_no_dba {
 
 sub bootstrap_tempdir {
     my $self = shift;
-    my $test_file = (
-        File::Spec->rel2abs((caller(1))[1])
-            =~ m{(?:^|[\\/])t[/\\](.*)}
-    );
-    my $dir_name = File::Spec->rel2abs('t/tmp/'. $test_file);
+    my ($test_dir, $test_file) = ('t', '');
+
+    if (File::Spec->rel2abs((caller(1))[1]) =~ m{(?:^|[\\/])(x?t)[/\\](.*)}) {
+        $test_dir  = $1;
+        $test_file = $2;
+    }
+
+    my $dir_name = File::Spec->rel2abs("$test_dir/tmp/$test_file");
     mkpath( $dir_name );
     return $tmp{'directory'} = File::Temp->newdir(
         DIR => $dir_name

-----------------------------------------------------------------------


More information about the Rt-commit mailing list